]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | # | |
4 | # Helps generate autoconf/automake stuff, when code is checked out from SCM. | |
5 | # | |
6 | # Copyright (C) 2006-2010 - Karel Zak <kzak@redhat.com> | |
7 | # | |
8 | ||
9 | srcdir=`dirname $0` | |
10 | test -z "$srcdir" && srcdir=. | |
11 | ||
12 | THEDIR=`pwd` | |
13 | cd $srcdir | |
14 | DIE=0 | |
15 | ||
16 | warn_mesg () | |
17 | { | |
18 | echo | |
19 | echo "WARNING: $1" | |
20 | test -z "$2" || | |
21 | echo " $2" | |
22 | echo | |
23 | } | |
24 | ||
25 | error_mesg () | |
26 | { | |
27 | echo | |
28 | echo "ERROR: $1" | |
29 | test -z "$2" || | |
30 | echo " $2" | |
31 | echo | |
32 | DIE=1 | |
33 | } | |
34 | ||
35 | # provide simple gettext backward compatibility | |
36 | autopoint_fun () | |
37 | { | |
38 | # we have to deal with set -e ... | |
39 | ret="0" | |
40 | ||
41 | # check against this hardcoded set of alternative gettext versions | |
42 | gt_ver=`gettext --version |\ | |
43 | sed -n -e 's/.* \(0\.17\|0\.18\|0\.18\.[1-2]\)$/\1/p'` | |
44 | ||
45 | if [ -n "$gt_ver" ]; then | |
46 | warn_mesg "warning: forcing autopoint to use old gettext $gt_ver" | |
47 | rm -f configure.ac.autogenbak | |
48 | sed -i.autogenbak configure.ac \ | |
49 | -e "s/\(AM_GNU_GETTEXT_VERSION\).*/\1([$gt_ver])/" | |
50 | fi | |
51 | ||
52 | autopoint "$@" || ret=$? | |
53 | ||
54 | if [ -n "$gt_ver" ]; then | |
55 | mv configure.ac.autogenbak configure.ac | |
56 | fi | |
57 | ||
58 | return $ret | |
59 | } | |
60 | ||
61 | test -f sys-utils/mount.c || | |
62 | error_mesg "You must run this script in the top-level util-linux directory." | |
63 | ||
64 | (autopoint --version) < /dev/null > /dev/null 2>&1 || | |
65 | error_mesg "You must have autopoint installed to generate the util-linux build system." "The autopoint command is part of the GNU gettext package." | |
66 | ||
67 | (autoconf --version) < /dev/null > /dev/null 2>&1 || | |
68 | error_mesg "You must have autoconf installed to generate the util-linux build system." | |
69 | ||
70 | (autoheader --version) < /dev/null > /dev/null 2>&1 || | |
71 | error_mesg "You must have autoheader installed to generate the util-linux build system." "The autoheader command is part of the GNU autoconf package." | |
72 | ||
73 | [ -x "$(command -v gettext)" -o -x "$(command -v xgettext)" ] || | |
74 | warn_mesg "You need have [x]gettext binary installed to update po/ stuff." | |
75 | ||
76 | (flex --version) < /dev/null > /dev/null 2>&1 || | |
77 | error_mesg "You must have flex installed to build the util-linux." | |
78 | ||
79 | if ! (bison --version) < /dev/null > /dev/null 2>&1; then | |
80 | error_mesg "You must have bison installed to build the util-linux." | |
81 | else | |
82 | lexver=$(bison --version | awk '/^bison \(GNU [Bb]ison\)/ { print $4 }') | |
83 | case "$lexver" in | |
84 | [2-9].*) | |
85 | ;; | |
86 | *) | |
87 | error_mesg "You must have bison version >= 2.x, but you have $lexver." | |
88 | ;; | |
89 | esac | |
90 | fi | |
91 | ||
92 | ||
93 | LIBTOOLIZE=libtoolize | |
94 | case `uname` in Darwin*) LIBTOOLIZE=glibtoolize ;; esac | |
95 | if ! ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1; then | |
96 | error_mesg "You must have libtool-2 installed to generate the util-linux build system." | |
97 | else | |
98 | ltver=$($LIBTOOLIZE --version | awk '/^[g]*libtoolize/ { print $4 }') | |
99 | ltver=${ltver:-"none"} | |
100 | test ${ltver##2.} = "$ltver" && | |
101 | error_mesg "You must have libtool version >= 2.x.x, but you have $ltver." | |
102 | fi | |
103 | ||
104 | (automake --version) < /dev/null > /dev/null 2>&1 || | |
105 | error_mesg "You must have automake installed to generate the util-linux build system." | |
106 | ||
107 | if test "$DIE" -eq 1; then | |
108 | exit 1 | |
109 | fi | |
110 | ||
111 | echo | |
112 | echo "Generating build-system with:" | |
113 | echo " autopoint: $(autopoint --version | head -1)" | |
114 | echo " aclocal: $(aclocal --version | head -1)" | |
115 | echo " autoconf: $(autoconf --version | head -1)" | |
116 | echo " autoheader: $(autoheader --version | head -1)" | |
117 | echo " automake: $(automake --version | head -1)" | |
118 | echo " libtoolize: $($LIBTOOLIZE --version | head -1)" | |
119 | echo " flex: $(flex --version | head -1)" | |
120 | echo " bison: $(bison --version | head -1)" | |
121 | echo | |
122 | ||
123 | rm -rf autom4te.cache | |
124 | ||
125 | set -e | |
126 | po/update-potfiles | |
127 | autopoint_fun --force $AP_OPTS | |
128 | if ! grep -q datarootdir po/Makefile.in.in; then | |
129 | echo "INFO: autopoint does not honor dataroot variable, patching." | |
130 | sed -i -e 's/^datadir *=\(.*\)/datarootdir = @datarootdir@\ | |
131 | datadir = @datadir@/g' po/Makefile.in.in | |
132 | fi | |
133 | $LIBTOOLIZE --force $LT_OPTS | |
134 | ||
135 | # patch libtool | |
136 | if test -f tools/libtool.m4.patch; then | |
137 | if test -L m4/libtool.m4; then | |
138 | cp m4/libtool.m4 m4/libtool.m4.org | |
139 | rm m4/libtool.m4 | |
140 | mv m4/libtool.m4.org m4/libtool.m4 | |
141 | fi | |
142 | set +e | |
143 | patch --batch --dry -p1 < tools/libtool.m4.patch > /dev/null 2>&1 | |
144 | if [ "$?" -eq 0 ]; then | |
145 | patch -p1 --batch < tools/libtool.m4.patch | |
146 | fi | |
147 | set -e | |
148 | fi | |
149 | ||
150 | aclocal -I m4 $AL_OPTS | |
151 | autoconf $AC_OPTS | |
152 | autoheader $AH_OPTS | |
153 | ||
154 | automake --add-missing $AM_OPTS | |
155 | ||
156 | ||
157 | cd "$THEDIR" | |
158 | ||
159 | echo | |
160 | echo "Now type '$srcdir/configure' and 'make' to compile." | |
161 | echo | |
162 | ||
163 |