/
bootstrap
executable file
·378 lines (340 loc) · 11.5 KB
/
bootstrap
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/sh
# bootstrap a xapian source tree obtained from SVN to produce a tree like
# you'd get from unpacking the results of "make dist"
#
# Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Olly Betts
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
if [ "$1" = "--help" ] ; then
echo "$0 [--without-autotools|--clean]"
exit 0
fi
trap 'echo "Bootstrap failed"' EXIT
set -e
# The variables which specify the autotools to use.
autotools="AUTORECONF AUTOCONF AUTOHEADER AUTOM4TE AUTOMAKE ACLOCAL LIBTOOLIZE"
# Tool for downloading a file from a URL (currently wget or curl).
FETCH_URL_TOOL=
lazy_build() {
package=$1
basename=$package-$2
ext=$3
checksum=$4
tarball=$basename.$ext
case $basename in
*[a-z]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
esac
# Create the stamp file in INST so that rerunning bootstrap after
# "rm -rf INST" recovers nicely.
stamp=../INST/$package.stamp
# Temporary measure to "upgrade" from having the stamp file in BUILD. Doing
# this isn't vital but saves having to rebuild needlessly and cleans up the
# old stamp file too.
# FIXME: remove once everyone has had a chance to re-bootstrap.
test ! -f "$package.stamp" || mv "$package.stamp" "$stamp"
# Download the tarball if required.
if [ ! -f "$tarball" ] ; then
if [ -z "$FETCH_URL_TOOL" ] ; then
if ${WGET-wget} --version > /dev/null 2>&1 ; then
FETCH_URL_TOOL=${WGET-wget}
elif ${CURL-curl} --version > /dev/null 2>&1 || [ "$?" = 2 ] ; then
# curl --version exists with code 2.
FETCH_URL_TOOL=${CURL-curl}
else
echo "Neither wget nor curl found - set WGET or CURL to the full path," >&2
echo "or download $url to directory `pwd` by hand and rerun this script." >&2
exit 1
fi
fi
$FETCH_URL_TOOL "ftp://ftp.gnu.org/gnu/$package/$tarball"
fi
if [ -f "$stamp" ] ; then
find_stdout=`find "$stamp" -newer "$tarball" -print`
else
find_stdout=
fi
if [ -z "$find_stdout" ] ; then
# Verify the tarball's checksum before building it.
echo "$checksum $tarball"|sha1sum -c
for f in "$package"-* ; do
[ "$f" = "$tarball" ] || rm -rf "$f"
done
case $ext in
tar.bz2)
bzip2 -dc "$tarball"| tar xf - ;;
*)
gzip -dc "$tarball"| tar xf - ;;
esac
cd "$basename"
./configure --prefix="$instdir"
make
make install
cd ..
rm -rf "$basename"
touch "$stamp"
fi
}
curdir=`pwd`
# cd to srcdir if we aren't already there.
srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
case $srcdir in
""|.)
srcdir=. ;;
*)
cd "$srcdir" ;;
esac
if [ "$1" = "--without-autotools" ] ; then
shift
else
if [ "$1" = "--clean" ] ; then
shift
rm -rf INST
# FIXME: remove once everyone has had a chance to re-bootstrap.
rm -f INST BUILD/*.stamp
fi
[ -d INST ] || mkdir INST
instdir=`pwd`/INST
[ -d BUILD ] || mkdir BUILD
cd BUILD
# The last field is the SHA1 checksum of the tarball.
lazy_build autoconf 2.62 tar.bz2 de2b6f57da07427794c56e25844e31f35fc46755
lazy_build automake 1.10.1 tar.bz2 cd2e0f7054d4edc75cbf87cd8a92962b3b417b74
lazy_build libtool 2.2.6a tar.gz 7b547877b1b78b547343e4678a531aece8949904
for v in $autotools ; do
tool=`echo "$v"|tr A-Z a-z`
eval "$v=\"\$instdir\"/bin/$tool;export $v"
done
cd ..
fi
case `${LIBTOOLIZE-libtoolize} --version` in
"")
echo "${LIBTOOLIZE-libtoolize} not found"
exit 1 ;;
"libtoolize (GNU libtool) 1.4.*")
echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
exit 1 ;;
"libtoolize (GNU libtool) 1.5.*")
echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
exit 1 ;;
esac
ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
intree_swig=no
# We no longer snapshot xapian-applications/queryserver since it hasn't seen a
# check-in for ages.
modules=
for module in xapian-core xapian-applications/omega swig xapian-bindings ; do
d=$module
if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
echo "Bootstrapping \`$module'"
[ -f "$d/preautoreconf" ] && "$d/preautoreconf"
# If we have a custom INSTALL file, preserve it since autoreconf insists on
# replacing INSTALL with "generic installation instructions" when --force
# is used. Be careful to replace it if autoreconf fails.
if [ -f "$d/INSTALL" ] ; then
if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
:
else
mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
fi
fi
autoreconf_rc=
if [ swig = "$module" ] ; then
# SWIG provides its own bootstrapping script.
curdir=`pwd`
cd "$d"
./autogen.sh || autoreconf_rc=$?
cd "$curdir"
# Use the uninstalled wrapper for the in-tree copy of SWIG.
intree_swig=yes
else
# Use --install as debian's autoconf wrapper uses 2.5X if it sees it
# (but it doesn't check for -i).
#
# Use --force so that we update files if autoconf, automake, or libtool
# has been upgraded.
${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
fi
if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
fi
if [ -n "$autoreconf_rc" ] ; then
exit $autoreconf_rc
fi
modules="$modules $module"
fi
done
# Search::Xapian doesn't use autotools.
if [ -f "search-xapian/Makefile.PL" ] ; then
modules="$modules search-xapian"
fi
# Generate the top-level configure script.
rm -f configure.tmp
cat <<'TOP_OF_CONFIGURE' > configure.tmp
#!/bin/sh
# configure each submodule in a xapian source tree
# Generated by Xapian top-level bootstrap script.
#
# Copyright (C) 2003,2004,2007,2008 Olly Betts
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
# USA
trap 'echo "configure failed"' EXIT
set -e
# Produced escaped version of command suitable for pasting back into sh
cmd=$0
for a ; do
case $a in
*[^-A-Za-z0-9_+=:@/.,]*)
esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
cmd="$cmd $esc_a" ;;
*)
cmd="$cmd $a" ;;
esac
done
here=`pwd`
TOP_OF_CONFIGURE
# Produce an absolute path to srcdir.
srcdir_abs=`pwd`
# This section is unquoted so we can substitute variables.
cat <<MIDDLE_OF_CONFIGURE >> configure.tmp
srcdir="$srcdir_abs"
modules="$modules"
MIDDLE_OF_CONFIGURE
vars=
if [ yes = "$intree_swig" ] ; then
# We want the path to SWIG to point into srcdir, which isn't known until
# configure-time, so we need to expand $here in configure. We can't just set
# SWIG here and let the case below handle it as that would escape the value
# such that $here didn't get expanded at all.
echo ': ${SWIG="$here/swig/preinst-swig"}' >> configure.tmp
echo "export SWIG" >> configure.tmp
vars=' SWIG=$here/swig/preinst-swig'
# Kill any existing setting of SWIG so that we don't try to handle it again
# below.
SWIG=
fi
for tool in SWIG $autotools ; do
eval "val=\$$tool"
if [ -n "$val" ] ; then
echo ': ${'"$tool=\"$val\""'}' >> configure.tmp
echo "export $tool" >> configure.tmp
vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
fi
done
if [ -n "$vars" ] ; then
# $vars will always have a leading space.
echo "set$vars "'"$@"' >> configure.tmp
fi
cat <<'END_OF_CONFIGURE' >> configure.tmp
dirs=
XAPIAN_CONFIG=$here/xapian-core/xapian-config
for d in $modules ; do
if [ "$here" = "$srcdir" ] ; then
configure=./configure
else
configure=$srcdir/$d/configure
fi
if [ -f "$configure" ] ; then
if [ -d "$d" ] ; then : ; else
case $d in
xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
esac
mkdir "$d"
fi
echo "Configuring \`$d'"
# Use a shared config.cache for speed and to save a bit of diskspace, but
# don't share it with SWIG just in case it manages to probe and cache
# different answers (e.g. because it uses a C compiler).
case $d in
swig)
cd "$d" && "$configure" ${1+"$@"}
;;
xapian-core)
cd "$d" && "$configure" --enable-maintainer-mode --cache-file="$here/config.cache" ${1+"$@"}
;;
search-xapian)
# Extract any CXX=... argument from those passed to us.
unset cxxarg
for arg
do
case $arg in
CXX=*) cxxarg=$arg ;;
esac
done
cd "$d" && perl Makefile.PL XAPIAN_CONFIG="$XAPIAN_CONFIG" ${cxxarg+"$cxxarg"}
;;
*)
cd "$d" && "$configure" --enable-maintainer-mode --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
;;
esac
cd "$here"
dirs="$dirs $d"
fi
done
rm -f Makefile.tmp
echo "# Makefile generated by:" > Makefile.tmp
echo "# $cmd" >> Makefile.tmp
for target in all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck ; do
echo >> Makefile.tmp
echo "$target:" >> Makefile.tmp
for d in $dirs ; do
case $d,$target in
swig,install*|swig,uninstall|swig,dist|swig,check|swig,distcheck|swig,all)
# Need to ensure swig is built before "make dist", "make check", etc.
echo " cd $d && \$(MAKE)" >> Makefile.tmp ;;
swig,mostlyclean|search-xapian,mostlyclean)
echo " cd $d && \$(MAKE) clean" >> Makefile.tmp ;;
search-xapian,install-strip)
echo " cd $d && \$(MAKE) install" >> Makefile.tmp ;;
search-xapian,maintainer-clean)
echo " cd $d && \$(MAKE) realclean" >> Makefile.tmp ;;
search-xapian,distcheck)
echo " cd $d && \$(MAKE) disttest" >> Makefile.tmp ;;
xapian-bindings,distcheck)
# FIXME: distcheck doesn't currently work for xapian-bindings because
# xapian-core isn't installed.
echo " cd $d && \$(MAKE) check dist" >> Makefile.tmp ;;
*)
echo " cd $d && \$(MAKE) $target" >> Makefile.tmp ;;
esac
done
case $target in
distclean) echo " rm -f Makefile config.cache" >> Makefile.tmp ;;
maintainer-clean) echo " rm -f Makefile configure config.cache" >> Makefile.tmp ;;
esac
done
mv -f Makefile.tmp Makefile
trap - EXIT
echo "Configured successfully - now run \"${MAKE-make}\""
END_OF_CONFIGURE
chmod +x configure.tmp
mv -f configure.tmp configure
trap - EXIT
echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""