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"
6 # Copyright (C) 2002-2022 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
24 if [ "$1" = "--help" ] ; then
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.
34 trap 'echo "Bootstrap failed"' EXIT
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.
48 if [ -z "$SHA256SUM_TOOL" ] ; then
49 for SHA256SUM_TOOL
in \
50 '${SHA256SUM-sha256sum} 2>/dev/null|cut -d\ -f1' \
51 '${SHASUM-shasum} -a256 2>/dev/null|cut -d\ -f1' \
52 '${OPENSSL-openssl} sha256 2>/dev/null|sed "s/.* //"' \
54 if [ -z "$SHA256SUM_TOOL" ] ; then
56 Need sha256sum or shasum or openssl installed to check SHA256 checksums.
57 Set environment variable SHA256SUM, SHASUM or OPENSSL if the tool isn't on
62 # Sanity check by hashing empty input.
63 r
=`:|eval "$SHA256SUM_TOOL"`
64 [ X
"$r" != Xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
] ||
break
67 r
=`< "$tarball_" eval "$SHA256SUM_TOOL"`
68 if [ X
"$r" != X
"$checksum_" ] ; then
69 echo "$tarball_: computed SHA256 checksum did NOT match"
70 echo "computed: $r with $SHA256SUM_TOOL"
71 echo "expected: $checksum_"
73 file "$tarball_" || true
74 mv "$tarball_" "$tarball_.$r"
75 echo "Renamed $tarball_ to $tarball_.$r"
81 # This function is expected to be used in 'if' so we can't rely on set -e
82 # being in effect here.
90 if [ "$1" != "$v" ] ; then
91 if [ -z "$1" ] ||
[ "$1" -lt "$v" ] ; then
103 # This function is expected to be used in 'if' so we can't rely on set -e
104 # being in effect here.
109 case $download_tools in
115 if [ -n "$binary" ] ; then
116 if [ -s "../patches/$package/series" ] ; then
117 echo "There are patches to apply to $package so using private build"
119 # Check if a new enough version is already installed.
120 version_installed
=`"$binary" --version 2>/dev/null|sed '1,1 s/.* //p;d'`
121 if [ -n "$version_installed" ] ; then
122 # Fast track equality.
123 if [ "$version_installed" = "$version" ] ; then
124 echo "$binary $version_installed installed, exactly what's needed"
127 if check_at_least
"$version_installed" "$version" ; then
128 echo "$binary $version_installed installed >= $version required"
142 basename=$package-$version
146 if [ "$ext" = "tar.xz" ] ; then
147 if [ -z "$xz_ok" ] ; then
148 if ${XZ-xz} --version > /dev
/null
2>&1 ; then
154 if [ "$xz_ok" = 0 ] ; then
160 if [ "$ext" = "tar.bz2" ] ; then
161 if [ -z "$bz2_ok" ] ; then
162 # bzip2 --version doesn't exit with code 0 in upstream version (though
163 # Debian at least patch this bug), so use --help to check it.
164 if bzip2 --help > /dev
/null
2>&1 ; then
170 if [ "$bz2_ok" = 0 ] ; then
176 tarball
=$basename.
$ext
178 *[24680][a-z
]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
181 # Create the stamp file in INST so that rerunning bootstrap after
182 # "rm -rf INST" recovers nicely.
183 stamp
=..
/INST
/$package.stamp
186 # Download the tarball if required.
187 if [ ! -f "$tarball" ] ; then
189 # Older git versions don't support "git worktree", so discard stderr and
190 # then we'll skip the worktree handling because main_worktree_dir will
192 main_worktree_dir
=`git worktree list --porcelain 2>/dev/null|sed 's/^worktree //;q'`
193 if [ -n "$main_worktree_dir" ] ; then
194 # Canonicalise main_worktree_dir before comparing with pwd.
195 main_worktree_dir
=`cd "$main_worktree_dir" && pwd`
196 if [ "$main_worktree_dir/BUILD" != "`pwd`" ] ; then
197 # If main_tarball is set non-empty, then we're a linked worktree.
198 main_tarball
=$main_worktree_dir/BUILD
/$tarball
201 if [ -n "$main_tarball" ] && [ -f "$main_tarball" ] ; then
202 # Don't re-download the tarball if the main worktree already has it.
203 tarball
=$main_tarball
205 if [ -z "$FETCH_URL_TOOL" ] ; then
206 if ${WGET-wget} --version > /dev
/null
2>&1 ; then
207 FETCH_URL_TOOL
="${WGET-wget} -O-"
208 elif ${CURL-curl} --version > /dev
/null
2>&1 ||
[ "$?" = 2 ] ; then
209 # curl --version exits with code 2 (~7.18.2) or 0 (7.35.0).
210 # -L is needed to follow HTTP redirects.
211 FETCH_URL_TOOL
="${CURL-curl} -L"
212 elif ${LWP_REQUEST-lwp-request} -v > /dev
/null
2>&1 ||
[ "$?" = 9 ] ||
[ "$?" = 255 ] ; then
213 # lwp-request -v exits with code 9 (5.810) or 255 (6.03)
214 FETCH_URL_TOOL
="${LWP_REQUEST-lwp-request} -mGET"
217 Neither wget nor curl nor lwp-request found - install one of them or if already
218 installed, set WGET, CURL or LWP_REQUEST to the full path. Alternatively,
221 then rerun this script.
226 url
="https://github.com/xapian/xapian-dev-deps/releases/download/current/$tarball"
229 case $download_protocol in
230 ftp) url
="ftp://ftp.astron.com/pub/file/$tarball" ;;
231 # We used to use http://fossies.org/ but that now redirects to https.
235 case $download_protocol in
236 ftp) url
="ftp://alpha.gnu.org/gnu/$package/$tarball" ;;
237 http
) url
="http://alpha.gnu.org/gnu/$package/$tarball" ;;
240 case $download_protocol in
241 ftp) url
="ftp://ftp.gnu.org/gnu/$package/$tarball" ;;
242 http
) url
="http://ftpmirror.gnu.org/$package/$tarball" ;;
245 case $download_protocol,$url in
247 echo "warning: No http: link for $tarball available, using https:"
251 # Keep the tarball under a quarantined name until we've verified its
252 # checksum. Once verified, if this is a linked git worktree we save
253 # the tarball in the main worktree's BUILD directory so that it can
254 # be shared with other worktrees.
255 if [ -n "$main_tarball" ] ; then
256 tarball
=$main_tarball
258 quarantined_tarball
=$tarball-quarantine.$$
259 rm -f "$quarantined_tarball"
260 echo "Downloading <$url>"
261 $FETCH_URL_TOOL "$url" > "$quarantined_tarball" ||
exit $?
262 check_checksum
"$checksum" "$quarantined_tarball"
263 mv "$quarantined_tarball" "$tarball"
270 if [ -z "$out_of_date" ] ; then
271 if [ -f "$stamp" ] ; then
272 # Check if the tarball or the patches we're applying have changed since
273 # the existing build.
274 out_of_date
=`find "$tarball" ../patches/"$package"/* -newer "$stamp" -print 2> /dev/null||true`
280 if [ -n "$out_of_date" ] ; then
281 # Verify the tarball's checksum before building it. We now check at
282 # download time, but older versions of bootstrap didn't, and this also
283 # protects a user who manually downloads a tarball (which we suggest as an
284 # option if wget, curl, etc aren't found).
285 check_checksum
"$checksum" "$tarball"
288 */*) ;; # Only expire tarballs from the main worktree.
290 case `git worktree list --porcelain 2>/dev/null|grep -c '^worktree '` in
292 # Remove tarballs of other versions if there's only one worktree, or if
293 # using git < 2.5 (before worktrees were added).
294 for f
in "$package"-* ; do
295 [ "$f" = "$tarball" ] ||
rm -rf "$f"
304 ${XZ-xz} -dc "$tarball"|
tar xf
- ||
exit $?
;;
306 bzip2 -dc "$tarball"|
tar xf
- ||
exit $?
;;
308 gzip -dc "$tarball"|
tar xf
- ||
exit $?
;;
311 cd "$basename" ||
exit $?
313 series
="../../patches/$package/series"
314 if [ ! -f "$series" ] ; then
316 No patch series file 'patches/$package/series' - if there are no patches,
317 this should just be an empty file.
321 if [ -s "$series" ] ; then
322 echo "Applying patches from $package/series"
323 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" | \
325 echo "Applying patch $package/$p"
326 patch -p1 < "../../patches/$package/$p" ||
exit $?
330 echo "Configuring $package"
331 if test -n "$AUTOCONF" ; then
332 .
/configure
--prefix "$instdir" AUTOCONF
="$AUTOCONF" ||
exit $?
334 .
/configure
--prefix "$instdir" ||
exit $?
336 echo "Building $package"
338 echo "Installing $package"
339 make install ||
exit $?
340 echo "Done installing $package"
342 rm -rf "$basename" ||
exit $?
344 touch "$stamp" ||
exit $?
349 handle_git_external
() {
351 if [ ! -f "$path/.nobootstrap" ] ; then
354 if [ ! -d "$path" ] ; then
355 git clone
--no-checkout -- "$url" "$path"
356 elif (cd "$path" && git reflog
"$rev" -- 2>/dev
/null
) ; then
357 : # Already have that revision locally
359 (cd "$path" && git fetch
)
361 (cd "$path" && git checkout
"$rev")
368 ts_from
=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$from"`
369 ts_to
=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$to"`
370 if [ "$ts_from" -gt "$ts_to" ] ; then
371 echo "Updating $to ($ts_to) with $from ($ts_from)"
372 # rm first in case the existing file is a symlink.
378 update_bootstrap_sticky_opts
() {
381 *[!-A-Za-z0-9_+=:@
/.
,]*)
382 # Quote for the shell and escape $ to $$ for make.
383 bootstrap_sticky_opts
="$bootstrap_sticky_opts '"`echo "$arg"|sed "s/'/'\\\\\\''/g;"'s/[$]/\\\\$\\\\$/g'`"'"
386 bootstrap_sticky_opts
="$bootstrap_sticky_opts $arg"
393 # cd to srcdir if we aren't already there.
394 srcdir
=`echo "$0"|sed 's!/*[^/]*$!!'`
402 # Commit hash to pass to handle_git_external for swig. Equivalent to
403 # SWIG 4.1.1 (we need at least SWIG 4.1.0 for Ruby 2.7 and PHP 8).
404 swig_git_commit_hash
=77323a0f07562b7d90d36181697a72a909b9519a
406 # Commit hash to use for common in omega:
407 omega_common_commit_hash
=86dbf97f160c2335c2be54dd782d9bea5df04420
409 gitdir
=`git rev-parse --git-dir`
411 if [ ! -d "$gitdir" ] ; then
412 echo "$0: No '.git' directory found - this script should be run from a"
413 echo "git repo cloned from git://git.xapian.org/xapian or a mirror of it"
417 for emptydir
in xapian-applications
/omega
/m4 xapian-bindings
/m4 ; do
418 if test -d "$emptydir" ; then
421 parent
=`echo "$emptydir"|sed 's,/[^/]*$,,'`
422 if test -d "$parent" ; then
428 if [ -f "$gitdir/info/exclude" ] ; then
429 sed '/^\(swig\|xapian-applications\/omega\/common$\)/d' "$gitdir/info/exclude" > "$gitdir/info/exclude~"
431 [ -d "$gitdir/info" ] || mkdir
"$gitdir/info"
433 cat <<END >> "$gitdir/info/exclude~"
435 xapian-applications/omega/common
437 if [ -f "$gitdir/info/exclude" ] &&
438 cmp -s "$gitdir/info/exclude~" "$gitdir/info/exclude" ; then
439 rm "$gitdir/info/exclude~"
441 mv "$gitdir/info/exclude~" "$gitdir/info/exclude"
444 # If this tree is checked out from the github mirror, use the same access
445 # method for other things checked out from github (e.g. swig) so we avoid
446 # firewall issues. If there's no default remote, the git config command
447 # will exit with status 1, so ignore that failure.
448 origin_url
=`git config remote.origin.url||:`
450 *[@
/]github.com
[:/]*)
451 github_base_url
=`echo "X$origin_url"|sed 's/^X//;s!\([@/]github.com[:/]\).*!\1!'` ;;
453 github_base_url
=https
://github.com
/ ;;
455 swig_origin_url
=${github_base_url}swig
/swig.git
457 if [ -z "$XAPIAN_COMMON_CLONE_URL" ] ; then
458 xapian_common_clone_url
=.
460 xapian_common_clone_url
=$XAPIAN_COMMON_CLONE_URL
463 # Set to 'ftp' to use ftp URLs where available and 'http' to use unencrypted
464 # 'http'. By default we prefer https downloads as they are more likely to work
465 # through firewalls and better preserve user privacy.
468 # Set to 'always' to always use a locally installed copy of the autotools
469 # or 'never' to never download.
471 # By default we check for locally installed versions and use them if they are
472 # new enough versions. But e.g. for building releases we want to use a known
474 download_tools
=ifneeded
476 # Save options which should be sticky for when "make" needs to rerun bootstrap.
477 # This should be empty or start with a space.
478 bootstrap_sticky_opts
=
480 while [ "$#" -gt 0 ] ; do
483 update_bootstrap_sticky_opts
"$1"
484 download_tools
=`echo "x$1"|sed 's/^x--download-tools=//'`
490 update_bootstrap_sticky_opts
"$1=$2"
497 bootstrap_sticky_opts
="$bootstrap_sticky_opts $1"
498 download_protocol
=ftp
504 bootstrap_sticky_opts
="$bootstrap_sticky_opts $1"
505 download_protocol
=http
510 --fetch-url-command=*)
511 update_bootstrap_sticky_opts
"$1"
512 FETCH_URL_TOOL
=`echo "x$1"|sed 's/^x--fetch-url-command=//'`
518 update_bootstrap_sticky_opts
"$1=$2"
525 # This probably shouldn't be sticky.
532 # This shouldn't be sticky.
533 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"
539 bootstrap_sticky_opts
="$bootstrap_sticky_opts $1"
545 echo "Unknown option '$1'" 1>&2
555 if [ "$#" -gt 0 ] ; then
557 update_bootstrap_sticky_opts
"$a"
561 case $download_tools in
564 echo "warning: If stuff breaks with '--download-tools=never', you get to keep the pieces"
567 echo "Invalid --download-tools value '$download_tools'"
572 [ -d INST
] || mkdir INST
575 [ -d BUILD
] || mkdir BUILD
578 # The hex strings are SHA256 checksums for the preceding extension.
580 if need_to_build
$args autoconf
; then
582 tar.xz f14c83cfebcc9427f2c3cea7258bd90df972d92eb26752da4ddad81c87a0faa4 \
583 tar.gz
431075ad0bf529ef13cb41e9042c542381103e80015686222b8a9d4abef42a1c
584 AUTOCONF
=$instdir/bin
/autoconf
586 AUTORECONF
=$instdir/bin
/autoreconf
588 AUTOHEADER
=$instdir/bin
/autoheader
590 AUTOM4TE
=$instdir/bin
/autom4te
593 args
='automake 1.16.5'
594 if need_to_build
$args automake
; then
596 tar.xz f01d58cd6d9d77fbdca9eb4bbd5ead1988228fdb73d6f7a201f5f8d6b118b469 \
597 tar.gz
07bd24ad08a64bc17250ce09ec56e921d6343903943e99ccf63bbf0705e34605
598 ACLOCAL
=$instdir/bin
/aclocal
600 AUTOMAKE
=$instdir/bin
/automake
604 if need_to_build
$args libtool
; then
606 tar.xz
7c87a8c2c8c0fc9cd5019e402bed4292462d00a718a7cd5f11218153bf28b26f \
607 tar.gz e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3
608 LIBTOOLIZE
=$instdir/bin
/libtoolize
610 libtool_aclocal
=$instdir/share
/aclocal
612 libtool_aclocal
=`which libtoolize|sed 's!/bin/[^/]*$!/share/aclocal!'`
613 if [ -z "$libtool_aclocal" ] ; then
614 echo "libtoolize not found"
619 if [ "$1" = "--deps=libmagic" ] ; then
621 lazy_build
file 5.3.2 \
622 tar.gz
8639dc4d1b21e232285cd483604afc4a6ee810710e00e579dbe9591681722b50
625 # Save the unadorned aclocal for bootstrapping SWIG. In particular SWIG
626 # uses a modified old version of AX_CXX_COMPILE_STDCXX_11 which isn't
627 # compatible with the current version which might be in a system directory.
628 SWIG_ACLOCAL
=${ACLOCAL-aclocal}
632 # Add -I for in-tree macro directory first, so we use that xapian.m4 in
633 # preference to one in any directories which may be added below.
634 ACLOCAL
="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
637 aclocal_ac_dir
=`${ACLOCAL-aclocal} --print-ac-dir`
638 aclocal_system_needed
=
639 if [ ! -r "$aclocal_ac_dir/pkg.m4" ] ; then
640 if [ -r /usr
/share
/aclocal
/pkg.
m4 ] ; then
641 aclocal_system_needed
=/usr
/share
/aclocal
642 elif [ -r /usr
/local
/share
/aclocal
/pkg.
m4 ] ; then
643 aclocal_system_needed
=/usr
/local
/share
/aclocal
644 elif [ -r /opt
/local
/share
/aclocal
/pkg.
m4 ] ; then
645 aclocal_system_needed
=/opt
/local
/share
/aclocal
649 # If the aclocal we're using is in a different prefix to the libtool we're
650 # using, we probably need to tell aclocal where to look for our libtool's
651 # macros. We also need to do this if we add -I /usr/share/aclocal below
652 # since otherwise the system libtool's macros may be used in preference.
653 if [ "$aclocal_ac_dir" != "$libtool_aclocal" ] ||
[ -n "$aclocal_system_needed" ]; then
654 ACLOCAL
="${ACLOCAL-aclocal} -I $libtool_aclocal"
658 # If we're using a non-system automake, check if pkg.m4 is in the directory
659 # aclocal looks in by default. If not and there's a system pkg.m4, tell
660 # aclocal to also look in the system aclocal directory.
661 if [ -n "$aclocal_system_needed" ] ; then
662 ACLOCAL
="${ACLOCAL-aclocal} -I $aclocal_system_needed"
666 case `${LIBTOOLIZE-libtoolize} --version` in
668 echo "${LIBTOOLIZE-libtoolize} not found"
670 "libtoolize (GNU libtool) 1.4.*")
671 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
672 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
674 "libtoolize (GNU libtool) 1.5.*")
675 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
676 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
682 for module
in ${@:-xapian-core xapian-applications/omega swig xapian-bindings} ; do
684 if [ "$d" = swig
] ; then
685 if [ -f "xapian-bindings/.nobootstrap" ] ; then
686 # No point bootstrapping SWIG if we aren't going to use it.
687 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
690 handle_git_external swig
"$swig_git_commit_hash" "$swig_origin_url"
692 if [ -f "$d/configure.ac" ] ||
[ -f "$d/configure.in" ] ; then
695 # Skip any directories we can't bootstrap.
698 if [ -f "$d/.nobootstrap" ] ; then
699 # Report why to save head scratching when someone forgets they created
700 # a .nobootstrap file.
701 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
705 xapian-applications
/omega
)
706 # If someone's created a directory for common, leave it be.
707 if [ -h "$d/common" ] ||
[ ! -d "$d/common" ] ; then
708 hash=$omega_common_commit_hash
709 if [ -f "$gitdir/shallow" ] ; then
710 if git reflog
"$hash" -- 2> /dev
/null
; then
711 : # Already have the desired commit.
713 git fetch
--unshallow
716 handle_git_external
"$d/.common.git" "$hash" "$xapian_common_clone_url"
717 ln -sf .common.git
/xapian-core
/common
"$d/common"
722 echo "Bootstrapping \`$module'"
723 [ -f "$d/preautoreconf" ] && perl
"$d/preautoreconf"
725 # If we have a custom INSTALL file, preserve it since autoreconf insists on
726 # replacing INSTALL with "generic installation instructions" when --force
727 # is used. Be careful to replace it if autoreconf fails.
728 if [ -f "$d/INSTALL" ] ; then
729 if grep 'generic installation instructions' "$d/INSTALL" >/dev
/null
2>&1 ; then
732 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
737 if [ swig
= "$module" ] ; then
738 # SWIG provides its own bootstrapping script.
741 ACLOCAL
=$SWIG_ACLOCAL .
/autogen.sh || autoreconf_rc
=$?
743 # Use the uninstalled wrapper for the in-tree copy of SWIG.
746 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
747 # (but it doesn't check for -i).
749 # Use --force so that we update files if autoconf, automake, or libtool
751 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc
=$?
753 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
754 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
756 if [ -n "$autoreconf_rc" ] ; then
759 for f
in config.guess config.sub
; do
760 if [ -f "$d/$f" ] ; then
761 update_config
"config/$f" "$d/$f"
764 modules
="$modules $module"
767 # Produce an absolute path to srcdir.
770 # Generate the top-level configure script.
772 cat <<TOP_OF_CONFIGURE > configure.tmp
774 # configure each submodule in a xapian source tree
775 # Generated by Xapian top-level bootstrap script.
777 trap 'echo "configure failed"' EXIT
785 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
786 # Produced escaped version of command suitable for pasting back into sh
788 user_CPPFLAGS=$CPPFLAGS
789 user_LDFLAGS=$LDFLAGS
792 *[^-A-Za-z0-9_+=:@/.,]*)
793 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
798 # Capture any command-line settings of CPPFLAGS or LDFLAGS so we can override
799 # for omega. We follow the behaviour of autoconf-generated configure scripts
800 # in that command-line setting beats environment variable setting, and the
801 # last of multiple command-line settings is used.
804 user_CPPFLAGS=`expr "x$a" : 'xCPPFLAGS=\(.*\)'` ;;
806 user_LDFLAGS=`expr "x$a" : 'xLDFLAGS=\(.*\)'` ;;
814 if [ yes = "$intree_swig" ] ; then
815 # We want the path to SWIG to point into srcdir, which isn't known until
816 # configure-time, so we need to expand $here in configure.
817 vars
=' SWIG=$here/swig/preinst-swig'
818 elif [ -n "$SWIG" ] ; then
819 # User specified SWIG in environment, e.g. with:
820 # SWIG=/opt/swig/bin/swig ./bootstrap
821 vars
=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
823 for tool
in $autotools ; do
825 if [ -n "$val" ] ; then
826 echo ': ${'"$tool='$val'"'}' >> configure.tmp
827 echo "export $tool" >> configure.tmp
828 vars
="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
831 if [ -n "$vars" ] ; then
832 # $vars will always have a leading space.
833 echo "set$vars "'"$@"' >> configure.tmp
836 cat <<'END_OF_CONFIGURE' >> configure.tmp
839 XAPIAN_CONFIG=$here/xapian-core/xapian-config
840 for d in $modules ; do
841 if [ "$here" = "$srcdir" ] ; then
842 configure=./configure
843 configure_from_here=$d/configure
845 configure=$srcdir/$d/configure
846 configure_from_here=$configure
848 if [ -f "$configure_from_here" ] ; then
849 if [ -d "$d" ] ; then : ; else
851 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
855 echo "Configuring \`$d'"
856 # Replace EXIT trap with one which shows `config.log`.
857 trap 'if [ -f config.log ]; then echo "configure failed, config.log was:"; sed "s/^/| /" config.log; else echo "configure failed"; fi' EXIT
858 # Use a shared config.cache for speed and to save a bit of diskspace, but
859 # don't share it with SWIG just in case it manages to probe and cache
860 # different answers (e.g. because it uses a C compiler).
864 *--host=*|*--host" "*)
865 # We're cross-building, but SWIG needs to be built natively.
869 if [ -n "$skip" ] ; then
882 # Drop CC=xxx or CXX=xxx
884 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
885 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
886 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
889 # Drop SWIG=xxx - not useful and could cause problems.
892 swig_configure_args="$swig_configure_args "\'`printf '%s' "$arg"|sed "s/'/'\\\\\\\\''/g"`\'
894 # Also handle compilers specified in environment variables. We can
895 # just reassign them unconditionally as CC and CXX are ignored if
902 cd "$d" && eval "$configure" $swig_configure_args
906 cd "$d" && "$configure" ${1+"$@"}
911 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
913 xapian-applications/omega)
914 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include $user_CPPFLAGS" LDFLAGS="-L$srcdir/INST/lib $user_LDFLAGS" ${1+"$@"}
917 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
921 trap 'echo "configure failed"' EXIT
924 revdirs="$d $revdirs"
929 *" --help "*|*" --version "*)
930 # Don't generate Makefile if --help or --version specified.
937 cat <<EOF > Makefile.tmp
938 # Makefile generated by:
939 CONFIGURE_COMMAND := $cmd
941 if [ "$srcdir" != . ] ; then
942 cat <<EOF >> Makefile.tmp
947 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
948 for target in $targets ; do
953 # When uninstalling or cleaning, process directories in reverse order, so
954 # that we process a directory after any directories which might use it.
961 swig,install*|swig,uninstall)
962 # Nothing to do with swig when installing/uninstalling.
964 swig,dist|swig,check|swig,distcheck|swig,all)
965 # Need to ensure swig is built before "make dist", "make check", etc.
966 echo " cd $d && \$(MAKE)" ;;
968 echo " cd $d && \$(MAKE) clean" ;;
969 xapian-bindings,distcheck)
970 # FIXME: distcheck doesn't currently work for xapian-bindings because
971 # xapian-core isn't installed.
972 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
974 echo " cd $d && \$(MAKE) $target" ;;
978 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
981 cat <<EOF >> Makefile.tmp
984 \$(CONFIGURE_COMMAND)
986 Makefile: $srcdir/configure
987 \$(CONFIGURE_COMMAND)
989 $srcdir/configure: \\
994 # We want to rerun bootstrap if a series file changes (patch added or removed)
995 # or an existing patch changes. Since we always have an series file (even if
996 # it is empty), this also handles us adding the first patch for something.
997 for d
in patches
/* ; do
999 echo "$series:" >> configure.tmp2
1003 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
1009 # Because there's a pipeline, this is a subshell, so use a temporary file
1010 # rather than a variable to compile a list of patches to use below.
1011 echo "$patch:" >> configure.tmp2
1013 done >> configure.tmp
1015 cat <<'END_OF_CONFIGURE' >> configure.tmp
1018 echo " \$srcdir/bootstrap$bootstrap_sticky_opts" >> configure.tmp
1019 cat <<'END_OF_CONFIGURE' >> configure.tmp
1021 .PHONY: $targets recheck
1023 # Dummy dependencies to allow removing patches we no longer need.
1026 cat configure.tmp2
>> configure.tmp
1028 cat <<'END_OF_CONFIGURE' >> configure.tmp
1030 mv -f Makefile.tmp Makefile
1032 echo "Configured successfully - now run \"${MAKE-make}\""
1035 rm -f configure.tmp2
1037 chmod +x configure.tmp
1038 mv -f configure.tmp configure
1040 # git defaults to showing 7 character abbreviated hashes if that's enough to be
1041 # unique for a particular commit. But you can't paste these into trac as it
1042 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
1043 # need 9 characters to be unique across all of Xapian at the time of writing,
1044 # and 12 for the Linux kernel currently (a much larger number of objects than
1045 # Xapian). 12 is a manageable length and decently future-proof, so let's use
1047 core_abbrev_recommended
=12
1048 core_abbrev
=`git config --get core.abbrev||:`
1049 if [ -z "$core_abbrev" ] ; then
1050 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
1051 git config
--local core.abbrev
"$core_abbrev_recommended"
1052 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
1053 if [ -z "`git config --local core.abbrev`" ] ; then
1054 # Set globally to < $core_abbrev_recommended, override in this repo.
1055 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
1056 git config
--local core.abbrev
"$core_abbrev_recommended"
1059 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
1064 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""