summaryrefslogtreecommitdiffstats
path: root/build-glib2.sh
blob: 6e20893e0ad6716297cd883fc4ae5a892b7b4401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /bin/sh

# Download and build glib 2.x statically with all dependencies and then
# compile GNU Midnight Commander against it.
# Copyright (C) 2003 Pavel Roskin
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.

#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# This script is incomplete!  It doesn't download libiconv.  This is OK
# for glibc-based systems, but probably not for others.  This limitation
# is known.  Please don't report it.


: ${MC_TOPDIR=`pwd`}
: ${WORK_TOPDIR=$MC_TOPDIR/build_glib2}
: ${TMP_INSTDIR=$WORK_TOPDIR/tmp-inst}
: ${GLIB_VERSION=2.30.0}
: ${PKGC_VERSION=0.23}
: ${GETTEXT_VERSION=0.17}

GLIB_DIR="glib-$GLIB_VERSION"
GLIB_TARBALL="glib-$GLIB_VERSION.tar.bz2"
GLIB_URL="https://download.gnome.org/sources/glib/2.30/$GLIB_TARBALL"

PKGC_DIR="pkg-config-$PKGC_VERSION"
PKGC_TARBALL="pkg-config-$PKGC_VERSION.tar.gz"
PKGC_URL="http://pkgconfig.freedesktop.org/releases/$PKGC_TARBALL"

GETTEXT_DIR="gettext-$GETTEXT_VERSION/gettext-runtime"
GETTEXT_TARBALL="gettext-$GETTEXT_VERSION.tar.gz"
GETTEXT_URL="ftp://ftp.gnu.org/gnu/gettext/$GETTEXT_TARBALL"

get_file() {
  curl --remote-name "$1" || \
  wget --passive-ftp "$1" || \
  wget "$1" || \
  ftp "$1" </dev/null || \
  exit 1
}
if test ! -d $WORK_TOPDIR; then
    mkdir -p $WORK_TOPDIR
fi

if test -f $MC_TOPDIR/src/dir.c; then : ; else
  echo "Not in the top-level directory of GNU Midnight Commander." 2>&1
  exit 1
fi

if test -f $MC_TOPDIR/configure; then : ; else
  $MC_TOPDIR/autogen.sh --help >/dev/null || exit 1
fi

rm -rf "$TMP_INSTDIR"
PATH="$TMP_INSTDIR/bin:$PATH"
export PATH

# Compile gettext
cd "$WORK_TOPDIR"
if gzip -vt "$GETTEXT_TARBALL"; then : ; else
  get_file "$GETTEXT_URL"
fi

rm -rf "$GETTEXT_DIR"
gzip -cd "$GETTEXT_TARBALL" | tar xf -
cd "$GETTEXT_DIR"
if test -f src/gettext.c; then : ; else
  echo "gettext source is incomplete" 2>&1
  exit 1
fi

./configure --disable-shared --disable-nls --prefix="$TMP_INSTDIR" || exit 1
make all || exit 1
make install || exit 1

# Compile pkgconfig
cd "$WORK_TOPDIR"
if gzip -vt "$PKGC_TARBALL"; then : ; else
  get_file "$PKGC_URL"
fi

rm -rf "$PKGC_DIR"
gzip -cd "$PKGC_TARBALL" | tar xf -
cd "$PKGC_DIR"
if test -f pkg.c; then : ; else
  echo "pkgconfig source is incomplete" 2>&1
  exit 1
fi

./configure --disable-shared --prefix="$TMP_INSTDIR" || exit 1
make all || exit 1
make install || exit 1

# Compile glib
cd "$WORK_TOPDIR"
if gzip -vt "$GLIB_TARBALL"; then : ; else
  get_file "$GLIB_URL" || exit 1
fi

rm -rf "$GLIB_DIR"
gzip -cd "$GLIB_TARBALL" | tar xf -
cd "$GLIB_DIR"
if test -f glib/glist.c; then : ; else
  echo "glib source is incomplete" 2>&1
  exit 1
fi

./configure --disable-shared --prefix="$TMP_INSTDIR" \
	    PKG_CONFIG="$TMP_INSTDIR/bin/pkg-config" \
	    CPPFLAGS="-I$TMP_INSTDIR/include" \
	    LDFLAGS="-L$TMP_INSTDIR/lib" || exit 1
make all || exit 1
make install || exit 1

cd "$MC_TOPDIR"
./configure PKG_CONFIG="$TMP_INSTDIR/bin/pkg-config" $@ || exit 1
make clean || exit 1
make || exit 1

echo "GNU Midnight Commander has been successfully compiled"