Define USE_WIN32_UUID_API and use it
[xapian.git] / bootstrap
blobb00a9d0c9121c48a9ae889e77596a0c59207beff
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
502 if [ "$1" = "--deps=libmagic" ] ; then
503 shift
504 lazy_build file '' 5.25 \
505 tar.gz fea78106dd0b7a09a61714cdbe545135563e84bd
508 cd ..
510 case `${LIBTOOLIZE-libtoolize} --version` in
512 echo "${LIBTOOLIZE-libtoolize} not found"
513 exit 1 ;;
514 "libtoolize (GNU libtool) 1.4.*")
515 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
516 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
517 exit 1 ;;
518 "libtoolize (GNU libtool) 1.5.*")
519 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
520 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
521 exit 1 ;;
522 esac
524 ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
525 export ACLOCAL
527 intree_swig=no
528 modules=
529 for module in ${@:-xapian-core xapian-applications/omega swig xapian-bindings} ; do
530 d=$module
531 if [ "$d" = swig ] ; then
532 if [ -f "xapian-bindings/.nobootstrap" ] ; then
533 # No point bootstrapping SWIG if we aren't going to use it.
534 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
535 continue
537 handle_git_external swig "$swig_git_commit_hash" "$swig_origin_url"
539 if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
541 else
542 # Skip any directories we can't bootstrap.
543 continue
545 if [ -f "$d/.nobootstrap" ] ; then
546 # Report why to save head scratching when someone forgets they created
547 # a .nobootstrap file.
548 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
549 continue
551 case $d in
552 xapian-applications/omega|xapian-letor)
553 # If someone's created a directory for common, leave it be.
554 if [ -h "$d/common" ] || [ ! -d "$d/common" ] ; then
555 # Pick omega_common_commit_hash or letor_common_commit_hash:
556 var=`echo "$d"|sed 's!.*[-/]!!g'`_common_commit_hash
557 hash=`eval echo \\\$"$var"`
558 handle_git_external "$d/.common.git" "$hash" "$xapian_common_clone_url"
559 ln -sf .common.git/xapian-core/common "$d/common"
562 esac
564 echo "Bootstrapping \`$module'"
565 [ -f "$d/preautoreconf" ] && "$d/preautoreconf"
567 # If we have a custom INSTALL file, preserve it since autoreconf insists on
568 # replacing INSTALL with "generic installation instructions" when --force
569 # is used. Be careful to replace it if autoreconf fails.
570 if [ -f "$d/INSTALL" ] ; then
571 if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
573 else
574 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
578 autoreconf_rc=
579 if [ swig = "$module" ] ; then
580 # SWIG provides its own bootstrapping script.
581 curdir=`pwd`
582 cd "$d"
583 ./autogen.sh || autoreconf_rc=$?
584 cd "$curdir"
585 # Use the uninstalled wrapper for the in-tree copy of SWIG.
586 intree_swig=yes
587 else
588 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
589 # (but it doesn't check for -i).
591 # Use --force so that we update files if autoconf, automake, or libtool
592 # has been upgraded.
593 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
595 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
596 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
598 if [ -n "$autoreconf_rc" ] ; then
599 exit $autoreconf_rc
601 for f in config.guess config.sub ; do
602 if [ -f "$d/$f" ] ; then
603 update_config "config/$f" "$d/$f"
605 done
606 modules="$modules $module"
607 done
609 # Produce an absolute path to srcdir.
610 srcdir_abs=`pwd`
612 # Generate the top-level configure script.
613 rm -f configure.tmp
614 cat <<TOP_OF_CONFIGURE > configure.tmp
615 #!/bin/sh
616 # configure each submodule in a xapian source tree
617 # Generated by Xapian top-level bootstrap script.
618 #$copyright
619 trap 'echo "configure failed"' EXIT
620 set -e
622 srcdir="$srcdir_abs"
623 modules="$modules"
625 TOP_OF_CONFIGURE
627 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
628 # Produced escaped version of command suitable for pasting back into sh
629 cmd=$0
630 for a ; do
631 case $a in
632 *[^-A-Za-z0-9_+=:@/.,]*)
633 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
634 cmd="$cmd $esc_a" ;;
636 cmd="$cmd $a" ;;
637 esac
638 done
640 here=`pwd`
641 MIDDLE_OF_CONFIGURE
643 vars=
644 if [ yes = "$intree_swig" ] ; then
645 # We want the path to SWIG to point into srcdir, which isn't known until
646 # configure-time, so we need to expand $here in configure.
647 vars=' SWIG=$here/swig/preinst-swig'
648 elif [ -n "$SWIG" ] ; then
649 # User specified SWIG in environment, e.g. with:
650 # SWIG=/opt/swig/bin/swig ./bootstrap
651 vars=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
653 for tool in $autotools ; do
654 eval "val=\$$tool"
655 if [ -n "$val" ] ; then
656 echo ': ${'"$tool='$val'"'}' >> configure.tmp
657 echo "export $tool" >> configure.tmp
658 vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
660 done
661 if [ -n "$vars" ] ; then
662 # $vars will always have a leading space.
663 echo "set$vars "'"$@"' >> configure.tmp
666 cat <<'END_OF_CONFIGURE' >> configure.tmp
667 dirs=
668 revdirs=
669 XAPIAN_CONFIG=$here/xapian-core/xapian-config
670 for d in $modules ; do
671 if [ "$here" = "$srcdir" ] ; then
672 configure=./configure
673 configure_from_here=$d/configure
674 else
675 configure=$srcdir/$d/configure
676 configure_from_here=$configure
678 if [ -f "$configure_from_here" ] ; then
679 if [ -d "$d" ] ; then : ; else
680 case $d in
681 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
682 esac
683 mkdir "$d"
685 echo "Configuring \`$d'"
686 # Use a shared config.cache for speed and to save a bit of diskspace, but
687 # don't share it with SWIG just in case it manages to probe and cache
688 # different answers (e.g. because it uses a C compiler).
689 case $d in
690 swig)
691 case "$*" in
692 *--host=*|*--host" "*)
693 # We're cross-building, but SWIG needs to be built natively.
694 swig_configure_args=
695 skip=
696 for arg in "$@" ; do
697 if [ -n "$skip" ] ; then
698 skip=
699 continue
701 case $arg in
702 --host=*)
703 # Drop --host=xxx
704 continue ;;
705 --host)
706 # Drop --host xxx
707 skip=1
708 continue ;;
709 CC=*|CXX=*)
710 # Drop CC=xxx or CXX=xxx
711 continue ;;
712 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
713 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
714 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
716 SWIG=*)
717 # Drop SWIG=xxx - not useful and could cause problems.
718 continue ;;
719 esac
720 swig_configure_args="$swig_configure_args "\'`echo "x$arg"|sed "s/^x//;s/'/'\\\\\\\\''/g"`\'
721 done
722 # Also handle compilers specified in environment variables. We can
723 # just reassign them unconditionally as CC and CXX are ignored if
724 # empty.
725 cd "$d" && CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD "$configure" `eval echo $swig_configure_args`
728 cd "$d" && "$configure" ${1+"$@"}
730 esac
732 xapian-core)
733 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
735 xapian-applications/omega)
736 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include" LDFLAGS="-L$srcdir/INST/lib" ${1+"$@"}
739 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
741 esac
742 cd "$here"
743 dirs="$dirs $d"
744 revdirs="$d $revdirs"
746 done
748 case " $* " in
749 *" --help "*|*" --version "*)
750 # Don't generate Makefile if --help or --version specified.
751 trap - EXIT
752 exit 0
754 esac
756 rm -f Makefile.tmp
757 cat <<EOF > Makefile.tmp
758 # Makefile generated by:
759 CONFIGURE_COMMAND := $cmd
761 if [ "$srcdir" != . ] ; then
762 cat <<EOF >> Makefile.tmp
764 VPATH = $srcdir
767 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
768 for target in $targets ; do
769 echo
770 echo "$target:"
771 case $target in
772 uninstall|*clean)
773 # When uninstalling or cleaning, process directories in reverse order, so
774 # that we process a directory after any directories which might use it.
775 list=$revdirs ;;
777 list=$dirs ;;
778 esac
779 for d in $list ; do
780 case $d,$target in
781 swig,install*|swig,uninstall)
782 # Nothing to do with swig when installing/uninstalling.
784 swig,dist|swig,check|swig,distcheck|swig,all)
785 # Need to ensure swig is built before "make dist", "make check", etc.
786 echo " cd $d && \$(MAKE)" ;;
787 swig,mostlyclean)
788 echo " cd $d && \$(MAKE) clean" ;;
789 xapian-bindings,distcheck)
790 # FIXME: distcheck doesn't currently work for xapian-bindings because
791 # xapian-core isn't installed.
792 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
794 echo " cd $d && \$(MAKE) $target" ;;
795 esac
796 done
797 case $target in
798 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
799 esac
800 done >> Makefile.tmp
801 cat <<EOF >> Makefile.tmp
803 recheck:
804 \$(CONFIGURE_COMMAND)
806 Makefile: $srcdir/configure
807 \$(CONFIGURE_COMMAND)
809 $srcdir/configure: \\
810 END_OF_CONFIGURE
812 : > configure.tmp2
814 # We want to rerun bootstrap if a series file changes (patch added or removed)
815 # or an existing patch changes. Since we always have an series file (even if
816 # it is empty), this also handles us adding the first patch for something.
817 patches=
818 for d in patches/* ; do
819 series=$d/series
820 echo "$series:" >> configure.tmp2
821 cat << END
822 $series\\\\
824 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
825 while read p ; do
826 patch=$d/$p
827 cat << END
828 $patch\\\\
830 # Because there's a pipeline, this is a subshell, so use a temporary file
831 # rather than a variable to compile a list of patches to use below.
832 echo "$patch:" >> configure.tmp2
833 done
834 done >> configure.tmp
836 cat <<'END_OF_CONFIGURE' >> configure.tmp
837 $srcdir/bootstrap
838 $srcdir/bootstrap
840 .PHONY: $targets recheck
842 # Dummy dependencies to allow removing patches we no longer need.
843 END_OF_CONFIGURE
845 cat configure.tmp2 >> configure.tmp
847 cat <<'END_OF_CONFIGURE' >> configure.tmp
849 mv -f Makefile.tmp Makefile
850 trap - EXIT
851 echo "Configured successfully - now run \"${MAKE-make}\""
852 END_OF_CONFIGURE
854 rm -f configure.tmp2
856 chmod +x configure.tmp
857 mv -f configure.tmp configure
859 # git defaults to showing 7 character abbreviated hashes if that's enough to be
860 # unique for a particular commit. But you can't paste these into trac as it
861 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
862 # need 9 characters to be unique across all of Xapian at the time of writing,
863 # and 12 for the Linux kernel currently (a much larger number of objects than
864 # Xapian). 12 is a manageable length and decently future-proof, so let's use
865 # that.
866 core_abbrev_recommended=12
867 core_abbrev=`git config --get core.abbrev||:`
868 if [ -z "$core_abbrev" ] ; then
869 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
870 git config --local core.abbrev "$core_abbrev_recommended"
871 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
872 if [ -z "`git config --local core.abbrev`" ] ; then
873 # Set globally to < $core_abbrev_recommended, override in this repo.
874 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
875 git config --local core.abbrev "$core_abbrev_recommended"
876 else
877 # Just warn.
878 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
882 trap - EXIT
883 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""