Optimise diversification by implementing C2-GLS
[xapian.git] / bootstrap
blob781f4538bc9ac0101aba1922c9cbb933217371d7
1 #!/bin/sh
2 # bootstrap a xapian source tree obtained from git to produce a tree like
3 # you'd get from unpacking the results of "make dist"
5 copyright='
6 # Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018 Olly Betts
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of the
11 # License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 # USA
24 if [ "$1" = "--help" ] ; then
25 cat <<__END__
26 $0 [--ftp|--http] [--download-tools=(always|ifneeded|never)] [--fetch-url-command=CMD] [--clean] [MODULE...]
28 The default is to bootstrap all known modules. Any modules which have a
29 file called ".nobootstrap" in their top-level will be skipped.
30 __END__
31 exit 0
34 trap 'echo "Bootstrap failed"' EXIT
35 set -e
37 # The variables which specify the autotools to use.
38 autotools="AUTORECONF AUTOCONF AUTOHEADER AUTOM4TE AUTOMAKE ACLOCAL LIBTOOLIZE"
40 # Tool for downloading a file from a URL (currently wget, curl, and lwp-request
41 # are probed for in that order). Can be specified with --fetch-url-command.
42 FETCH_URL_TOOL=
44 check_checksum() {
45 # This function is expected to be used in 'if' so we can't rely on set -e
46 # being in effect here.
47 checksum=$1
48 tarball=$2
50 if [ -z "$SHA256SUM_TOOL" ] ; then
51 for SHA256SUM_TOOL in \
52 '${SHA256SUM-sha256sum} 2>/dev/null|cut -d\ -f1' \
53 '${SHASUM-shasum} -a256 2>/dev/null|cut -d\ -f1' \
54 '${OPENSSL-openssl} sha256 2>/dev/null|sed "s/.* //"' \
55 '' ; do
56 if [ -z "$SHA256SUM_TOOL" ] ; then
57 echo <<'END'
58 Need sha256sum or shasum or openssl installed to check SHA256 checksums.
59 Set environment variable SHA256SUM, SHASUM or OPENSSL if the tool isn't on
60 your PATH.
61 END
62 exit 1
64 # Sanity check by hashing empty input.
65 r=`:|eval "$SHA256SUM_TOOL"`
66 [ X"$r" != Xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ] || break
67 done
69 r=`< $tarball eval "$SHA256SUM_TOOL"`
70 if [ X"$r" != X"$checksum" ] ; then
71 echo "$tarball: computed SHA256 checksum did NOT match"
72 echo "computed: $r with $SHA256SUM_TOOL"
73 echo "expected: $checksum"
74 ls -l $tarball
75 file $tarball || true
76 mv "$tarball" "$tarball.$r"
77 echo "Renamed $tarball to $tarball.$r"
78 exit 1
82 check_at_least() {
83 # This function is expected to be used in 'if' so we can't rely on set -e
84 # being in effect here.
85 v1=$1
86 v2=$2
87 save_IFS=$IFS
88 IFS=.
89 set x $v1
90 for v in $v2 ; do
91 shift
92 if [ "$1" != "$v" ] ; then
93 if [ -z "$1" ] || [ "$1" -lt "$v" ] ; then
94 IFS=$save_IFS
95 return 1
97 break
99 done
100 IFS=$save_IFS
101 return 0
104 lazy_build() {
105 # This function is expected to be used in 'if' so we can't rely on set -e
106 # being in effect here.
107 package=$1
108 binary=$2
109 version=$3
111 case $download_tools in
112 always) ;;
113 never)
114 return 1
117 if [ -n $binary ] ; then
118 if [ -s "../patches/$package/series" ] ; then
119 echo "There are patches to apply to $package so it has to be built"
120 else
121 # Check if a new enough version is already installed.
122 version_installed=`"$binary" --version 2>/dev/null|sed '1,1 s/.* //p;d'`
123 if [ -n "$version_installed" ] ; then
124 # Fast track equality.
125 if [ "$version_installed" = "$version" ] ; then
126 echo "$binary $version_installed installed, exactly what's needed"
127 return 1
129 if check_at_least "$version_installed" "$version" ; then
130 echo "$binary $version_installed installed >= $version required"
131 return 1
137 esac
139 basename=$package-$version
140 ext=$4
141 checksum=$5
143 if [ "$ext" = "tar.xz" ] ; then
144 if [ -z "$xz_ok" ] ; then
145 if ${XZ-xz} --version > /dev/null 2>&1 ; then
146 xz_ok=1
147 else
148 xz_ok=0
151 if [ "$xz_ok" = 0 ] ; then
152 shift 2
153 ext=$4
154 checksum=$5
157 if [ "$ext" = "tar.bz2" ] ; then
158 if [ -z "$bz2_ok" ] ; then
159 # bzip2 --version doesn't exit with code 0 in upstream version (though
160 # Debian at least patch this bug), so use --help to check it.
161 if bzip2 --help > /dev/null 2>&1 ; then
162 bz2_ok=1
163 else
164 bz2_ok=0
167 if [ "$bz2_ok" = 0 ] ; then
168 shift 2
169 ext=$4
170 checksum=$5
173 tarball=$basename.$ext
174 case $basename in
175 *[24680][a-z]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
176 esac
178 # Create the stamp file in INST so that rerunning bootstrap after
179 # "rm -rf INST" recovers nicely.
180 stamp=../INST/$package.stamp
182 # Download the tarball if required.
183 if [ ! -f "$tarball" ] ; then
184 if [ -z "$FETCH_URL_TOOL" ] ; then
185 if ${WGET-wget} --version > /dev/null 2>&1 ; then
186 FETCH_URL_TOOL="${WGET-wget} -O-"
187 elif ${CURL-curl} --version > /dev/null 2>&1 || [ "$?" = 2 ] ; then
188 # curl --version exits with code 2 (~7.18.2) or 0 (7.35.0).
189 # -L is needed to follow HTTP redirects.
190 FETCH_URL_TOOL="${CURL-curl} -L"
191 elif ${LWP_REQUEST-lwp-request} -v > /dev/null 2>&1 || [ "$?" = 9 -o "$?" = 255 ] ; then
192 # lwp-request -v exits with code 9 (5.810) or 255 (6.03)
193 FETCH_URL_TOOL="${LWP_REQUEST-lwp-request} -mGET"
194 else
195 cat <<END >&2
196 Neither wget nor curl nor lwp-request found - install one of them or if already
197 installed, set WGET, CURL or LWP_REQUEST to the full path. Alternatively,
198 download $url
199 to directory `pwd`
200 then rerun this script.
202 exit 1
205 url="https://github.com/xapian/xapian-dev-deps/releases/download/current/$tarball"
206 case $basename in
207 file-*)
208 case $download_protocol in
209 ftp) url="ftp://ftp.astron.com/pub/file/$tarball" ;;
210 # We used to use http://fossies.org/ but that now redirects to https.
211 esac ;;
212 *[13579][a-z])
213 # GNU alpha release
214 case $download_protocol in
215 ftp) url="ftp://alpha.gnu.org/gnu/$package/$tarball" ;;
216 http) url="http://alpha.gnu.org/gnu/$package/$tarball" ;;
217 esac ;;
219 case $download_protocol in
220 ftp) url="ftp://ftp.gnu.org/gnu/$package/$tarball" ;;
221 http) url="http://ftpmirror.gnu.org/$package/$tarball" ;;
222 esac ;;
223 esac
224 case $download_protocol,$url in
225 http,https:*)
226 echo "warning: No http: link for $tarball available, using https:"
228 esac
229 rm -f download.tmp
230 echo "Downloading <$url>"
231 $FETCH_URL_TOOL "$url" > download.tmp || exit $?
232 mv download.tmp "$tarball"
235 if [ -f "$stamp" ] ; then
236 find_stdout=`find "$tarball" ../patches/"$package"/* -newer "$stamp" -print 2> /dev/null||true`
237 else
238 find_stdout=force
241 if [ -n "$find_stdout" ] ; then
242 # Verify the tarball's checksum before building it.
243 check_checksum "$checksum" "$tarball"
245 # Remove tarballs of other versions.
246 for f in "$package"-* ; do
247 [ "$f" = "$tarball" ] || rm -rf "$f"
248 done
250 case $ext in
251 tar.xz)
252 ${XZ-xz} -dc "$tarball"| tar xf - || exit $? ;;
253 tar.bz2)
254 bzip2 -dc "$tarball"| tar xf - || exit $? ;;
256 gzip -dc "$tarball"| tar xf - || exit $? ;;
257 esac
259 cd "$basename" || exit $?
261 series="../../patches/$package/series"
262 if [ ! -f "$series" ] ; then
263 cat <<END >&2
264 No patch series file 'patches/$package/series' - if there are no patches,
265 this should just be an empty file.
267 exit 1
269 if [ -s "$series" ] ; then
270 echo "Applying patches from $package/series"
271 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" | \
272 while read p ; do
273 echo "Applying patch $package/$p"
274 patch -p1 < "../../patches/$package/$p" || exit $?
275 done
278 echo "Configuring $package"
279 if test -n "$AUTOCONF" ; then
280 ./configure --prefix "$instdir" AUTOCONF="$AUTOCONF" || exit $?
281 else
282 ./configure --prefix "$instdir" || exit $?
284 echo "Building $package"
285 make || exit $?
286 echo "Installing $package"
287 make install || exit $?
288 echo "Done installing $package"
289 cd .. || exit $?
290 rm -rf "$basename" || exit $?
292 touch "$stamp" || exit $?
294 return 0
297 handle_git_external() {
298 path=$1
299 if [ ! -f "$path/.nobootstrap" ] ; then
300 rev=$2
301 url=$3
302 if [ ! -d "$path" ] ; then
303 git clone --no-checkout -- "$url" "$path"
304 elif (cd "$path" && git reflog "$rev" -- 2>/dev/null) ; then
305 : # Already have that revision locally
306 else
307 (cd "$path" && git fetch)
309 (cd "$path" && git checkout "$rev")
313 update_config() {
314 from=$1
315 to=$2
316 ts_from=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$from"`
317 ts_to=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$to"`
318 if [ "$ts_from" -gt "$ts_to" ] ; then
319 echo "Updating $to ($ts_to) with $from ($ts_from)"
320 # rm first in case the existing file is a symlink.
321 rm -f "$to"
322 cp "$from" "$to"
326 update_bootstrap_sticky_opts() {
327 arg=$1
328 case $arg in
329 *[^-A-Za-z0-9_+=:@/.,]*)
330 # Quote for the shell and escape $ to $$ for make.
331 bootstrap_sticky_opts="$bootstrap_sticky_opts '"`echo "$arg"|sed "s/'/'\\\\\\''/g;"'s/[$]/\\\\$\\\\$/g'`"'"
334 bootstrap_sticky_opts="$bootstrap_sticky_opts $arg"
336 esac
339 curdir=`pwd`
341 # cd to srcdir if we aren't already there.
342 srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
343 case $srcdir in
344 ""|.)
345 srcdir=. ;;
347 cd "$srcdir" ;;
348 esac
350 # Commit hash to pass to handle_git_external for swig.
351 swig_git_commit_hash=2c910e47ae788412b95e356c99cef5862808bf9a
353 # Commit hashes to use for common in omega and letor respectively:
354 omega_common_commit_hash=b310f9988f63cdc15b48323f9ac42f6b08c3a36c
355 letor_common_commit_hash=b310f9988f63cdc15b48323f9ac42f6b08c3a36c
357 if [ ! -d .git ] ; then
358 echo "$0: No '.git' directory found - this script should be run from a"
359 echo "git repo cloned from git://git.xapian.org/xapian or a mirror of it"
360 exit 1
363 for emptydir in xapian-applications/omega/m4 xapian-bindings/m4 xapian-letor/m4 ; do
364 if test -d "$emptydir" ; then
366 else
367 parent=`echo "$emptydir"|sed 's,/[^/]*$,,'`
368 if test -d "$parent" ; then
369 mkdir "$emptydir"
372 done
374 if [ -f .git/info/exclude ] ; then
375 sed '/^\(swig\|xapian-applications\/omega\/common$\)/d' .git/info/exclude > .git/info/exclude~
376 else
377 [ -d .git/info ] || mkdir .git/info
379 cat <<END >> .git/info/exclude~
380 swig
381 xapian-applications/omega/common
382 xapian-letor/common
384 if [ -f .git/info/exclude ] &&
385 cmp -s .git/info/exclude~ .git/info/exclude ; then
386 rm .git/info/exclude~
387 else
388 mv .git/info/exclude~ .git/info/exclude
391 # If this tree is checked out from the github mirror, use the same access
392 # method for other things checked out from github (e.g. swig) so we avoid
393 # firewall issues. If there's no default remote, the git config command
394 # will exit with status 1, so ignore that failure.
395 origin_url=`git config remote.origin.url||:`
396 case $origin_url in
397 *[@/]github.com[:/]*)
398 github_base_url=`echo "X$origin_url"|sed 's/^X//;s!\([@/]github.com[:/]\).*!\1!'` ;;
400 github_base_url=https://github.com/ ;;
401 esac
402 swig_origin_url=${github_base_url}swig/swig.git
404 if [ -z "$XAPIAN_COMMON_CLONE_URL" ] ; then
405 xapian_common_clone_url=.
406 else
407 xapian_common_clone_url=$XAPIAN_COMMON_CLONE_URL
410 # Set to 'ftp' to use ftp URLs where available and 'http' to use unencrypted
411 # 'http'. By default we prefer https downloads as they are more likely to work
412 # through firewalls and better preserve user privacy.
413 download_protocol=
415 # Set to 'always' to always use a locally installed copy of the autotools
416 # or 'never' to never download.
418 # By default we check for locally installed versions and use them if they are
419 # new enough versions. But e.g. for building releases we want to use a known
420 # set of versions.
421 download_tools=ifneeded
423 # Save options which should be sticky for when "make" needs to rerun bootstrap.
424 # This should be empty or start with a space.
425 bootstrap_sticky_opts=
427 while [ "$#" -gt 0 ] ; do
428 case $1 in
429 --download-tools=*)
430 update_bootstrap_sticky_opts "$1"
431 download_tools=`echo "x$1"|sed 's/^x--download-tools=//'`
432 shift
433 continue
436 --download-tools)
437 update_bootstrap_sticky_opts "$1=$2"
438 download_tools=$2
439 shift 2
440 continue
443 --ftp)
444 bootstrap_sticky_opts="$bootstrap_sticky_opts $1"
445 download_protocol=ftp
446 shift
447 continue
450 --http)
451 bootstrap_sticky_opts="$bootstrap_sticky_opts $1"
452 download_protocol=http
453 shift
454 continue
457 --fetch-url-command=*)
458 update_bootstrap_sticky_opts "$1"
459 FETCH_URL_TOOL=`echo "x$1"|sed 's/^x--fetch-url-command=//'`
460 shift
461 continue
464 --fetch-url-command)
465 update_bootstrap_sticky_opts "$1=$2"
466 FETCH_URL_TOOL=$2
467 shift 2
468 continue
471 --clean)
472 # This probably shouldn't be sticky.
473 rm -rf INST
474 shift
475 continue
478 --without-autotools)
479 # This shouldn't be sticky.
480 echo "warning: Ignoring old option '$1' - new default is to use installed versions of tools if new enough. Use '--download-tools=never' to prevent ever downloading"
481 shift
482 continue
486 bootstrap_sticky_opts="$bootstrap_sticky_opts $1"
487 shift
488 break
492 echo "Unknown option '$1'" 1>&2
493 exit 1
497 break
499 esac
500 done
502 if [ "$#" -gt 0 ] ; then
503 for a in "$@" ; do
504 update_bootstrap_sticky_opts "$a"
505 done
508 case $download_tools in
509 always|ifneeded) ;;
510 never)
511 echo "warning: If stuff breaks with '--download-tools=never', you get to keep the pieces"
514 echo "Invalid --download-tools value '$download_tools'"
515 exit 1
517 esac
519 [ -d INST ] || mkdir INST
520 instdir=`pwd`/INST
522 [ -d BUILD ] || mkdir BUILD
523 cd BUILD
525 # The hex strings are SHA256 checksums for the preceding extension.
526 if lazy_build autoconf autoconf 2.69 \
527 tar.xz 64ebcec9f8ac5b2487125a86a7760d2591ac9e1d3dbd59489633f9de62a57684 \
528 tar.gz 954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969 \
529 ; then
530 AUTOCONF=$instdir/bin/autoconf
531 export AUTOCONF
532 AUTORECONF=$instdir/bin/autoreconf
533 export AUTORECONF
534 AUTOHEADER=$instdir/bin/autoheader
535 export AUTOHEADER
536 AUTOM4TE=$instdir/bin/autom4te
537 export AUTOM4TE
539 if lazy_build automake automake 1.16.1 \
540 tar.xz 5d05bb38a23fd3312b10aea93840feec685bdf4a41146e78882848165d3ae921 \
541 tar.gz 608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8 \
542 ; then
543 ACLOCAL=$instdir/bin/aclocal
544 export ACLOCAL
545 AUTOMAKE=$instdir/bin/automake
546 export AUTOMAKE
548 if lazy_build libtool libtool 2.4.6 \
549 tar.xz 7c87a8c2c8c0fc9cd5019e402bed4292462d00a718a7cd5f11218153bf28b26f \
550 tar.gz e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3 \
551 ; then
552 LIBTOOLIZE=$instdir/bin/libtoolize
553 export LIBTOOLIZE
554 libtool_aclocal=$instdir/share/aclocal
555 else
556 libtool_aclocal=`which libtool|sed 's!/bin/[^/]*$!/share/aclocal!'`
558 # If the aclocal we're using is in a different prefix to the libtool we're
559 # using, we probably need to tell aclocal where to look for our libtool's
560 # macros. Our directory may already by specified by other means, but it's
561 # fairly harmless to specify an explicit -I for a directory which is searched
562 # anyway - at worst it changes the search order.
563 if [ "`${ACLOCAL-aclocal} --print-ac-dir`" != "$libtool_aclocal" ] ; then
564 ACLOCAL="${ACLOCAL-aclocal} -I $libtool_aclocal"
565 export ACLOCAL
568 if [ "$1" = "--deps=libmagic" ] ; then
569 shift
570 lazy_build file '' 5.32 \
571 tar.gz 8639dc4d1b21e232285cd483604afc4a6ee810710e00e579dbe9591681722b50
574 cd ..
576 case `${LIBTOOLIZE-libtoolize} --version` in
578 echo "${LIBTOOLIZE-libtoolize} not found"
579 exit 1 ;;
580 "libtoolize (GNU libtool) 1.4.*")
581 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
582 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
583 exit 1 ;;
584 "libtoolize (GNU libtool) 1.5.*")
585 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
586 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
587 exit 1 ;;
588 esac
590 ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
591 export ACLOCAL
593 intree_swig=no
594 modules=
595 for module in ${@:-xapian-core xapian-applications/omega swig xapian-bindings} ; do
596 d=$module
597 if [ "$d" = swig ] ; then
598 if [ -f "xapian-bindings/.nobootstrap" ] ; then
599 # No point bootstrapping SWIG if we aren't going to use it.
600 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
601 continue
603 handle_git_external swig "$swig_git_commit_hash" "$swig_origin_url"
605 if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
607 else
608 # Skip any directories we can't bootstrap.
609 continue
611 if [ -f "$d/.nobootstrap" ] ; then
612 # Report why to save head scratching when someone forgets they created
613 # a .nobootstrap file.
614 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
615 continue
617 case $d in
618 xapian-applications/omega|xapian-letor)
619 # If someone's created a directory for common, leave it be.
620 if [ -h "$d/common" ] || [ ! -d "$d/common" ] ; then
621 # Pick omega_common_commit_hash or letor_common_commit_hash:
622 var=`echo "$d"|sed 's!.*[-/]!!g'`_common_commit_hash
623 hash=`eval echo \\\$"$var"`
624 handle_git_external "$d/.common.git" "$hash" "$xapian_common_clone_url"
625 ln -sf .common.git/xapian-core/common "$d/common"
628 esac
630 echo "Bootstrapping \`$module'"
631 [ -f "$d/preautoreconf" ] && "$d/preautoreconf"
633 # If we have a custom INSTALL file, preserve it since autoreconf insists on
634 # replacing INSTALL with "generic installation instructions" when --force
635 # is used. Be careful to replace it if autoreconf fails.
636 if [ -f "$d/INSTALL" ] ; then
637 if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
639 else
640 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
644 autoreconf_rc=
645 if [ swig = "$module" ] ; then
646 # SWIG provides its own bootstrapping script.
647 curdir=`pwd`
648 cd "$d"
649 ./autogen.sh || autoreconf_rc=$?
650 cd "$curdir"
651 # Use the uninstalled wrapper for the in-tree copy of SWIG.
652 intree_swig=yes
653 else
654 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
655 # (but it doesn't check for -i).
657 # Use --force so that we update files if autoconf, automake, or libtool
658 # has been upgraded.
659 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
661 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
662 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
664 if [ -n "$autoreconf_rc" ] ; then
665 exit $autoreconf_rc
667 for f in config.guess config.sub ; do
668 if [ -f "$d/$f" ] ; then
669 update_config "config/$f" "$d/$f"
671 done
672 modules="$modules $module"
673 done
675 # Produce an absolute path to srcdir.
676 srcdir_abs=`pwd`
678 # Generate the top-level configure script.
679 rm -f configure.tmp
680 cat <<TOP_OF_CONFIGURE > configure.tmp
681 #!/bin/sh
682 # configure each submodule in a xapian source tree
683 # Generated by Xapian top-level bootstrap script.
684 #$copyright
685 trap 'echo "configure failed"' EXIT
686 set -e
688 srcdir="$srcdir_abs"
689 modules="$modules"
691 TOP_OF_CONFIGURE
693 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
694 # Produced escaped version of command suitable for pasting back into sh
695 cmd=$0
696 for a ; do
697 case $a in
698 *[^-A-Za-z0-9_+=:@/.,]*)
699 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
700 cmd="$cmd $esc_a" ;;
702 cmd="$cmd $a" ;;
703 esac
704 done
706 here=`pwd`
707 MIDDLE_OF_CONFIGURE
709 vars=
710 if [ yes = "$intree_swig" ] ; then
711 # We want the path to SWIG to point into srcdir, which isn't known until
712 # configure-time, so we need to expand $here in configure.
713 vars=' SWIG=$here/swig/preinst-swig'
714 elif [ -n "$SWIG" ] ; then
715 # User specified SWIG in environment, e.g. with:
716 # SWIG=/opt/swig/bin/swig ./bootstrap
717 vars=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
719 for tool in $autotools ; do
720 eval "val=\$$tool"
721 if [ -n "$val" ] ; then
722 echo ': ${'"$tool='$val'"'}' >> configure.tmp
723 echo "export $tool" >> configure.tmp
724 vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
726 done
727 if [ -n "$vars" ] ; then
728 # $vars will always have a leading space.
729 echo "set$vars "'"$@"' >> configure.tmp
732 cat <<'END_OF_CONFIGURE' >> configure.tmp
733 dirs=
734 revdirs=
735 XAPIAN_CONFIG=$here/xapian-core/xapian-config
736 for d in $modules ; do
737 if [ "$here" = "$srcdir" ] ; then
738 configure=./configure
739 configure_from_here=$d/configure
740 else
741 configure=$srcdir/$d/configure
742 configure_from_here=$configure
744 if [ -f "$configure_from_here" ] ; then
745 if [ -d "$d" ] ; then : ; else
746 case $d in
747 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
748 esac
749 mkdir "$d"
751 echo "Configuring \`$d'"
752 # Use a shared config.cache for speed and to save a bit of diskspace, but
753 # don't share it with SWIG just in case it manages to probe and cache
754 # different answers (e.g. because it uses a C compiler).
755 case $d in
756 swig)
757 case "$*" in
758 *--host=*|*--host" "*)
759 # We're cross-building, but SWIG needs to be built natively.
760 swig_configure_args=
761 skip=
762 for arg in "$@" ; do
763 if [ -n "$skip" ] ; then
764 skip=
765 continue
767 case $arg in
768 --host=*)
769 # Drop --host=xxx
770 continue ;;
771 --host)
772 # Drop --host xxx
773 skip=1
774 continue ;;
775 CC=*|CXX=*)
776 # Drop CC=xxx or CXX=xxx
777 continue ;;
778 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
779 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
780 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
782 SWIG=*)
783 # Drop SWIG=xxx - not useful and could cause problems.
784 continue ;;
785 esac
786 swig_configure_args="$swig_configure_args "\'`echo "x$arg"|sed "s/^x//;s/'/'\\\\\\\\''/g"`\'
787 done
788 # Also handle compilers specified in environment variables. We can
789 # just reassign them unconditionally as CC and CXX are ignored if
790 # empty.
791 cd "$d" && CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD "$configure" `eval echo $swig_configure_args`
794 cd "$d" && "$configure" ${1+"$@"}
796 esac
798 xapian-core)
799 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
801 xapian-applications/omega)
802 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include" LDFLAGS="-L$srcdir/INST/lib" ${1+"$@"}
805 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
807 esac
808 cd "$here"
809 dirs="$dirs $d"
810 revdirs="$d $revdirs"
812 done
814 case " $* " in
815 *" --help "*|*" --version "*)
816 # Don't generate Makefile if --help or --version specified.
817 trap - EXIT
818 exit 0
820 esac
822 rm -f Makefile.tmp
823 cat <<EOF > Makefile.tmp
824 # Makefile generated by:
825 CONFIGURE_COMMAND := $cmd
827 if [ "$srcdir" != . ] ; then
828 cat <<EOF >> Makefile.tmp
830 VPATH = $srcdir
833 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
834 for target in $targets ; do
835 echo
836 echo "$target:"
837 case $target in
838 uninstall|*clean)
839 # When uninstalling or cleaning, process directories in reverse order, so
840 # that we process a directory after any directories which might use it.
841 list=$revdirs ;;
843 list=$dirs ;;
844 esac
845 for d in $list ; do
846 case $d,$target in
847 swig,install*|swig,uninstall)
848 # Nothing to do with swig when installing/uninstalling.
850 swig,dist|swig,check|swig,distcheck|swig,all)
851 # Need to ensure swig is built before "make dist", "make check", etc.
852 echo " cd $d && \$(MAKE)" ;;
853 swig,mostlyclean)
854 echo " cd $d && \$(MAKE) clean" ;;
855 xapian-bindings,distcheck)
856 # FIXME: distcheck doesn't currently work for xapian-bindings because
857 # xapian-core isn't installed.
858 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
860 echo " cd $d && \$(MAKE) $target" ;;
861 esac
862 done
863 case $target in
864 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
865 esac
866 done >> Makefile.tmp
867 cat <<EOF >> Makefile.tmp
869 recheck:
870 \$(CONFIGURE_COMMAND)
872 Makefile: $srcdir/configure
873 \$(CONFIGURE_COMMAND)
875 $srcdir/configure: \\
876 END_OF_CONFIGURE
878 : > configure.tmp2
880 # We want to rerun bootstrap if a series file changes (patch added or removed)
881 # or an existing patch changes. Since we always have an series file (even if
882 # it is empty), this also handles us adding the first patch for something.
883 patches=
884 for d in patches/* ; do
885 series=$d/series
886 echo "$series:" >> configure.tmp2
887 cat << END
888 $series\\\\
890 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
891 while read p ; do
892 patch=$d/$p
893 cat << END
894 $patch\\\\
896 # Because there's a pipeline, this is a subshell, so use a temporary file
897 # rather than a variable to compile a list of patches to use below.
898 echo "$patch:" >> configure.tmp2
899 done
900 done >> configure.tmp
902 cat <<'END_OF_CONFIGURE' >> configure.tmp
903 $srcdir/bootstrap
904 END_OF_CONFIGURE
905 echo " \$srcdir/bootstrap$bootstrap_sticky_opts" >> configure.tmp
906 cat <<'END_OF_CONFIGURE' >> configure.tmp
908 .PHONY: $targets recheck
910 # Dummy dependencies to allow removing patches we no longer need.
911 END_OF_CONFIGURE
913 cat configure.tmp2 >> configure.tmp
915 cat <<'END_OF_CONFIGURE' >> configure.tmp
917 mv -f Makefile.tmp Makefile
918 trap - EXIT
919 echo "Configured successfully - now run \"${MAKE-make}\""
920 END_OF_CONFIGURE
922 rm -f configure.tmp2
924 chmod +x configure.tmp
925 mv -f configure.tmp configure
927 # git defaults to showing 7 character abbreviated hashes if that's enough to be
928 # unique for a particular commit. But you can't paste these into trac as it
929 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
930 # need 9 characters to be unique across all of Xapian at the time of writing,
931 # and 12 for the Linux kernel currently (a much larger number of objects than
932 # Xapian). 12 is a manageable length and decently future-proof, so let's use
933 # that.
934 core_abbrev_recommended=12
935 core_abbrev=`git config --get core.abbrev||:`
936 if [ -z "$core_abbrev" ] ; then
937 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
938 git config --local core.abbrev "$core_abbrev_recommended"
939 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
940 if [ -z "`git config --local core.abbrev`" ] ; then
941 # Set globally to < $core_abbrev_recommended, override in this repo.
942 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
943 git config --local core.abbrev "$core_abbrev_recommended"
944 else
945 # Just warn.
946 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
950 trap - EXIT
951 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""