Fix formatting of @file comment
[xapian.git] / bootstrap
blob5b7a216ee8941ea449bc188e03525010ed55c530
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 checksum=$1
45 tarball=$2
47 if [ -z "$SHA1SUM_TOOL" ] ; then
48 for SHA1SUM_TOOL in \
49 '${SHA1SUM-sha1sum} 2>/dev/null|cut -d\ -f1' \
50 '${SHASUM-shasum} 2>/dev/null|cut -d\ -f1' \
51 '${OPENSSL-openssl} sha1 2>/dev/null|sed "s/.* //"' \
52 '' ; do
53 if [ -z "$SHA1SUM_TOOL" ] ; then
54 echo <<'END'
55 Need sha1sum or shasum or openssl installed to check SHA1 checksums.
56 Set environment variable SHA1SUM, SHASUM or OPENSSL if the tool isn't on
57 your PATH.
58 END
59 exit 1
61 r=`:|eval "$SHA1SUM_TOOL"`
62 [ X"$r" != Xda39a3ee5e6b4b0d3255bfef95601890afd80709 ] || break
63 done
65 r=`< $tarball eval "$SHA1SUM_TOOL"`
66 if [ X"$r" != X"$checksum" ] ; then
67 echo "$tarball: computed SHA1 checksum did NOT match"
68 echo "computed: $r with $SHA1SUM_TOOL"
69 echo "expected: $checksum"
70 ls -l $tarball
71 file $tarball || true
72 mv "$tarball" "$tarball.$r"
73 echo "Renamed $tarball to $tarball.$r"
74 exit 1
78 check_at_least() {
79 v1=$1
80 v2=$2
81 save_IFS=$IFS
82 IFS=.
83 set x $v1
84 for v in $v2 ; do
85 shift
86 if [ "$1" != "$v" ] ; then
87 if [ "$1" -lt "$v" ] ; then
88 IFS=$save_IFS
89 return 1
91 break
93 done
94 IFS=$save_IFS
95 return 0
98 lazy_build() {
99 package=$1
100 binary=$2
101 version=$3
103 case $download_tools in
104 always) ;;
105 never)
106 return 1
109 if [ -n $binary ] ; then
110 # Check if a new enough version is already installed.
111 version_installed=`"$binary" --version 2>/dev/null|sed '1,1 s/.* //p;d'`
112 if [ -n "$version_installed" ] ; then
113 # Fast track equality.
114 if [ "$version_installed" = "$version" ] ; then
115 echo "$binary $version_installed installed, exactly what's needed"
116 return 1
118 if check_at_least "$version_installed" "$version" ; then
119 echo "$binary $version_installed installed >= $version required"
120 return 1
125 esac
127 basename=$package-$version
128 ext=$4
129 checksum=$5
131 if [ "$ext" = "tar.xz" ] ; then
132 if [ -z "$xz_ok" ] ; then
133 if ${XZ-xz} --version > /dev/null 2>&1 ; then
134 xz_ok=1
135 else
136 xz_ok=0
139 if [ "$xz_ok" = 0 ] ; then
140 shift 2
141 ext=$4
142 checksum=$5
145 if [ "$ext" = "tar.bz2" ] ; then
146 if [ -z "$bz2_ok" ] ; then
147 # bzip2 --version doesn't exit with code 0 in upstream version (though
148 # Debian at least patch this bug), so use --help to check it.
149 if bzip2 --help > /dev/null 2>&1 ; then
150 bz2_ok=1
151 else
152 bz2_ok=0
155 if [ "$bz2_ok" = 0 ] ; then
156 shift 2
157 ext=$4
158 checksum=$5
161 tarball=$basename.$ext
162 case $basename in
163 *[24680][a-z]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
164 esac
166 # Create the stamp file in INST so that rerunning bootstrap after
167 # "rm -rf INST" recovers nicely.
168 stamp=../INST/$package.stamp
170 # Download the tarball if required.
171 if [ ! -f "$tarball" ] ; then
172 if [ -z "$FETCH_URL_TOOL" ] ; then
173 if ${WGET-wget} --version > /dev/null 2>&1 ; then
174 FETCH_URL_TOOL="${WGET-wget} -O-"
175 elif ${CURL-curl} --version > /dev/null 2>&1 || [ "$?" = 2 ] ; then
176 # curl --version exits with code 2.
177 # -L is needed to follow HTTP redirects.
178 FETCH_URL_TOOL="${CURL-curl} -L"
179 elif ${LWP_REQUEST-lwp-request} -v > /dev/null 2>&1 || [ "$?" = 9 -o "$?" = 255 ] ; then
180 # lwp-request -v exits with code 9 (5.810) or 255 (6.03)
181 FETCH_URL_TOOL="${LWP_REQUEST-lwp-request} -mGET"
182 else
183 cat <<END >&2
184 Neither wget nor curl nor lwp-request found - install one of them or if already
185 installed, set WGET, CURL or LWP_REQUEST to the full path. Alternatively,
186 download $url
187 to directory `pwd`
188 then rerun this script.
190 exit 1
193 case $basename in
194 file-*)
195 if [ "$use_ftp" = yes ] ; then
196 url="ftp://ftp.astron.com/pub/file/$tarball"
197 else
198 url="http://fossies.org/unix/misc/$tarball"
199 fi ;;
200 *[13579][a-z])
201 # GNU alpha release
202 if [ "$use_ftp" = yes ] ; then
203 url="ftp://alpha.gnu.org/gnu/$package/$tarball"
204 else
205 url="http://alpha.gnu.org/gnu/$package/$tarball"
206 fi ;;
208 if [ "$use_ftp" = yes ] ; then
209 url="ftp://ftp.gnu.org/gnu/$package/$tarball"
210 else
211 url="http://ftpmirror.gnu.org/$package/$tarball"
212 fi ;;
213 esac
214 rm -f download.tmp
215 echo "Downloading <$url>"
216 $FETCH_URL_TOOL "$url" > download.tmp && mv download.tmp "$tarball"
219 if [ -f "$stamp" ] ; then
220 find_stdout=`find "$tarball" ../patches/"$package"/* -newer "$stamp" -print 2> /dev/null||true`
221 else
222 find_stdout=force
225 if [ -n "$find_stdout" ] ; then
226 # Verify the tarball's checksum before building it.
227 check_sha1sum "$checksum" "$tarball"
229 # Remove tarballs of other versions.
230 for f in "$package"-* ; do
231 [ "$f" = "$tarball" ] || rm -rf "$f"
232 done
234 case $ext in
235 tar.xz)
236 ${XZ-xz} -dc "$tarball"| tar xf - ;;
237 tar.bz2)
238 bzip2 -dc "$tarball"| tar xf - ;;
240 gzip -dc "$tarball"| tar xf - ;;
241 esac
243 cd "$basename"
245 if [ ! -f "../../patches/$package/series" ] ; then
246 cat <<END >&2
247 No patch series file 'patches/$package/series' - if there are no patches,
248 this should just be an empty file.
250 exit 1
252 echo "Applying patches from $package/series"
253 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "../../patches/$package/series" | \
254 while read p ; do
255 echo "Applying patch $package/$p"
256 patch -p1 < "../../patches/$package/$p"
257 done
259 if test -n "$AUTOCONF" ; then
260 ./configure --prefix "$instdir" AUTOCONF="$AUTOCONF"
261 else
262 ./configure --prefix "$instdir"
264 make
265 make install
266 cd ..
267 rm -rf "$basename"
269 touch "$stamp"
271 return 0
274 handle_git_external() {
275 path=$1
276 if [ ! -f "$path/.nobootstrap" ] ; then
277 rev=$2
278 url=$3
279 if [ ! -d "$path" ] ; then
280 git clone --no-checkout -- "$url" "$path"
281 elif (cd "$path" && git reflog "$rev" -- 2>/dev/null) ; then
282 : # Already have that revision locally
283 else
284 (cd "$path" && git fetch)
286 (cd "$path" && git checkout "$rev")
290 update_config() {
291 from=$1
292 to=$2
293 ts_from=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$from"`
294 ts_to=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$to"`
295 if [ "$ts_from" -gt "$ts_to" ] ; then
296 echo "Updating $to ($ts_to) with $from ($ts_from)"
297 # rm first in case the existing file is a symlink.
298 rm -f "$to"
299 cp "$from" "$to"
303 curdir=`pwd`
305 # cd to srcdir if we aren't already there.
306 srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
307 case $srcdir in
308 ""|.)
309 srcdir=. ;;
311 cd "$srcdir" ;;
312 esac
314 # Commit hash to pass to handle_git_external for swig.
315 swig_git_commit_hash=2c910e47ae788412b95e356c99cef5862808bf9a
317 # Commit hashes to use for common in omega and letor respectively:
318 omega_common_commit_hash=bddcf54435286b0363efff94f22529093e85fc89
319 letor_common_commit_hash=bddcf54435286b0363efff94f22529093e85fc89
321 if [ ! -d .git ] ; then
322 echo "$0: No '.git' directory found - this script should be run from a"
323 echo "git repo cloned from git://git.xapian.org/xapian or a mirror of it"
324 exit 1
327 for emptydir in xapian-applications/omega/m4 xapian-bindings/m4 xapian-letor/m4 ; do
328 if test -d "$emptydir" ; then
330 else
331 parent=`echo "$emptydir"|sed 's,/[^/]*$,,'`
332 if test -d "$parent" ; then
333 mkdir "$emptydir"
336 done
338 if [ -f .git/info/exclude ] ; then
339 sed '/^\(swig\|xapian-applications\/omega\/common$\)/d' .git/info/exclude > .git/info/exclude~
340 else
341 [ -d .git/info ] || mkdir .git/info
343 cat <<END >> .git/info/exclude~
344 swig
345 xapian-applications/omega/common
346 xapian-letor/common
348 if [ -f .git/info/exclude ] &&
349 cmp -s .git/info/exclude~ .git/info/exclude ; then
350 rm .git/info/exclude~
351 else
352 mv .git/info/exclude~ .git/info/exclude
355 # If this tree is checked out from the github mirror, use the same access
356 # method for other things checked out from github (e.g. swig) so we avoid
357 # firewall issues. If there's no default remote, the git config command
358 # will exit with status 1, so ignore that failure.
359 origin_url=`git config remote.origin.url||:`
360 case $origin_url in
361 *[@/]github.com[:/]*)
362 github_base_url=`echo "X$origin_url"|sed 's/^X//;s!\([@/]github.com[:/]\).*!\1!'` ;;
364 github_base_url=https://github.com/ ;;
365 esac
366 swig_origin_url=${github_base_url}swig/swig.git
368 if [ -z "$XAPIAN_COMMON_CLONE_URL" ] ; then
369 xapian_common_clone_url=.
370 else
371 xapian_common_clone_url=$XAPIAN_COMMON_CLONE_URL
374 # Set to 'yes' to use ftp URLs where available.
376 # By default we prefer http downloads as they are more likely to work through
377 # firewalls.
378 use_ftp=no
380 # Set to 'always' to always use a locally installed copy of the autotools
381 # or 'never' to never download.
383 # By default we check for locally installed versions and use them if they are
384 # new enough versions. But e.g. for building releases we want to use a known
385 # set of versions.
386 download_tools=ifneeded
388 while [ "$#" -gt 0 ] ; do
389 case $1 in
390 --download-tools=*)
391 download_tools=`echo "x$1"|sed 's/x--download-tools=//'`
392 shift
393 continue
396 --download-tools)
397 download_tools=$2
398 shift 2
399 continue
402 --ftp)
403 use_ftp=yes
404 shift
405 continue
408 --clean)
409 rm -rf INST
410 shift
411 continue
414 --without-autotools)
415 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"
416 shift
417 continue
421 shift
422 break
426 echo "Unknown option '$1'" 1>&2
427 exit 1
431 break
433 esac
434 done
436 case $download_tools in
437 always|ifneeded) ;;
438 never)
439 echo "warning: If stuff breaks with '--download-tools=never', you get to keep the pieces"
442 echo "Invalid --download-tools value '$download_tools'"
443 exit 1
445 esac
447 [ -d INST ] || mkdir INST
448 instdir=`pwd`/INST
450 [ -d BUILD ] || mkdir BUILD
451 cd BUILD
453 # The last field is the SHA1 checksum of the tarball.
454 if lazy_build autoconf autoconf 2.69 \
455 tar.xz e891c3193029775e83e0534ac0ee0c4c711f6d23 \
456 tar.gz 562471cbcb0dd0fa42a76665acf0dbb68479b78a \
457 ; then
458 AUTOCONF=$instdir/bin/autoconf
459 export AUTOCONF
460 AUTORECONF=$instdir/bin/autoreconf
461 export AUTORECONF
462 AUTOHEADER=$instdir/bin/autoheader
463 export AUTOHEADER
464 AUTOM4TE=$instdir/bin/autom4te
465 export AUTOM4TE
467 if lazy_build automake automake 1.15 \
468 tar.xz c279b35ca6c410809dac8ade143b805fb48b7655 \
469 tar.gz b5a840c7ec4321e78fdc9472e476263fa6614ca1 \
470 ; then
471 ACLOCAL=$instdir/bin/aclocal
472 export ACLOCAL
473 AUTOMAKE=$instdir/bin/automake
474 export AUTOMAKE
476 if lazy_build libtool libtool 2.4.6 \
477 tar.xz 3e7504b832eb2dd23170c91b6af72e15b56eb94e \
478 tar.gz 25b6931265230a06f0fc2146df64c04e5ae6ec33 \
479 ; then
480 LIBTOOLIZE=$instdir/bin/libtoolize
481 export LIBTOOLIZE
483 if [ "$1" = "--deps=libmagic" ] ; then
484 shift
485 lazy_build file '' 5.25 \
486 tar.gz fea78106dd0b7a09a61714cdbe545135563e84bd
489 cd ..
491 case `${LIBTOOLIZE-libtoolize} --version` in
493 echo "${LIBTOOLIZE-libtoolize} not found"
494 exit 1 ;;
495 "libtoolize (GNU libtool) 1.4.*")
496 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
497 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
498 exit 1 ;;
499 "libtoolize (GNU libtool) 1.5.*")
500 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
501 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
502 exit 1 ;;
503 esac
505 ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
506 export ACLOCAL
508 intree_swig=no
509 modules=
510 for module in ${@:-xapian-core xapian-applications/omega swig xapian-bindings} ; do
511 d=$module
512 if [ "$d" = swig ] ; then
513 if [ -f "xapian-bindings/.nobootstrap" ] ; then
514 # No point bootstrapping SWIG if we aren't going to use it.
515 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
516 continue
518 handle_git_external swig "$swig_git_commit_hash" "$swig_origin_url"
520 if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
522 else
523 # Skip any directories we can't bootstrap.
524 continue
526 if [ -f "$d/.nobootstrap" ] ; then
527 # Report why to save head scratching when someone forgets they created
528 # a .nobootstrap file.
529 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
530 continue
532 case $d in
533 xapian-applications/omega|xapian-letor)
534 # If someone's created a directory for common, leave it be.
535 if [ -h "$d/common" ] || [ ! -d "$d/common" ] ; then
536 # Pick omega_common_commit_hash or letor_common_commit_hash:
537 var=`echo "$d"|sed 's!.*[-/]!!g'`_common_commit_hash
538 hash=`eval echo \\\$"$var"`
539 handle_git_external "$d/.common.git" "$hash" "$xapian_common_clone_url"
540 ln -sf .common.git/xapian-core/common "$d/common"
543 esac
545 echo "Bootstrapping \`$module'"
546 [ -f "$d/preautoreconf" ] && "$d/preautoreconf"
548 # If we have a custom INSTALL file, preserve it since autoreconf insists on
549 # replacing INSTALL with "generic installation instructions" when --force
550 # is used. Be careful to replace it if autoreconf fails.
551 if [ -f "$d/INSTALL" ] ; then
552 if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
554 else
555 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
559 autoreconf_rc=
560 if [ swig = "$module" ] ; then
561 # SWIG provides its own bootstrapping script.
562 curdir=`pwd`
563 cd "$d"
564 ./autogen.sh || autoreconf_rc=$?
565 cd "$curdir"
566 # Use the uninstalled wrapper for the in-tree copy of SWIG.
567 intree_swig=yes
568 else
569 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
570 # (but it doesn't check for -i).
572 # Use --force so that we update files if autoconf, automake, or libtool
573 # has been upgraded.
574 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
576 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
577 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
579 if [ -n "$autoreconf_rc" ] ; then
580 exit $autoreconf_rc
582 for f in config.guess config.sub ; do
583 if [ -f "$d/$f" ] ; then
584 update_config "config/$f" "$d/$f"
586 done
587 modules="$modules $module"
588 done
590 # Produce an absolute path to srcdir.
591 srcdir_abs=`pwd`
593 # Generate the top-level configure script.
594 rm -f configure.tmp
595 cat <<TOP_OF_CONFIGURE > configure.tmp
596 #!/bin/sh
597 # configure each submodule in a xapian source tree
598 # Generated by Xapian top-level bootstrap script.
599 #$copyright
600 trap 'echo "configure failed"' EXIT
601 set -e
603 srcdir="$srcdir_abs"
604 modules="$modules"
606 TOP_OF_CONFIGURE
608 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
609 # Produced escaped version of command suitable for pasting back into sh
610 cmd=$0
611 for a ; do
612 case $a in
613 *[^-A-Za-z0-9_+=:@/.,]*)
614 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
615 cmd="$cmd $esc_a" ;;
617 cmd="$cmd $a" ;;
618 esac
619 done
621 here=`pwd`
622 MIDDLE_OF_CONFIGURE
624 vars=
625 if [ yes = "$intree_swig" ] ; then
626 # We want the path to SWIG to point into srcdir, which isn't known until
627 # configure-time, so we need to expand $here in configure.
628 vars=' SWIG=$here/swig/preinst-swig'
629 elif [ -n "$SWIG" ] ; then
630 # User specified SWIG in environment, e.g. with:
631 # SWIG=/opt/swig/bin/swig ./bootstrap
632 vars=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
634 for tool in $autotools ; do
635 eval "val=\$$tool"
636 if [ -n "$val" ] ; then
637 echo ': ${'"$tool='$val'"'}' >> configure.tmp
638 echo "export $tool" >> configure.tmp
639 vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
641 done
642 if [ -n "$vars" ] ; then
643 # $vars will always have a leading space.
644 echo "set$vars "'"$@"' >> configure.tmp
647 cat <<'END_OF_CONFIGURE' >> configure.tmp
648 dirs=
649 revdirs=
650 XAPIAN_CONFIG=$here/xapian-core/xapian-config
651 for d in $modules ; do
652 if [ "$here" = "$srcdir" ] ; then
653 configure=./configure
654 configure_from_here=$d/configure
655 else
656 configure=$srcdir/$d/configure
657 configure_from_here=$configure
659 if [ -f "$configure_from_here" ] ; then
660 if [ -d "$d" ] ; then : ; else
661 case $d in
662 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
663 esac
664 mkdir "$d"
666 echo "Configuring \`$d'"
667 # Use a shared config.cache for speed and to save a bit of diskspace, but
668 # don't share it with SWIG just in case it manages to probe and cache
669 # different answers (e.g. because it uses a C compiler).
670 case $d in
671 swig)
672 case "$*" in
673 *--host=*|*--host" "*)
674 # We're cross-building, but SWIG needs to be built natively.
675 swig_configure_args=
676 skip=
677 for arg in "$@" ; do
678 if [ -n "$skip" ] ; then
679 skip=
680 continue
682 case $arg in
683 --host=*)
684 # Drop --host=xxx
685 continue ;;
686 --host)
687 # Drop --host xxx
688 skip=1
689 continue ;;
690 CC=*|CXX=*)
691 # Drop CC=xxx or CXX=xxx
692 continue ;;
693 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
694 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
695 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
697 SWIG=*)
698 # Drop SWIG=xxx - not useful and could cause problems.
699 continue ;;
700 esac
701 swig_configure_args="$swig_configure_args "\'`echo "x$arg"|sed "s/^x//;s/'/'\\\\\\\\''/g"`\'
702 done
703 # Also handle compilers specified in environment variables. We can
704 # just reassign them unconditionally as CC and CXX are ignored if
705 # empty.
706 cd "$d" && CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD "$configure" `eval echo $swig_configure_args`
709 cd "$d" && "$configure" ${1+"$@"}
711 esac
713 xapian-core)
714 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
716 xapian-applications/omega)
717 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include" LDFLAGS="-L$srcdir/INST/lib" ${1+"$@"}
720 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
722 esac
723 cd "$here"
724 dirs="$dirs $d"
725 revdirs="$d $revdirs"
727 done
729 case " $* " in
730 *" --help "*|*" --version "*)
731 # Don't generate Makefile if --help or --version specified.
732 trap - EXIT
733 exit 0
735 esac
737 rm -f Makefile.tmp
738 cat <<EOF > Makefile.tmp
739 # Makefile generated by:
740 CONFIGURE_COMMAND := $cmd
742 if [ "$srcdir" != . ] ; then
743 cat <<EOF >> Makefile.tmp
745 VPATH = $srcdir
748 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
749 for target in $targets ; do
750 echo
751 echo "$target:"
752 case $target in
753 uninstall|*clean)
754 # When uninstalling or cleaning, process directories in reverse order, so
755 # that we process a directory after any directories which might use it.
756 list=$revdirs ;;
758 list=$dirs ;;
759 esac
760 for d in $list ; do
761 case $d,$target in
762 swig,install*|swig,uninstall)
763 # Nothing to do with swig when installing/uninstalling.
765 swig,dist|swig,check|swig,distcheck|swig,all)
766 # Need to ensure swig is built before "make dist", "make check", etc.
767 echo " cd $d && \$(MAKE)" ;;
768 swig,mostlyclean)
769 echo " cd $d && \$(MAKE) clean" ;;
770 xapian-bindings,distcheck)
771 # FIXME: distcheck doesn't currently work for xapian-bindings because
772 # xapian-core isn't installed.
773 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
775 echo " cd $d && \$(MAKE) $target" ;;
776 esac
777 done
778 case $target in
779 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
780 esac
781 done >> Makefile.tmp
782 cat <<EOF >> Makefile.tmp
784 recheck:
785 \$(CONFIGURE_COMMAND)
787 Makefile: $srcdir/configure
788 \$(CONFIGURE_COMMAND)
790 $srcdir/configure: \\
791 END_OF_CONFIGURE
793 : > configure.tmp2
795 # We want to rerun bootstrap if a series file changes (patch added or removed)
796 # or an existing patch changes. Since we always have an series file (even if
797 # it is empty), this also handles us adding the first patch for something.
798 patches=
799 for d in patches/* ; do
800 series=$d/series
801 echo "$series:" >> configure.tmp2
802 cat << END
803 $series\\\\
805 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
806 while read p ; do
807 patch=$d/$p
808 cat << END
809 $patch\\\\
811 # Because there's a pipeline, this is a subshell, so use a temporary file
812 # rather than a variable to compile a list of patches to use below.
813 echo "$patch:" >> configure.tmp2
814 done
815 done >> configure.tmp
817 cat <<'END_OF_CONFIGURE' >> configure.tmp
818 $srcdir/bootstrap
819 $srcdir/bootstrap
821 .PHONY: $targets recheck
823 # Dummy dependencies to allow removing patches we no longer need.
824 END_OF_CONFIGURE
826 cat configure.tmp2 >> configure.tmp
828 cat <<'END_OF_CONFIGURE' >> configure.tmp
830 mv -f Makefile.tmp Makefile
831 trap - EXIT
832 echo "Configured successfully - now run \"${MAKE-make}\""
833 END_OF_CONFIGURE
835 rm -f configure.tmp2
837 chmod +x configure.tmp
838 mv -f configure.tmp configure
840 # git defaults to showing 7 character abbreviated hashes if that's enough to be
841 # unique for a particular commit. But you can't paste these into trac as it
842 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
843 # need 9 characters to be unique across all of Xapian at the time of writing,
844 # and 12 for the Linux kernel currently (a much larger number of objects than
845 # Xapian). 12 is a manageable length and decently future-proof, so let's use
846 # that.
847 core_abbrev_recommended=12
848 core_abbrev=`git config --get core.abbrev||:`
849 if [ -z "$core_abbrev" ] ; then
850 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
851 git config --local core.abbrev "$core_abbrev_recommended"
852 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
853 if [ -z "`git config --local core.abbrev`" ] ; then
854 # Set globally to < $core_abbrev_recommended, override in this repo.
855 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
856 git config --local core.abbrev "$core_abbrev_recommended"
857 else
858 # Just warn.
859 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
863 trap - EXIT
864 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""