build-glib2.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #! /bin/sh
  2. # Download and build glib 2.x statically with all dependencies and then
  3. # compile GNU Midnight Commander against it.
  4. # Copyright (C) 2003 Pavel Roskin
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. # This script is incomplete! It doesn't download libiconv. This is OK
  19. # for glibc-based systems, but probably not for others. This limitation
  20. # is known. Please don't report it.
  21. : ${MC_TOPDIR=`pwd`}
  22. : ${WORK_TOPDIR=$MC_TOPDIR/build_glib2}
  23. : ${TMP_INSTDIR=$WORK_TOPDIR/tmp-inst}
  24. : ${GLIB_VERSION=2.30.0}
  25. : ${PKGC_VERSION=0.23}
  26. : ${GETTEXT_VERSION=0.17}
  27. GLIB_DIR="glib-$GLIB_VERSION"
  28. GLIB_TARBALL="glib-$GLIB_VERSION.tar.bz2"
  29. GLIB_URL="https://download.gnome.org/sources/glib/2.30/$GLIB_TARBALL"
  30. PKGC_DIR="pkg-config-$PKGC_VERSION"
  31. PKGC_TARBALL="pkg-config-$PKGC_VERSION.tar.gz"
  32. PKGC_URL="http://pkgconfig.freedesktop.org/releases/$PKGC_TARBALL"
  33. GETTEXT_DIR="gettext-$GETTEXT_VERSION/gettext-runtime"
  34. GETTEXT_TARBALL="gettext-$GETTEXT_VERSION.tar.gz"
  35. GETTEXT_URL="ftp://ftp.gnu.org/gnu/gettext/$GETTEXT_TARBALL"
  36. get_file() {
  37. curl --remote-name "$1" || \
  38. wget --passive-ftp "$1" || \
  39. wget "$1" || \
  40. ftp "$1" </dev/null || \
  41. exit 1
  42. }
  43. if test ! -d $WORK_TOPDIR; then
  44. mkdir -p $WORK_TOPDIR
  45. fi
  46. if test -f $MC_TOPDIR/src/dir.c; then : ; else
  47. echo "Not in the top-level directory of GNU Midnight Commander." 2>&1
  48. exit 1
  49. fi
  50. if test -f $MC_TOPDIR/configure; then : ; else
  51. $MC_TOPDIR/autogen.sh --help >/dev/null || exit 1
  52. fi
  53. rm -rf "$TMP_INSTDIR"
  54. PATH="$TMP_INSTDIR/bin:$PATH"
  55. export PATH
  56. # Compile gettext
  57. cd "$WORK_TOPDIR"
  58. if gzip -vt "$GETTEXT_TARBALL"; then : ; else
  59. get_file "$GETTEXT_URL"
  60. fi
  61. rm -rf "$GETTEXT_DIR"
  62. gzip -cd "$GETTEXT_TARBALL" | tar xf -
  63. cd "$GETTEXT_DIR"
  64. if test -f src/gettext.c; then : ; else
  65. echo "gettext source is incomplete" 2>&1
  66. exit 1
  67. fi
  68. ./configure --disable-shared --disable-nls --prefix="$TMP_INSTDIR" || exit 1
  69. make all || exit 1
  70. make install || exit 1
  71. # Compile pkgconfig
  72. cd "$WORK_TOPDIR"
  73. if gzip -vt "$PKGC_TARBALL"; then : ; else
  74. get_file "$PKGC_URL"
  75. fi
  76. rm -rf "$PKGC_DIR"
  77. gzip -cd "$PKGC_TARBALL" | tar xf -
  78. cd "$PKGC_DIR"
  79. if test -f pkg.c; then : ; else
  80. echo "pkgconfig source is incomplete" 2>&1
  81. exit 1
  82. fi
  83. ./configure --disable-shared --prefix="$TMP_INSTDIR" || exit 1
  84. make all || exit 1
  85. make install || exit 1
  86. # Compile glib
  87. cd "$WORK_TOPDIR"
  88. if gzip -vt "$GLIB_TARBALL"; then : ; else
  89. get_file "$GLIB_URL" || exit 1
  90. fi
  91. rm -rf "$GLIB_DIR"
  92. gzip -cd "$GLIB_TARBALL" | tar xf -
  93. cd "$GLIB_DIR"
  94. if test -f glib/glist.c; then : ; else
  95. echo "glib source is incomplete" 2>&1
  96. exit 1
  97. fi
  98. ./configure --disable-shared --prefix="$TMP_INSTDIR" \
  99. PKG_CONFIG="$TMP_INSTDIR/bin/pkg-config" \
  100. CPPFLAGS="-I$TMP_INSTDIR/include" \
  101. LDFLAGS="-L$TMP_INSTDIR/lib" || exit 1
  102. make all || exit 1
  103. make install || exit 1
  104. cd "$MC_TOPDIR"
  105. ./configure PKG_CONFIG="$TMP_INSTDIR/bin/pkg-config" $@ || exit 1
  106. make clean || exit 1
  107. make || exit 1
  108. echo "GNU Midnight Commander has been successfully compiled"