Use new lemon /*X-overwrites-Y*/ magic comments
[xapian.git] / bootstrap
blob66e2930659fc912ff91acbe43e490ef1069c1061
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 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] [--download-tools=(always|ifneeded|never)] [--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 or curl).
41 FETCH_URL_TOOL=
43 check_sha1sum() {
44 # This function is expected to be used in 'if' so we can't rely on set -e
45 # being in effect here.
46 checksum=$1
47 tarball=$2
49 if [ -z "$SHA1SUM_TOOL" ] ; then
50 for SHA1SUM_TOOL in \
51 '${SHA1SUM-sha1sum} 2>/dev/null|cut -d\ -f1' \
52 '${SHASUM-shasum} 2>/dev/null|cut -d\ -f1' \
53 '${OPENSSL-openssl} sha1 2>/dev/null|sed "s/.* //"' \
54 '' ; do
55 if [ -z "$SHA1SUM_TOOL" ] ; then
56 echo <<'END'
57 Need sha1sum or shasum or openssl installed to check SHA1 checksums.
58 Set environment variable SHA1SUM, SHASUM or OPENSSL if the tool isn't on
59 your PATH.
60 END
61 exit 1
63 # Sanity check by hashing empty input.
64 r=`:|eval "$SHA1SUM_TOOL"`
65 [ X"$r" != Xda39a3ee5e6b4b0d3255bfef95601890afd80709 ] || break
66 done
68 r=`< $tarball eval "$SHA1SUM_TOOL"`
69 if [ X"$r" != X"$checksum" ] ; then
70 echo "$tarball: computed SHA1 checksum did NOT match"
71 echo "computed: $r with $SHA1SUM_TOOL"
72 echo "expected: $checksum"
73 ls -l $tarball
74 file $tarball || true
75 mv "$tarball" "$tarball.$r"
76 echo "Renamed $tarball to $tarball.$r"
77 exit 1
81 check_at_least() {
82 # This function is expected to be used in 'if' so we can't rely on set -e
83 # being in effect here.
84 v1=$1
85 v2=$2
86 save_IFS=$IFS
87 IFS=.
88 set x $v1
89 for v in $v2 ; do
90 shift
91 if [ "$1" != "$v" ] ; then
92 if [ -z "$1" ] || [ "$1" -lt "$v" ] ; then
93 IFS=$save_IFS
94 return 1
96 break
98 done
99 IFS=$save_IFS
100 return 0
103 lazy_build() {
104 # This function is expected to be used in 'if' so we can't rely on set -e
105 # being in effect here.
106 package=$1
107 binary=$2
108 version=$3
110 case $download_tools in
111 always) ;;
112 never)
113 return 1
116 if [ -n $binary ] ; then
117 if [ -s "../patches/$package/series" ] ; then
118 echo "There are patches to apply to $package so it has to be built"
119 else
120 # Check if a new enough version is already installed.
121 version_installed=`"$binary" --version 2>/dev/null|sed '1,1 s/.* //p;d'`
122 if [ -n "$version_installed" ] ; then
123 # Fast track equality.
124 if [ "$version_installed" = "$version" ] ; then
125 echo "$binary $version_installed installed, exactly what's needed"
126 return 1
128 if check_at_least "$version_installed" "$version" ; then
129 echo "$binary $version_installed installed >= $version required"
130 return 1
136 esac
138 basename=$package-$version
139 ext=$4
140 checksum=$5
142 if [ "$ext" = "tar.xz" ] ; then
143 if [ -z "$xz_ok" ] ; then
144 if ${XZ-xz} --version > /dev/null 2>&1 ; then
145 xz_ok=1
146 else
147 xz_ok=0
150 if [ "$xz_ok" = 0 ] ; then
151 shift 2
152 ext=$4
153 checksum=$5
156 if [ "$ext" = "tar.bz2" ] ; then
157 if [ -z "$bz2_ok" ] ; then
158 # bzip2 --version doesn't exit with code 0 in upstream version (though
159 # Debian at least patch this bug), so use --help to check it.
160 if bzip2 --help > /dev/null 2>&1 ; then
161 bz2_ok=1
162 else
163 bz2_ok=0
166 if [ "$bz2_ok" = 0 ] ; then
167 shift 2
168 ext=$4
169 checksum=$5
172 tarball=$basename.$ext
173 case $basename in
174 *[24680][a-z]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
175 esac
177 # Create the stamp file in INST so that rerunning bootstrap after
178 # "rm -rf INST" recovers nicely.
179 stamp=../INST/$package.stamp
181 # Download the tarball if required.
182 if [ ! -f "$tarball" ] ; then
183 if [ -z "$FETCH_URL_TOOL" ] ; then
184 if ${WGET-wget} --version > /dev/null 2>&1 ; then
185 FETCH_URL_TOOL="${WGET-wget} -O-"
186 elif ${CURL-curl} --version > /dev/null 2>&1 || [ "$?" = 2 ] ; then
187 # curl --version exits with code 2.
188 # -L is needed to follow HTTP redirects.
189 FETCH_URL_TOOL="${CURL-curl} -L"
190 elif ${LWP_REQUEST-lwp-request} -v > /dev/null 2>&1 || [ "$?" = 9 -o "$?" = 255 ] ; then
191 # lwp-request -v exits with code 9 (5.810) or 255 (6.03)
192 FETCH_URL_TOOL="${LWP_REQUEST-lwp-request} -mGET"
193 else
194 cat <<END >&2
195 Neither wget nor curl nor lwp-request found - install one of them or if already
196 installed, set WGET, CURL or LWP_REQUEST to the full path. Alternatively,
197 download $url
198 to directory `pwd`
199 then rerun this script.
201 exit 1
204 case $basename in
205 file-*)
206 if [ "$use_ftp" = yes ] ; then
207 url="ftp://ftp.astron.com/pub/file/$tarball"
208 else
209 url="http://fossies.org/unix/misc/$tarball"
210 fi ;;
211 *[13579][a-z])
212 # GNU alpha release
213 if [ "$use_ftp" = yes ] ; then
214 url="ftp://alpha.gnu.org/gnu/$package/$tarball"
215 else
216 url="http://alpha.gnu.org/gnu/$package/$tarball"
217 fi ;;
219 if [ "$use_ftp" = yes ] ; then
220 url="ftp://ftp.gnu.org/gnu/$package/$tarball"
221 else
222 url="http://ftpmirror.gnu.org/$package/$tarball"
223 fi ;;
224 esac
225 rm -f download.tmp
226 echo "Downloading <$url>"
227 $FETCH_URL_TOOL "$url" > download.tmp || exit $?
228 mv download.tmp "$tarball"
231 if [ -f "$stamp" ] ; then
232 find_stdout=`find "$tarball" ../patches/"$package"/* -newer "$stamp" -print 2> /dev/null||true`
233 else
234 find_stdout=force
237 if [ -n "$find_stdout" ] ; then
238 # Verify the tarball's checksum before building it.
239 check_sha1sum "$checksum" "$tarball"
241 # Remove tarballs of other versions.
242 for f in "$package"-* ; do
243 [ "$f" = "$tarball" ] || rm -rf "$f"
244 done
246 case $ext in
247 tar.xz)
248 ${XZ-xz} -dc "$tarball"| tar xf - || exit $? ;;
249 tar.bz2)
250 bzip2 -dc "$tarball"| tar xf - || exit $? ;;
252 gzip -dc "$tarball"| tar xf - || exit $? ;;
253 esac
255 cd "$basename" || exit $?
257 series="../../patches/$package/series"
258 if [ ! -f "$series" ] ; then
259 cat <<END >&2
260 No patch series file 'patches/$package/series' - if there are no patches,
261 this should just be an empty file.
263 exit 1
265 if [ -s "$series" ] ; then
266 echo "Applying patches from $package/series"
267 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" | \
268 while read p ; do
269 echo "Applying patch $package/$p"
270 patch -p1 < "../../patches/$package/$p" || exit $?
271 done
274 echo "Configuring $package"
275 if test -n "$AUTOCONF" ; then
276 ./configure --prefix "$instdir" AUTOCONF="$AUTOCONF" || exit $?
277 else
278 ./configure --prefix "$instdir" || exit $?
280 echo "Building $package"
281 make || exit $?
282 echo "Installing $package"
283 make install || exit $?
284 echo "Done installing $package"
285 cd .. || exit $?
286 rm -rf "$basename" || exit $?
288 touch "$stamp" || exit $?
290 return 0
293 handle_git_external() {
294 path=$1
295 if [ ! -f "$path/.nobootstrap" ] ; then
296 rev=$2
297 url=$3
298 if [ ! -d "$path" ] ; then
299 git clone --no-checkout -- "$url" "$path"
300 elif (cd "$path" && git reflog "$rev" -- 2>/dev/null) ; then
301 : # Already have that revision locally
302 else
303 (cd "$path" && git fetch)
305 (cd "$path" && git checkout "$rev")
309 update_config() {
310 from=$1
311 to=$2
312 ts_from=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$from"`
313 ts_to=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$to"`
314 if [ "$ts_from" -gt "$ts_to" ] ; then
315 echo "Updating $to ($ts_to) with $from ($ts_from)"
316 # rm first in case the existing file is a symlink.
317 rm -f "$to"
318 cp "$from" "$to"
322 curdir=`pwd`
324 # cd to srcdir if we aren't already there.
325 srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
326 case $srcdir in
327 ""|.)
328 srcdir=. ;;
330 cd "$srcdir" ;;
331 esac
333 # Commit hash to pass to handle_git_external for swig.
334 swig_git_commit_hash=2c910e47ae788412b95e356c99cef5862808bf9a
336 # Commit hashes to use for common in omega and letor respectively:
337 omega_common_commit_hash=b310f9988f63cdc15b48323f9ac42f6b08c3a36c
338 letor_common_commit_hash=b310f9988f63cdc15b48323f9ac42f6b08c3a36c
340 if [ ! -d .git ] ; then
341 echo "$0: No '.git' directory found - this script should be run from a"
342 echo "git repo cloned from git://git.xapian.org/xapian or a mirror of it"
343 exit 1
346 for emptydir in xapian-applications/omega/m4 xapian-bindings/m4 xapian-letor/m4 ; do
347 if test -d "$emptydir" ; then
349 else
350 parent=`echo "$emptydir"|sed 's,/[^/]*$,,'`
351 if test -d "$parent" ; then
352 mkdir "$emptydir"
355 done
357 if [ -f .git/info/exclude ] ; then
358 sed '/^\(swig\|xapian-applications\/omega\/common$\)/d' .git/info/exclude > .git/info/exclude~
359 else
360 [ -d .git/info ] || mkdir .git/info
362 cat <<END >> .git/info/exclude~
363 swig
364 xapian-applications/omega/common
365 xapian-letor/common
367 if [ -f .git/info/exclude ] &&
368 cmp -s .git/info/exclude~ .git/info/exclude ; then
369 rm .git/info/exclude~
370 else
371 mv .git/info/exclude~ .git/info/exclude
374 # If this tree is checked out from the github mirror, use the same access
375 # method for other things checked out from github (e.g. swig) so we avoid
376 # firewall issues. If there's no default remote, the git config command
377 # will exit with status 1, so ignore that failure.
378 origin_url=`git config remote.origin.url||:`
379 case $origin_url in
380 *[@/]github.com[:/]*)
381 github_base_url=`echo "X$origin_url"|sed 's/^X//;s!\([@/]github.com[:/]\).*!\1!'` ;;
383 github_base_url=https://github.com/ ;;
384 esac
385 swig_origin_url=${github_base_url}swig/swig.git
387 if [ -z "$XAPIAN_COMMON_CLONE_URL" ] ; then
388 xapian_common_clone_url=.
389 else
390 xapian_common_clone_url=$XAPIAN_COMMON_CLONE_URL
393 # Set to 'yes' to use ftp URLs where available.
395 # By default we prefer http downloads as they are more likely to work through
396 # firewalls.
397 use_ftp=no
399 # Set to 'always' to always use a locally installed copy of the autotools
400 # or 'never' to never download.
402 # By default we check for locally installed versions and use them if they are
403 # new enough versions. But e.g. for building releases we want to use a known
404 # set of versions.
405 download_tools=ifneeded
407 while [ "$#" -gt 0 ] ; do
408 case $1 in
409 --download-tools=*)
410 download_tools=`echo "x$1"|sed 's/x--download-tools=//'`
411 shift
412 continue
415 --download-tools)
416 download_tools=$2
417 shift 2
418 continue
421 --ftp)
422 use_ftp=yes
423 shift
424 continue
427 --clean)
428 rm -rf INST
429 shift
430 continue
433 --without-autotools)
434 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"
435 shift
436 continue
440 shift
441 break
445 echo "Unknown option '$1'" 1>&2
446 exit 1
450 break
452 esac
453 done
455 case $download_tools in
456 always|ifneeded) ;;
457 never)
458 echo "warning: If stuff breaks with '--download-tools=never', you get to keep the pieces"
461 echo "Invalid --download-tools value '$download_tools'"
462 exit 1
464 esac
466 [ -d INST ] || mkdir INST
467 instdir=`pwd`/INST
469 [ -d BUILD ] || mkdir BUILD
470 cd BUILD
472 # The last field is the SHA1 checksum of the tarball.
473 if lazy_build autoconf autoconf 2.69 \
474 tar.xz e891c3193029775e83e0534ac0ee0c4c711f6d23 \
475 tar.gz 562471cbcb0dd0fa42a76665acf0dbb68479b78a \
476 ; then
477 AUTOCONF=$instdir/bin/autoconf
478 export AUTOCONF
479 AUTORECONF=$instdir/bin/autoreconf
480 export AUTORECONF
481 AUTOHEADER=$instdir/bin/autoheader
482 export AUTOHEADER
483 AUTOM4TE=$instdir/bin/autom4te
484 export AUTOM4TE
486 if lazy_build automake automake 1.15.1 \
487 tar.xz 45632d466c16ecf18d9c18dc4be883cde59acb59 \
488 tar.gz d3cd5fc9bbea9f977b51799180cde5d253dcba96 \
489 ; then
490 ACLOCAL=$instdir/bin/aclocal
491 export ACLOCAL
492 AUTOMAKE=$instdir/bin/automake
493 export AUTOMAKE
495 if lazy_build libtool libtool 2.4.6 \
496 tar.xz 3e7504b832eb2dd23170c91b6af72e15b56eb94e \
497 tar.gz 25b6931265230a06f0fc2146df64c04e5ae6ec33 \
498 ; then
499 LIBTOOLIZE=$instdir/bin/libtoolize
500 export LIBTOOLIZE
501 libtool_aclocal=$instdir/share/aclocal
502 else
503 libtool_aclocal=`which libtool|sed 's!/bin/[^/]*$!/share/aclocal!'`
505 # If the aclocal we're using is in a different prefix to the libtool we're
506 # using, we probably need to tell aclocal where to look for our libtool's
507 # macros. Our directory may already by specified by other means, but it's
508 # fairly harmless to specify an explicit -I for a directory which is searched
509 # anyway - at worst it changes the search order.
510 if [ "`${ACLOCAL-aclocal} --print-ac-dir`" != "$libtool_aclocal" ] ; then
511 ACLOCAL="${ACLOCAL-aclocal} -I $libtool_aclocal"
512 export ACLOCAL
515 if [ "$1" = "--deps=libmagic" ] ; then
516 shift
517 lazy_build file '' 5.25 \
518 tar.gz fea78106dd0b7a09a61714cdbe545135563e84bd
521 cd ..
523 case `${LIBTOOLIZE-libtoolize} --version` in
525 echo "${LIBTOOLIZE-libtoolize} not found"
526 exit 1 ;;
527 "libtoolize (GNU libtool) 1.4.*")
528 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
529 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
530 exit 1 ;;
531 "libtoolize (GNU libtool) 1.5.*")
532 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
533 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
534 exit 1 ;;
535 esac
537 ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
538 export ACLOCAL
540 intree_swig=no
541 modules=
542 for module in ${@:-xapian-core xapian-applications/omega swig xapian-bindings} ; do
543 d=$module
544 if [ "$d" = swig ] ; then
545 if [ -f "xapian-bindings/.nobootstrap" ] ; then
546 # No point bootstrapping SWIG if we aren't going to use it.
547 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
548 continue
550 handle_git_external swig "$swig_git_commit_hash" "$swig_origin_url"
552 if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
554 else
555 # Skip any directories we can't bootstrap.
556 continue
558 if [ -f "$d/.nobootstrap" ] ; then
559 # Report why to save head scratching when someone forgets they created
560 # a .nobootstrap file.
561 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
562 continue
564 case $d in
565 xapian-applications/omega|xapian-letor)
566 # If someone's created a directory for common, leave it be.
567 if [ -h "$d/common" ] || [ ! -d "$d/common" ] ; then
568 # Pick omega_common_commit_hash or letor_common_commit_hash:
569 var=`echo "$d"|sed 's!.*[-/]!!g'`_common_commit_hash
570 hash=`eval echo \\\$"$var"`
571 handle_git_external "$d/.common.git" "$hash" "$xapian_common_clone_url"
572 ln -sf .common.git/xapian-core/common "$d/common"
575 esac
577 echo "Bootstrapping \`$module'"
578 [ -f "$d/preautoreconf" ] && "$d/preautoreconf"
580 # If we have a custom INSTALL file, preserve it since autoreconf insists on
581 # replacing INSTALL with "generic installation instructions" when --force
582 # is used. Be careful to replace it if autoreconf fails.
583 if [ -f "$d/INSTALL" ] ; then
584 if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
586 else
587 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
591 autoreconf_rc=
592 if [ swig = "$module" ] ; then
593 # SWIG provides its own bootstrapping script.
594 curdir=`pwd`
595 cd "$d"
596 ./autogen.sh || autoreconf_rc=$?
597 cd "$curdir"
598 # Use the uninstalled wrapper for the in-tree copy of SWIG.
599 intree_swig=yes
600 else
601 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
602 # (but it doesn't check for -i).
604 # Use --force so that we update files if autoconf, automake, or libtool
605 # has been upgraded.
606 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
608 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
609 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
611 if [ -n "$autoreconf_rc" ] ; then
612 exit $autoreconf_rc
614 for f in config.guess config.sub ; do
615 if [ -f "$d/$f" ] ; then
616 update_config "config/$f" "$d/$f"
618 done
619 modules="$modules $module"
620 done
622 # Produce an absolute path to srcdir.
623 srcdir_abs=`pwd`
625 # Generate the top-level configure script.
626 rm -f configure.tmp
627 cat <<TOP_OF_CONFIGURE > configure.tmp
628 #!/bin/sh
629 # configure each submodule in a xapian source tree
630 # Generated by Xapian top-level bootstrap script.
631 #$copyright
632 trap 'echo "configure failed"' EXIT
633 set -e
635 srcdir="$srcdir_abs"
636 modules="$modules"
638 TOP_OF_CONFIGURE
640 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
641 # Produced escaped version of command suitable for pasting back into sh
642 cmd=$0
643 for a ; do
644 case $a in
645 *[^-A-Za-z0-9_+=:@/.,]*)
646 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
647 cmd="$cmd $esc_a" ;;
649 cmd="$cmd $a" ;;
650 esac
651 done
653 here=`pwd`
654 MIDDLE_OF_CONFIGURE
656 vars=
657 if [ yes = "$intree_swig" ] ; then
658 # We want the path to SWIG to point into srcdir, which isn't known until
659 # configure-time, so we need to expand $here in configure.
660 vars=' SWIG=$here/swig/preinst-swig'
661 elif [ -n "$SWIG" ] ; then
662 # User specified SWIG in environment, e.g. with:
663 # SWIG=/opt/swig/bin/swig ./bootstrap
664 vars=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
666 for tool in $autotools ; do
667 eval "val=\$$tool"
668 if [ -n "$val" ] ; then
669 echo ': ${'"$tool='$val'"'}' >> configure.tmp
670 echo "export $tool" >> configure.tmp
671 vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
673 done
674 if [ -n "$vars" ] ; then
675 # $vars will always have a leading space.
676 echo "set$vars "'"$@"' >> configure.tmp
679 cat <<'END_OF_CONFIGURE' >> configure.tmp
680 dirs=
681 revdirs=
682 XAPIAN_CONFIG=$here/xapian-core/xapian-config
683 for d in $modules ; do
684 if [ "$here" = "$srcdir" ] ; then
685 configure=./configure
686 configure_from_here=$d/configure
687 else
688 configure=$srcdir/$d/configure
689 configure_from_here=$configure
691 if [ -f "$configure_from_here" ] ; then
692 if [ -d "$d" ] ; then : ; else
693 case $d in
694 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
695 esac
696 mkdir "$d"
698 echo "Configuring \`$d'"
699 # Use a shared config.cache for speed and to save a bit of diskspace, but
700 # don't share it with SWIG just in case it manages to probe and cache
701 # different answers (e.g. because it uses a C compiler).
702 case $d in
703 swig)
704 case "$*" in
705 *--host=*|*--host" "*)
706 # We're cross-building, but SWIG needs to be built natively.
707 swig_configure_args=
708 skip=
709 for arg in "$@" ; do
710 if [ -n "$skip" ] ; then
711 skip=
712 continue
714 case $arg in
715 --host=*)
716 # Drop --host=xxx
717 continue ;;
718 --host)
719 # Drop --host xxx
720 skip=1
721 continue ;;
722 CC=*|CXX=*)
723 # Drop CC=xxx or CXX=xxx
724 continue ;;
725 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
726 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
727 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
729 SWIG=*)
730 # Drop SWIG=xxx - not useful and could cause problems.
731 continue ;;
732 esac
733 swig_configure_args="$swig_configure_args "\'`echo "x$arg"|sed "s/^x//;s/'/'\\\\\\\\''/g"`\'
734 done
735 # Also handle compilers specified in environment variables. We can
736 # just reassign them unconditionally as CC and CXX are ignored if
737 # empty.
738 cd "$d" && CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD "$configure" `eval echo $swig_configure_args`
741 cd "$d" && "$configure" ${1+"$@"}
743 esac
745 xapian-core)
746 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
748 xapian-applications/omega)
749 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include" LDFLAGS="-L$srcdir/INST/lib" ${1+"$@"}
752 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
754 esac
755 cd "$here"
756 dirs="$dirs $d"
757 revdirs="$d $revdirs"
759 done
761 case " $* " in
762 *" --help "*|*" --version "*)
763 # Don't generate Makefile if --help or --version specified.
764 trap - EXIT
765 exit 0
767 esac
769 rm -f Makefile.tmp
770 cat <<EOF > Makefile.tmp
771 # Makefile generated by:
772 CONFIGURE_COMMAND := $cmd
774 if [ "$srcdir" != . ] ; then
775 cat <<EOF >> Makefile.tmp
777 VPATH = $srcdir
780 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
781 for target in $targets ; do
782 echo
783 echo "$target:"
784 case $target in
785 uninstall|*clean)
786 # When uninstalling or cleaning, process directories in reverse order, so
787 # that we process a directory after any directories which might use it.
788 list=$revdirs ;;
790 list=$dirs ;;
791 esac
792 for d in $list ; do
793 case $d,$target in
794 swig,install*|swig,uninstall)
795 # Nothing to do with swig when installing/uninstalling.
797 swig,dist|swig,check|swig,distcheck|swig,all)
798 # Need to ensure swig is built before "make dist", "make check", etc.
799 echo " cd $d && \$(MAKE)" ;;
800 swig,mostlyclean)
801 echo " cd $d && \$(MAKE) clean" ;;
802 xapian-bindings,distcheck)
803 # FIXME: distcheck doesn't currently work for xapian-bindings because
804 # xapian-core isn't installed.
805 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
807 echo " cd $d && \$(MAKE) $target" ;;
808 esac
809 done
810 case $target in
811 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
812 esac
813 done >> Makefile.tmp
814 cat <<EOF >> Makefile.tmp
816 recheck:
817 \$(CONFIGURE_COMMAND)
819 Makefile: $srcdir/configure
820 \$(CONFIGURE_COMMAND)
822 $srcdir/configure: \\
823 END_OF_CONFIGURE
825 : > configure.tmp2
827 # We want to rerun bootstrap if a series file changes (patch added or removed)
828 # or an existing patch changes. Since we always have an series file (even if
829 # it is empty), this also handles us adding the first patch for something.
830 patches=
831 for d in patches/* ; do
832 series=$d/series
833 echo "$series:" >> configure.tmp2
834 cat << END
835 $series\\\\
837 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
838 while read p ; do
839 patch=$d/$p
840 cat << END
841 $patch\\\\
843 # Because there's a pipeline, this is a subshell, so use a temporary file
844 # rather than a variable to compile a list of patches to use below.
845 echo "$patch:" >> configure.tmp2
846 done
847 done >> configure.tmp
849 cat <<'END_OF_CONFIGURE' >> configure.tmp
850 $srcdir/bootstrap
851 $srcdir/bootstrap
853 .PHONY: $targets recheck
855 # Dummy dependencies to allow removing patches we no longer need.
856 END_OF_CONFIGURE
858 cat configure.tmp2 >> configure.tmp
860 cat <<'END_OF_CONFIGURE' >> configure.tmp
862 mv -f Makefile.tmp Makefile
863 trap - EXIT
864 echo "Configured successfully - now run \"${MAKE-make}\""
865 END_OF_CONFIGURE
867 rm -f configure.tmp2
869 chmod +x configure.tmp
870 mv -f configure.tmp configure
872 # git defaults to showing 7 character abbreviated hashes if that's enough to be
873 # unique for a particular commit. But you can't paste these into trac as it
874 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
875 # need 9 characters to be unique across all of Xapian at the time of writing,
876 # and 12 for the Linux kernel currently (a much larger number of objects than
877 # Xapian). 12 is a manageable length and decently future-proof, so let's use
878 # that.
879 core_abbrev_recommended=12
880 core_abbrev=`git config --get core.abbrev||:`
881 if [ -z "$core_abbrev" ] ; then
882 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
883 git config --local core.abbrev "$core_abbrev_recommended"
884 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
885 if [ -z "`git config --local core.abbrev`" ] ; then
886 # Set globally to < $core_abbrev_recommended, override in this repo.
887 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
888 git config --local core.abbrev "$core_abbrev_recommended"
889 else
890 # Just warn.
891 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
895 trap - EXIT
896 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""