Use installed autotools if new enough
[xapian.git] / bootstrap
blobdfcad052642e23cf01a86528bfd00bbed5f5a9e4
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 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] [--without-autotools|--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 lazy_build() {
79 package=$1
80 binary=$2
81 version=$3
83 if [ "$always_install" = no ] && [ -n $binary ] ; then
84 # Check if a new enough version is already installed.
85 version_installed=`"$binary" --version|sed '1,1 s/.* //p;d'`
86 # Fast track equality.
87 if [ "$version_installed" = "$version" ] ; then
88 echo "$binary $version_installed installed, exactly what's needed"
89 return 1
91 save_IFS=$IFS
92 IFS=.
93 set x $version_installed
94 shift
95 ok=yes
96 for v in $version ; do
97 shift
98 if [ "$1" != "$v" ] ; then
99 if [ "$1" -lt "$v" ] ; then
100 ok=no
102 break
104 done
105 IFS=$save_IFS
106 if [ "$ok" = yes ] ; then
107 echo "$binary $version_installed installed >= $version required"
108 return 1
112 basename=$package-$version
113 ext=$4
114 checksum=$5
116 if [ "$ext" = "tar.xz" ] ; then
117 if [ -z "$xz_ok" ] ; then
118 if ${XZ-xz} --version > /dev/null 2>&1 ; then
119 xz_ok=1
120 else
121 xz_ok=0
124 if [ "$xz_ok" = 0 ] ; then
125 shift 2
126 ext=$4
127 checksum=$5
130 if [ "$ext" = "tar.bz2" ] ; then
131 if [ -z "$bz2_ok" ] ; then
132 # bzip2 --version doesn't exit with code 0 in upstream version (though
133 # Debian at least patch this bug), so use --help to check it.
134 if bzip2 --help > /dev/null 2>&1 ; then
135 bz2_ok=1
136 else
137 bz2_ok=0
140 if [ "$bz2_ok" = 0 ] ; then
141 shift 2
142 ext=$4
143 checksum=$5
146 tarball=$basename.$ext
147 case $basename in
148 *[24680][a-z]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
149 esac
151 # Create the stamp file in INST so that rerunning bootstrap after
152 # "rm -rf INST" recovers nicely.
153 stamp=../INST/$package.stamp
155 # Download the tarball if required.
156 if [ ! -f "$tarball" ] ; then
157 if [ -z "$FETCH_URL_TOOL" ] ; then
158 if ${WGET-wget} --version > /dev/null 2>&1 ; then
159 FETCH_URL_TOOL="${WGET-wget} -O-"
160 elif ${CURL-curl} --version > /dev/null 2>&1 || [ "$?" = 2 ] ; then
161 # curl --version exits with code 2.
162 # -L is needed to follow HTTP redirects.
163 FETCH_URL_TOOL="${CURL-curl} -L"
164 elif ${LWP_REQUEST-lwp-request} -v > /dev/null 2>&1 || [ "$?" = 9 -o "$?" = 255 ] ; then
165 # lwp-request -v exits with code 9 (5.810) or 255 (6.03)
166 FETCH_URL_TOOL="${LWP_REQUEST-lwp-request} -mGET"
167 else
168 cat <<END >&2
169 Neither wget nor curl nor lwp-request found - install one of them or if already
170 installed, set WGET, CURL or LWP_REQUEST to the full path. Alternatively,
171 download $url
172 to directory `pwd`
173 then rerun this script.
175 exit 1
178 case $basename in
179 file-*)
180 if [ "$use_ftp" = yes ] ; then
181 url="ftp://ftp.astron.com/pub/file/$tarball"
182 else
183 url="http://fossies.org/unix/misc/$tarball"
184 fi ;;
185 *[13579][a-z])
186 # GNU alpha release
187 if [ "$use_ftp" = yes ] ; then
188 url="ftp://alpha.gnu.org/gnu/$package/$tarball"
189 else
190 url="http://alpha.gnu.org/gnu/$package/$tarball"
191 fi ;;
193 if [ "$use_ftp" = yes ] ; then
194 url="ftp://ftp.gnu.org/gnu/$package/$tarball"
195 else
196 url="http://ftpmirror.gnu.org/$package/$tarball"
197 fi ;;
198 esac
199 rm -f download.tmp
200 echo "Downloading <$url>"
201 $FETCH_URL_TOOL "$url" > download.tmp && mv download.tmp "$tarball"
204 if [ -f "$stamp" ] ; then
205 find_stdout=`find "$tarball" ../patches/"$package"/* -newer "$stamp" -print 2> /dev/null||true`
206 else
207 find_stdout=force
210 if [ -n "$find_stdout" ] ; then
211 # Verify the tarball's checksum before building it.
212 check_sha1sum "$checksum" "$tarball"
214 # Remove tarballs of other versions.
215 for f in "$package"-* ; do
216 [ "$f" = "$tarball" ] || rm -rf "$f"
217 done
219 case $ext in
220 tar.xz)
221 ${XZ-xz} -dc "$tarball"| tar xf - ;;
222 tar.bz2)
223 bzip2 -dc "$tarball"| tar xf - ;;
225 gzip -dc "$tarball"| tar xf - ;;
226 esac
228 cd "$basename"
230 if [ ! -f "../../patches/$package/series" ] ; then
231 cat <<END >&2
232 No patch series file 'patches/$package/series' - if there are no patches,
233 this should just be an empty file.
235 exit 1
237 echo "Applying patches from $package/series"
238 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "../../patches/$package/series" | \
239 while read p ; do
240 echo "Applying patch $package/$p"
241 patch -p1 < "../../patches/$package/$p"
242 done
244 if test -n "$AUTOCONF" ; then
245 ./configure --prefix "$instdir" AUTOCONF="$AUTOCONF"
246 else
247 ./configure --prefix "$instdir"
249 make
250 make install
251 cd ..
252 rm -rf "$basename"
254 touch "$stamp"
256 return 0
259 handle_git_external() {
260 path=$1
261 if [ ! -f "$path/.nobootstrap" ] ; then
262 rev=$2
263 url=$3
264 if [ ! -d "$path" ] ; then
265 git clone --no-checkout -- "$url" "$path"
266 elif (cd "$path" && git reflog "$rev" -- 2>/dev/null) ; then
267 : # Already have that revision locally
268 else
269 (cd "$path" && git fetch)
271 (cd "$path" && git checkout "$rev")
275 update_config() {
276 from=$1
277 to=$2
278 ts_from=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$from"`
279 ts_to=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$to"`
280 if [ "$ts_from" -gt "$ts_to" ] ; then
281 echo "Updating $to ($ts_to) with $from ($ts_from)"
282 # rm first in case the existing file is a symlink.
283 rm -f "$to"
284 cp "$from" "$to"
288 curdir=`pwd`
290 # cd to srcdir if we aren't already there.
291 srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
292 case $srcdir in
293 ""|.)
294 srcdir=. ;;
296 cd "$srcdir" ;;
297 esac
299 # Commit hash to pass to handle_git_external for swig.
300 swig_git_commit_hash=d21bb11153bd46c9eae124c13322add3e0df9cee
302 # Commit hashes to use for common in omega and letor respectively:
303 omega_common_commit_hash=bddcf54435286b0363efff94f22529093e85fc89
304 letor_common_commit_hash=bddcf54435286b0363efff94f22529093e85fc89
306 if [ ! -d .git ] ; then
307 echo "$0: No '.git' directory found - this script should be run from a"
308 echo "git repo cloned from git://git.xapian.org/xapian or a mirror of it"
309 exit 1
312 for emptydir in xapian-applications/omega/m4 xapian-bindings/m4 xapian-letor/m4 ; do
313 if test -d "$emptydir" ; then
315 else
316 parent=`echo "$emptydir"|sed 's,/[^/]*$,,'`
317 if test -d "$parent" ; then
318 mkdir "$emptydir"
321 done
323 if [ -f .git/info/exclude ] ; then
324 sed '/^\(swig\|xapian-applications\/omega\/common$\)/d' .git/info/exclude > .git/info/exclude~
325 else
326 [ -d .git/info ] || mkdir .git/info
328 cat <<END >> .git/info/exclude~
329 swig
330 xapian-applications/omega/common
331 xapian-letor/common
333 if [ -f .git/info/exclude ] &&
334 cmp -s .git/info/exclude~ .git/info/exclude ; then
335 rm .git/info/exclude~
336 else
337 mv .git/info/exclude~ .git/info/exclude
340 # If this tree is checked out from the github mirror, use the same access
341 # method for other things checked out from github (e.g. swig) so we avoid
342 # firewall issues. If there's no default remote, the git config command
343 # will exit with status 1, so ignore that failure.
344 origin_url=`git config remote.origin.url||:`
345 case $origin_url in
346 *[@/]github.com[:/]*)
347 github_base_url=`echo "X$origin_url"|sed 's/^X//;s!\([@/]github.com[:/]\).*!\1!'` ;;
349 github_base_url=https://github.com/ ;;
350 esac
351 swig_origin_url=${github_base_url}swig/swig.git
353 if [ -z "$XAPIAN_COMMON_CLONE_URL" ] ; then
354 xapian_common_clone_url=.
355 else
356 xapian_common_clone_url=$XAPIAN_COMMON_CLONE_URL
359 # Set to 'yes' to use ftp URLs where available.
361 # By default we prefer http downloads as they are more likely to work through
362 # firewalls.
363 use_ftp=no
365 # Set to 'yes' to always use a locally installed copy of the autotools.
367 # By default we check for locally installed versions and use them if they are
368 # new enough versions. But e.g. for building releases we want to use a known
369 # set of versions.
370 always_install=no
372 while [ "$#" -gt 0 ] ; do
373 case $1 in
374 --force-local-tools)
375 always_install=yes
376 shift
377 continue
380 --ftp)
381 use_ftp=yes
382 shift
383 continue
386 --clean)
387 rm -rf INST
388 shift
389 continue
392 --without-autotools)
393 echo "Ignoring '$1' - installed versions will be used if new enough"
394 shift
395 continue
399 shift
400 break
404 echo "Unknown option '$1'" 1>&2
405 exit 1
407 esac
408 done
410 [ -d INST ] || mkdir INST
411 instdir=`pwd`/INST
413 [ -d BUILD ] || mkdir BUILD
414 cd BUILD
416 # The last field is the SHA1 checksum of the tarball.
417 if lazy_build autoconf autoconf 2.69 \
418 tar.xz e891c3193029775e83e0534ac0ee0c4c711f6d23 \
419 tar.gz 562471cbcb0dd0fa42a76665acf0dbb68479b78a \
420 ; then
421 AUTOCONF=$instdir/bin/autoconf
422 export AUTOCONF
423 AUTORECONF=$instdir/bin/autoreconf
424 export AUTORECONF
425 AUTOHEADER=$instdir/bin/autoheader
426 export AUTOHEADER
427 AUTOM4TE=$instdir/bin/autom4te
428 export AUTOM4TE
430 if lazy_build automake automake 1.15 \
431 tar.xz c279b35ca6c410809dac8ade143b805fb48b7655 \
432 tar.gz b5a840c7ec4321e78fdc9472e476263fa6614ca1 \
433 ; then
434 ACLOCAL=$instdir/bin/aclocal
435 export ACLOCAL
436 AUTOMAKE=$instdir/bin/automake
437 export AUTOMAKE
439 if lazy_build libtool libtool 2.4.6 \
440 tar.xz 3e7504b832eb2dd23170c91b6af72e15b56eb94e \
441 tar.gz 25b6931265230a06f0fc2146df64c04e5ae6ec33 \
442 ; then
443 LIBTOOLIZE=$instdir/bin/libtoolize
444 export LIBTOOLIZE
446 if [ "$1" = "--deps=libmagic" ] ; then
447 shift
448 lazy_build file '' 5.25 \
449 tar.gz fea78106dd0b7a09a61714cdbe545135563e84bd
452 cd ..
454 case `${LIBTOOLIZE-libtoolize} --version` in
456 echo "${LIBTOOLIZE-libtoolize} not found"
457 exit 1 ;;
458 "libtoolize (GNU libtool) 1.4.*")
459 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
460 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
461 exit 1 ;;
462 "libtoolize (GNU libtool) 1.5.*")
463 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
464 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
465 exit 1 ;;
466 esac
468 ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
469 export ACLOCAL
471 intree_swig=no
472 modules=
473 for module in ${@:-xapian-core xapian-applications/omega swig xapian-bindings} ; do
474 d=$module
475 if [ "$d" = swig ] ; then
476 if [ -f "xapian-bindings/.nobootstrap" ] ; then
477 # No point bootstrapping SWIG if we aren't going to use it.
478 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
479 continue
481 handle_git_external swig "$swig_git_commit_hash" "$swig_origin_url"
483 if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
485 else
486 # Skip any directories we can't bootstrap.
487 continue
489 if [ -f "$d/.nobootstrap" ] ; then
490 # Report why to save head scratching when someone forgets they created
491 # a .nobootstrap file.
492 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
493 continue
495 case $d in
496 xapian-applications/omega|xapian-letor)
497 # If someone's created a directory for common, leave it be.
498 if [ -h "$d/common" ] || [ ! -d "$d/common" ] ; then
499 # Pick omega_common_commit_hash or letor_common_commit_hash:
500 var=`echo "$d"|sed 's!.*[-/]!!g'`_common_commit_hash
501 hash=`eval echo \\\$"$var"`
502 handle_git_external "$d/.common.git" "$hash" "$xapian_common_clone_url"
503 ln -sf .common.git/xapian-core/common "$d/common"
506 esac
508 echo "Bootstrapping \`$module'"
509 [ -f "$d/preautoreconf" ] && "$d/preautoreconf"
511 # If we have a custom INSTALL file, preserve it since autoreconf insists on
512 # replacing INSTALL with "generic installation instructions" when --force
513 # is used. Be careful to replace it if autoreconf fails.
514 if [ -f "$d/INSTALL" ] ; then
515 if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
517 else
518 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
522 autoreconf_rc=
523 if [ swig = "$module" ] ; then
524 # SWIG provides its own bootstrapping script.
525 curdir=`pwd`
526 cd "$d"
527 ./autogen.sh || autoreconf_rc=$?
528 cd "$curdir"
529 # Use the uninstalled wrapper for the in-tree copy of SWIG.
530 intree_swig=yes
531 else
532 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
533 # (but it doesn't check for -i).
535 # Use --force so that we update files if autoconf, automake, or libtool
536 # has been upgraded.
537 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
539 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
540 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
542 if [ -n "$autoreconf_rc" ] ; then
543 exit $autoreconf_rc
545 for f in config.guess config.sub ; do
546 if [ -f "$d/$f" ] ; then
547 update_config "config/$f" "$d/$f"
549 done
550 modules="$modules $module"
551 done
553 # Produce an absolute path to srcdir.
554 srcdir_abs=`pwd`
556 # Generate the top-level configure script.
557 rm -f configure.tmp
558 cat <<TOP_OF_CONFIGURE > configure.tmp
559 #!/bin/sh
560 # configure each submodule in a xapian source tree
561 # Generated by Xapian top-level bootstrap script.
562 #$copyright
563 trap 'echo "configure failed"' EXIT
564 set -e
566 srcdir="$srcdir_abs"
567 modules="$modules"
569 TOP_OF_CONFIGURE
571 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
572 # Produced escaped version of command suitable for pasting back into sh
573 cmd=$0
574 for a ; do
575 case $a in
576 *[^-A-Za-z0-9_+=:@/.,]*)
577 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
578 cmd="$cmd $esc_a" ;;
580 cmd="$cmd $a" ;;
581 esac
582 done
584 here=`pwd`
585 MIDDLE_OF_CONFIGURE
587 vars=
588 if [ yes = "$intree_swig" ] ; then
589 # We want the path to SWIG to point into srcdir, which isn't known until
590 # configure-time, so we need to expand $here in configure.
591 vars=' SWIG=$here/swig/preinst-swig'
592 elif [ -n "$SWIG" ] ; then
593 # User specified SWIG in environment, e.g. with:
594 # SWIG=/opt/swig/bin/swig ./bootstrap
595 vars=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
597 for tool in $autotools ; do
598 eval "val=\$$tool"
599 if [ -n "$val" ] ; then
600 echo ': ${'"$tool='$val'"'}' >> configure.tmp
601 echo "export $tool" >> configure.tmp
602 vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
604 done
605 if [ -n "$vars" ] ; then
606 # $vars will always have a leading space.
607 echo "set$vars "'"$@"' >> configure.tmp
610 cat <<'END_OF_CONFIGURE' >> configure.tmp
611 dirs=
612 revdirs=
613 XAPIAN_CONFIG=$here/xapian-core/xapian-config
614 for d in $modules ; do
615 if [ "$here" = "$srcdir" ] ; then
616 configure=./configure
617 configure_from_here=$d/configure
618 else
619 configure=$srcdir/$d/configure
620 configure_from_here=$configure
622 if [ -f "$configure_from_here" ] ; then
623 if [ -d "$d" ] ; then : ; else
624 case $d in
625 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
626 esac
627 mkdir "$d"
629 echo "Configuring \`$d'"
630 # Use a shared config.cache for speed and to save a bit of diskspace, but
631 # don't share it with SWIG just in case it manages to probe and cache
632 # different answers (e.g. because it uses a C compiler).
633 case $d in
634 swig)
635 case "$*" in
636 *--host=*|*--host" "*)
637 # We're cross-building, but SWIG needs to be built natively.
638 swig_configure_args=
639 skip=
640 for arg in "$@" ; do
641 if [ -n "$skip" ] ; then
642 skip=
643 continue
645 case $arg in
646 --host=*)
647 # Drop --host=xxx
648 continue ;;
649 --host)
650 # Drop --host xxx
651 skip=1
652 continue ;;
653 CC=*|CXX=*)
654 # Drop CC=xxx or CXX=xxx
655 continue ;;
656 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
657 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
658 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
660 SWIG=*)
661 # Drop SWIG=xxx - not useful and could cause problems.
662 continue ;;
663 esac
664 swig_configure_args="$swig_configure_args "\'`echo "x$arg"|sed "s/^x//;s/'/'\\\\\\\\''/g"`\'
665 done
666 # Also handle compilers specified in environment variables. We can
667 # just reassign them unconditionally as CC and CXX are ignored if
668 # empty.
669 cd "$d" && CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD "$configure" `eval echo $swig_configure_args`
672 cd "$d" && "$configure" ${1+"$@"}
674 esac
676 xapian-core)
677 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
679 xapian-applications/omega)
680 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include" LDFLAGS="-L$srcdir/INST/lib" ${1+"$@"}
683 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
685 esac
686 cd "$here"
687 dirs="$dirs $d"
688 revdirs="$d $revdirs"
690 done
692 case " $* " in
693 *" --help "*|*" --version "*)
694 # Don't generate Makefile if --help or --version specified.
695 trap - EXIT
696 exit 0
698 esac
700 rm -f Makefile.tmp
701 cat <<EOF > Makefile.tmp
702 # Makefile generated by:
703 CONFIGURE_COMMAND := $cmd
705 if [ "$srcdir" != . ] ; then
706 cat <<EOF >> Makefile.tmp
708 VPATH = $srcdir
711 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
712 for target in $targets ; do
713 echo
714 echo "$target:"
715 case $target in
716 uninstall|*clean)
717 # When uninstalling or cleaning, process directories in reverse order, so
718 # that we process a directory after any directories which might use it.
719 list=$revdirs ;;
721 list=$dirs ;;
722 esac
723 for d in $list ; do
724 case $d,$target in
725 swig,install*|swig,uninstall)
726 # Nothing to do with swig when installing/uninstalling.
728 swig,dist|swig,check|swig,distcheck|swig,all)
729 # Need to ensure swig is built before "make dist", "make check", etc.
730 echo " cd $d && \$(MAKE)" ;;
731 swig,mostlyclean)
732 echo " cd $d && \$(MAKE) clean" ;;
733 xapian-bindings,distcheck)
734 # FIXME: distcheck doesn't currently work for xapian-bindings because
735 # xapian-core isn't installed.
736 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
738 echo " cd $d && \$(MAKE) $target" ;;
739 esac
740 done
741 case $target in
742 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
743 esac
744 done >> Makefile.tmp
745 cat <<EOF >> Makefile.tmp
747 recheck:
748 \$(CONFIGURE_COMMAND)
750 Makefile: $srcdir/configure
751 \$(CONFIGURE_COMMAND)
753 $srcdir/configure: \\
754 END_OF_CONFIGURE
756 : > configure.tmp2
758 # We want to rerun bootstrap if a series file changes (patch added or removed)
759 # or an existing patch changes. Since we always have an series file (even if
760 # it is empty), this also handles us adding the first patch for something.
761 patches=
762 for d in patches/* ; do
763 series=$d/series
764 echo "$series:" >> configure.tmp2
765 cat << END
766 $series\\\\
768 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
769 while read p ; do
770 patch=$d/$p
771 cat << END
772 $patch\\\\
774 # Because there's a pipeline, this is a subshell, so use a temporary file
775 # rather than a variable to compile a list of patches to use below.
776 echo "$patch:" >> configure.tmp2
777 done
778 done >> configure.tmp
780 cat <<'END_OF_CONFIGURE' >> configure.tmp
781 $srcdir/bootstrap
782 $srcdir/bootstrap
784 .PHONY: $targets recheck
786 # Dummy dependencies to allow removing patches we no longer need.
787 END_OF_CONFIGURE
789 cat configure.tmp2 >> configure.tmp
791 cat <<'END_OF_CONFIGURE' >> configure.tmp
793 mv -f Makefile.tmp Makefile
794 trap - EXIT
795 echo "Configured successfully - now run \"${MAKE-make}\""
796 END_OF_CONFIGURE
798 rm -f configure.tmp2
800 chmod +x configure.tmp
801 mv -f configure.tmp configure
803 # git defaults to showing 7 character abbreviated hashes if that's enough to be
804 # unique for a particular commit. But you can't paste these into trac as it
805 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
806 # need 9 characters to be unique across all of Xapian at the time of writing,
807 # and 12 for the Linux kernel currently (a much larger number of objects than
808 # Xapian). 12 is a manageable length and decently future-proof, so let's use
809 # that.
810 core_abbrev_recommended=12
811 core_abbrev=`git config --get core.abbrev||:`
812 if [ -z "$core_abbrev" ] ; then
813 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
814 git config --local core.abbrev "$core_abbrev_recommended"
815 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
816 if [ -z "`git config --local core.abbrev`" ] ; then
817 # Set globally to < $core_abbrev_recommended, override in this repo.
818 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
819 git config --local core.abbrev "$core_abbrev_recommended"
820 else
821 # Just warn.
822 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
826 trap - EXIT
827 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""