build-glib2.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 2 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. #
  16. # You should have received a copy of the GNU General Public License along
  17. # with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. # This script is incomplete! It doesn't download libiconv. This is OK
  20. # for glibc-based systems, but probably not for others. This limitation
  21. # is known. Please don't report it.
  22. : ${MC_TOPDIR=`pwd`}
  23. : ${WORK_TOPDIR=$MC_TOPDIR/build_glib2}
  24. : ${TMP_INSTDIR=$WORK_TOPDIR/tmp-inst}
  25. : ${GLIB_VERSION=2.21.0}
  26. : ${PKGC_VERSION=0.23}
  27. : ${GETTEXT_VERSION=0.17}
  28. GLIB_DIR="glib-$GLIB_VERSION"
  29. GLIB_TARBALL="glib-$GLIB_VERSION.tar.gz"
  30. GLIB_URL="ftp://ftp.gtk.org/pub/glib/2.21/$GLIB_TARBALL"
  31. PKGC_DIR="pkg-config-$PKGC_VERSION"
  32. PKGC_TARBALL="pkg-config-$PKGC_VERSION.tar.gz"
  33. PKGC_URL="http://pkgconfig.freedesktop.org/releases/$PKGC_TARBALL"
  34. GETTEXT_DIR="gettext-$GETTEXT_VERSION/gettext-runtime"
  35. GETTEXT_TARBALL="gettext-$GETTEXT_VERSION.tar.gz"
  36. GETTEXT_URL="ftp://ftp.gnu.org/gnu/gettext/$GETTEXT_TARBALL"
  37. get_file() {
  38. curl --remote-name "$1" || \
  39. wget --passive-ftp "$1" || \
  40. wget "$1" || \
  41. ftp "$1" </dev/null || \
  42. exit 1
  43. }
  44. if test ! -d $WORK_TOPDIR; then
  45. mkdir -p $WORK_TOPDIR
  46. fi
  47. if test -f $MC_TOPDIR/src/dir.c; then : ; else
  48. echo "Not in the top-level directory of GNU Midnight Commander." 2>&1
  49. exit 1
  50. fi
  51. if test -f $MC_TOPDIR/configure; then : ; else
  52. $MC_TOPDIR/autogen.sh --help >/dev/null || exit 1
  53. fi
  54. rm -rf "$TMP_INSTDIR"
  55. PATH="$TMP_INSTDIR/bin:$PATH"
  56. export PATH
  57. # Compile gettext
  58. cd "$WORK_TOPDIR"
  59. if gzip -vt "$GETTEXT_TARBALL"; then : ; else
  60. get_file "$GETTEXT_URL"
  61. fi
  62. rm -rf "$GETTEXT_DIR"
  63. gzip -cd "$GETTEXT_TARBALL" | tar xf -
  64. cd "$GETTEXT_DIR"
  65. if test -f src/gettext.c; then : ; else
  66. echo "gettext source is incomplete" 2>&1
  67. exit 1
  68. fi
  69. ./configure --disable-shared --disable-nls --prefix="$TMP_INSTDIR" || exit 1
  70. make all || exit 1
  71. make install || exit 1
  72. # Compile pkgconfig
  73. cd "$WORK_TOPDIR"
  74. if gzip -vt "$PKGC_TARBALL"; then : ; else
  75. get_file "$PKGC_URL"
  76. fi
  77. rm -rf "$PKGC_DIR"
  78. gzip -cd "$PKGC_TARBALL" | tar xf -
  79. cd "$PKGC_DIR"
  80. if test -f pkg.c; then : ; else
  81. echo "pkgconfig source is incomplete" 2>&1
  82. exit 1
  83. fi
  84. ./configure --disable-shared --prefix="$TMP_INSTDIR" || exit 1
  85. make all || exit 1
  86. make install || exit 1
  87. # Compile glib
  88. cd "$WORK_TOPDIR"
  89. if gzip -vt "$GLIB_TARBALL"; then : ; else
  90. get_file "$GLIB_URL" || exit 1
  91. fi
  92. rm -rf "$GLIB_DIR"
  93. gzip -cd "$GLIB_TARBALL" | tar xf -
  94. cd "$GLIB_DIR"
  95. if test -f glib/glist.c; then : ; else
  96. echo "glib source is incomplete" 2>&1
  97. exit 1
  98. fi
  99. ./configure --disable-shared --prefix="$TMP_INSTDIR" \
  100. PKG_CONFIG="$TMP_INSTDIR/bin/pkg-config" \
  101. CPPFLAGS="-I$TMP_INSTDIR/include" \
  102. LDFLAGS="-L$TMP_INSTDIR/lib" || exit 1
  103. make all || exit 1
  104. make install || exit 1
  105. cd "$MC_TOPDIR"
  106. ./configure PKG_CONFIG="$TMP_INSTDIR/bin/pkg-config" $@ || exit 1
  107. make clean || exit 1
  108. make || exit 1
  109. echo "GNU Midnight Commander has been successfully compiled"