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