[chert] Fix potential SEGV with corrupt value stats
[xapian.git] / bootstrap
blob48c8f5a5c2786b8446d4a0a22a5dec42d9504aff
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 basename=$package-$2
81 ext=$3
82 checksum=$4
83 if [ "$ext" = "tar.xz" ] ; then
84 if [ -z "$xz_ok" ] ; then
85 if ${XZ-xz} --version > /dev/null 2>&1 ; then
86 xz_ok=1
87 else
88 xz_ok=0
91 if [ "$xz_ok" = 0 ] ; then
92 shift 2
93 ext=$3
94 checksum=$4
97 if [ "$ext" = "tar.bz2" ] ; then
98 if [ -z "$bz2_ok" ] ; then
99 # bzip2 --version doesn't exit with code 0 in upstream version (though
100 # Debian at least patch this bug), so use --help to check it.
101 if bzip2 --help > /dev/null 2>&1 ; then
102 bz2_ok=1
103 else
104 bz2_ok=0
107 if [ "$bz2_ok" = 0 ] ; then
108 shift 2
109 ext=$3
110 checksum=$4
113 tarball=$basename.$ext
114 case $basename in
115 *[24680][a-z]) basename=`echo "$basename"|sed 's/[a-z]$//'` ;;
116 esac
118 # Create the stamp file in INST so that rerunning bootstrap after
119 # "rm -rf INST" recovers nicely.
120 stamp=../INST/$package.stamp
122 # Download the tarball if required.
123 if [ ! -f "$tarball" ] ; then
124 if [ -z "$FETCH_URL_TOOL" ] ; then
125 if ${WGET-wget} --version > /dev/null 2>&1 ; then
126 FETCH_URL_TOOL="${WGET-wget} -O-"
127 elif ${CURL-curl} --version > /dev/null 2>&1 || [ "$?" = 2 ] ; then
128 # curl --version exits with code 2.
129 # -L is needed to follow HTTP redirects.
130 FETCH_URL_TOOL="${CURL-curl} -L"
131 elif ${LWP_REQUEST-lwp-request} -v > /dev/null 2>&1 || [ "$?" = 9 -o "$?" = 255 ] ; then
132 # lwp-request -v exits with code 9 (5.810) or 255 (6.03)
133 FETCH_URL_TOOL="${LWP_REQUEST-lwp-request} -mGET"
134 else
135 cat <<END >&2
136 Neither wget nor curl nor lwp-request found - install one of them or if already
137 installed, set WGET, CURL or LWP_REQUEST to the full path. Alternatively,
138 download $url
139 to directory `pwd`
140 then rerun this script.
142 exit 1
145 case $basename in
146 file-*)
147 if [ "$use_ftp" = yes ] ; then
148 url="ftp://ftp.astron.com/pub/file/$tarball"
149 else
150 url="http://fossies.org/unix/misc/$tarball"
151 fi ;;
152 *[13579][a-z])
153 # GNU alpha release
154 if [ "$use_ftp" = yes ] ; then
155 url="ftp://alpha.gnu.org/gnu/$package/$tarball"
156 else
157 url="http://alpha.gnu.org/gnu/$package/$tarball"
158 fi ;;
160 if [ "$use_ftp" = yes ] ; then
161 url="ftp://ftp.gnu.org/gnu/$package/$tarball"
162 else
163 url="http://ftpmirror.gnu.org/$package/$tarball"
164 fi ;;
165 esac
166 rm -f download.tmp
167 echo "Downloading <$url>"
168 $FETCH_URL_TOOL "$url" > download.tmp && mv download.tmp "$tarball"
171 if [ -f "$stamp" ] ; then
172 find_stdout=`find "$tarball" ../patches/"$package"/* -newer "$stamp" -print 2> /dev/null||true`
173 else
174 find_stdout=force
177 if [ -n "$find_stdout" ] ; then
178 # Verify the tarball's checksum before building it.
179 check_sha1sum "$checksum" "$tarball"
181 # Remove tarballs of other versions.
182 for f in "$package"-* ; do
183 [ "$f" = "$tarball" ] || rm -rf "$f"
184 done
186 case $ext in
187 tar.xz)
188 ${XZ-xz} -dc "$tarball"| tar xf - ;;
189 tar.bz2)
190 bzip2 -dc "$tarball"| tar xf - ;;
192 gzip -dc "$tarball"| tar xf - ;;
193 esac
195 cd "$basename"
197 if [ ! -f "../../patches/$package/series" ] ; then
198 cat <<END >&2
199 No patch series file 'patches/$package/series' - if there are no patches,
200 this should just be an empty file.
202 exit 1
204 echo "Applying patches from $package/series"
205 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "../../patches/$package/series" | \
206 while read p ; do
207 echo "Applying patch $package/$p"
208 patch -p1 < "../../patches/$package/$p"
209 done
211 if test -n "$AUTOCONF" ; then
212 ./configure --prefix "$instdir" AUTOCONF="$AUTOCONF"
213 else
214 ./configure --prefix "$instdir"
216 make
217 make install
218 cd ..
219 rm -rf "$basename"
221 touch "$stamp"
225 handle_git_external() {
226 path=$1
227 if [ ! -f "$path/.nobootstrap" ] ; then
228 rev=$2
229 url=$3
230 if [ ! -d "$path" ] ; then
231 git clone --no-checkout -- "$url" "$path"
232 elif (cd "$path" && git reflog "$rev" -- 2>/dev/null) ; then
233 : # Already have that revision locally
234 else
235 (cd "$path" && git fetch)
237 (cd "$path" && git checkout "$rev")
241 update_config() {
242 from=$1
243 to=$2
244 ts_from=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$from"`
245 ts_to=`perl -ne '/^timestamp=(\W?)([-\d]+)$1/ and do {$_=$2;y/-//d;print;exit}' "$to"`
246 if [ "$ts_from" -gt "$ts_to" ] ; then
247 echo "Updating $to ($ts_to) with $from ($ts_from)"
248 # rm first in case the existing file is a symlink.
249 rm -f "$to"
250 cp "$from" "$to"
254 curdir=`pwd`
256 # cd to srcdir if we aren't already there.
257 srcdir=`echo "$0"|sed 's!/*[^/]*$!!'`
258 case $srcdir in
259 ""|.)
260 srcdir=. ;;
262 cd "$srcdir" ;;
263 esac
265 # Commit hash to pass to handle_git_external for swig.
266 swig_git_commit_hash=d21bb11153bd46c9eae124c13322add3e0df9cee
268 # Commit hashes to use for common in omega and letor respectively:
269 omega_common_commit_hash=bddcf54435286b0363efff94f22529093e85fc89
270 letor_common_commit_hash=bddcf54435286b0363efff94f22529093e85fc89
272 if [ ! -d .git ] ; then
273 echo "$0: No '.git' directory found - this script should be run from a"
274 echo "git repo cloned from git://git.xapian.org/xapian or a mirror of it"
275 exit 1
278 for emptydir in xapian-applications/omega/m4 xapian-bindings/m4 xapian-letor/m4 ; do
279 if test -d "$emptydir" ; then
281 else
282 parent=`echo "$emptydir"|sed 's,/[^/]*$,,'`
283 if test -d "$parent" ; then
284 mkdir "$emptydir"
287 done
289 if [ -f .git/info/exclude ] ; then
290 sed '/^\(swig\|xapian-applications\/omega\/common$\)/d' .git/info/exclude > .git/info/exclude~
291 else
292 [ -d .git/info ] || mkdir .git/info
294 cat <<END >> .git/info/exclude~
295 swig
296 xapian-applications/omega/common
297 xapian-letor/common
299 if [ -f .git/info/exclude ] &&
300 cmp -s .git/info/exclude~ .git/info/exclude ; then
301 rm .git/info/exclude~
302 else
303 mv .git/info/exclude~ .git/info/exclude
306 # If this tree is checked out from the github mirror, use the same access
307 # method for other things checked out from github (e.g. swig) so we avoid
308 # firewall issues. If there's no default remote, the git config command
309 # will exit with status 1, so ignore that failure.
310 origin_url=`git config remote.origin.url||:`
311 case $origin_url in
312 *[@/]github.com[:/]*)
313 github_base_url=`echo "X$origin_url"|sed 's/^X//;s!\([@/]github.com[:/]\).*!\1!'` ;;
315 github_base_url=https://github.com/ ;;
316 esac
317 swig_origin_url=${github_base_url}swig/swig.git
319 if [ -z "$XAPIAN_COMMON_CLONE_URL" ] ; then
320 xapian_common_clone_url=.
321 else
322 xapian_common_clone_url=$XAPIAN_COMMON_CLONE_URL
325 # Prefer http downloads as they are more likely to work through firewalls.
326 use_ftp=no
327 if [ "$1" = "--ftp" ] ; then
328 shift
329 use_ftp=yes
332 if [ "$1" = "--without-autotools" ] ; then
333 shift
334 else
335 if [ "$1" = "--clean" ] ; then
336 shift
337 rm -rf INST
340 [ -d INST ] || mkdir INST
341 instdir=`pwd`/INST
343 [ -d BUILD ] || mkdir BUILD
344 cd BUILD
346 # The last field is the SHA1 checksum of the tarball.
347 lazy_build autoconf 2.69 \
348 tar.xz e891c3193029775e83e0534ac0ee0c4c711f6d23 \
349 tar.gz 562471cbcb0dd0fa42a76665acf0dbb68479b78a
350 AUTOCONF=$instdir/bin/autoconf \
351 lazy_build automake 1.15 \
352 tar.xz c279b35ca6c410809dac8ade143b805fb48b7655 \
353 tar.gz b5a840c7ec4321e78fdc9472e476263fa6614ca1
354 lazy_build libtool 2.4.6 \
355 tar.xz 3e7504b832eb2dd23170c91b6af72e15b56eb94e \
356 tar.gz 25b6931265230a06f0fc2146df64c04e5ae6ec33
357 if [ "$1" = "--deps=libmagic" ] ; then
358 shift
359 lazy_build file 5.25 \
360 tar.gz fea78106dd0b7a09a61714cdbe545135563e84bd
363 for v in $autotools ; do
364 tool=`echo "$v"|tr A-Z a-z`
365 eval "$v=\"\$instdir\"/bin/$tool;export $v"
366 done
368 cd ..
371 case `${LIBTOOLIZE-libtoolize} --version` in
373 echo "${LIBTOOLIZE-libtoolize} not found"
374 exit 1 ;;
375 "libtoolize (GNU libtool) 1.4.*")
376 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.4 which is too old - libtool 2.2 is required."
377 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
378 exit 1 ;;
379 "libtoolize (GNU libtool) 1.5.*")
380 echo "${LIBTOOLIZE-libtoolize} is from libtool 1.5 which is too old - libtool 2.2 is required."
381 echo "If you have both installed, set LIBTOOLIZE to point to the correct version."
382 exit 1 ;;
383 esac
385 ACLOCAL="${ACLOCAL-aclocal} -I `pwd`/xapian-core/m4-macros"
386 export ACLOCAL
388 intree_swig=no
389 modules=
390 for module in ${@:-xapian-core xapian-applications/omega swig xapian-bindings xapian-letor} ; do
391 d=$module
392 if [ "$d" = swig ] ; then
393 if [ -f "xapian-bindings/.nobootstrap" ] ; then
394 # No point bootstrapping SWIG if we aren't going to use it.
395 echo "Skipping '$d' due to presence of 'xapian-bindings/.nobootstrap'."
396 continue
398 handle_git_external swig "$swig_git_commit_hash" "$swig_origin_url"
400 if [ -f "$d/configure.ac" -o -f "$d/configure.in" ] ; then
402 else
403 # Skip any directories we can't bootstrap.
404 continue
406 if [ -f "$d/.nobootstrap" ] ; then
407 # Report why to save head scratching when someone forgets they created
408 # a .nobootstrap file.
409 echo "Skipping '$module' due to presence of '$d/.nobootstrap'."
410 continue
412 case $d in
413 xapian-applications/omega|xapian-letor)
414 # If someone's created a directory for common, leave it be.
415 if [ -h "$d/common" ] || [ ! -d "$d/common" ] ; then
416 # Pick omega_common_commit_hash or letor_common_commit_hash:
417 var=`echo "$d"|sed 's!.*[-/]!!g'`_common_commit_hash
418 hash=`eval echo \\\$"$var"`
419 handle_git_external "$d/.common.git" "$hash" "$xapian_common_clone_url"
420 ln -sf .common.git/xapian-core/common "$d/common"
423 esac
425 echo "Bootstrapping \`$module'"
426 [ -f "$d/preautoreconf" ] && "$d/preautoreconf"
428 # If we have a custom INSTALL file, preserve it since autoreconf insists on
429 # replacing INSTALL with "generic installation instructions" when --force
430 # is used. Be careful to replace it if autoreconf fails.
431 if [ -f "$d/INSTALL" ] ; then
432 if grep 'generic installation instructions' "$d/INSTALL" >/dev/null 2>&1 ; then
434 else
435 mv -f "$d/INSTALL" "$d/INSTALL.preserved-by-bootstrap"
439 autoreconf_rc=
440 if [ swig = "$module" ] ; then
441 # SWIG provides its own bootstrapping script.
442 curdir=`pwd`
443 cd "$d"
444 ./autogen.sh || autoreconf_rc=$?
445 cd "$curdir"
446 # Use the uninstalled wrapper for the in-tree copy of SWIG.
447 intree_swig=yes
448 else
449 # Use --install as debian's autoconf wrapper uses 2.5X if it sees it
450 # (but it doesn't check for -i).
452 # Use --force so that we update files if autoconf, automake, or libtool
453 # has been upgraded.
454 ${AUTORECONF-autoreconf} --install --force "$d" || autoreconf_rc=$?
456 if [ -f "$d/INSTALL.preserved-by-bootstrap" ] ; then
457 mv -f "$d/INSTALL.preserved-by-bootstrap" "$d/INSTALL"
459 if [ -n "$autoreconf_rc" ] ; then
460 exit $autoreconf_rc
462 for f in config.guess config.sub ; do
463 if [ -f "$d/$f" ] ; then
464 update_config "config/$f" "$d/$f"
466 done
467 modules="$modules $module"
468 done
470 # Produce an absolute path to srcdir.
471 srcdir_abs=`pwd`
473 # Generate the top-level configure script.
474 rm -f configure.tmp
475 cat <<TOP_OF_CONFIGURE > configure.tmp
476 #!/bin/sh
477 # configure each submodule in a xapian source tree
478 # Generated by Xapian top-level bootstrap script.
479 #$copyright
480 trap 'echo "configure failed"' EXIT
481 set -e
483 srcdir="$srcdir_abs"
484 modules="$modules"
486 TOP_OF_CONFIGURE
488 cat <<'MIDDLE_OF_CONFIGURE' >> configure.tmp
489 # Produced escaped version of command suitable for pasting back into sh
490 cmd=$0
491 for a ; do
492 case $a in
493 *[^-A-Za-z0-9_+=:@/.,]*)
494 esc_a=`echo "$a"|sed 's!\([^-A-Za-z0-9_+=:@/.,]\)!\\\\\\1!g'`
495 cmd="$cmd $esc_a" ;;
497 cmd="$cmd $a" ;;
498 esac
499 done
501 here=`pwd`
502 MIDDLE_OF_CONFIGURE
504 vars=
505 if [ yes = "$intree_swig" ] ; then
506 # We want the path to SWIG to point into srcdir, which isn't known until
507 # configure-time, so we need to expand $here in configure.
508 vars=' SWIG=$here/swig/preinst-swig'
509 elif [ -n "$SWIG" ] ; then
510 # User specified SWIG in environment, e.g. with:
511 # SWIG=/opt/swig/bin/swig ./bootstrap
512 vars=" SWIG='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
514 for tool in $autotools ; do
515 eval "val=\$$tool"
516 if [ -n "$val" ] ; then
517 echo ': ${'"$tool='$val'"'}' >> configure.tmp
518 echo "export $tool" >> configure.tmp
519 vars="$vars $tool='"`echo "$val"|sed 's/\(['"\\'"']\)/\\\1/g'`"'"
521 done
522 if [ -n "$vars" ] ; then
523 # $vars will always have a leading space.
524 echo "set$vars "'"$@"' >> configure.tmp
527 cat <<'END_OF_CONFIGURE' >> configure.tmp
528 dirs=
529 revdirs=
530 XAPIAN_CONFIG=$here/xapian-core/xapian-config
531 for d in $modules ; do
532 if [ "$here" = "$srcdir" ] ; then
533 configure=./configure
534 configure_from_here=$d/configure
535 else
536 configure=$srcdir/$d/configure
537 configure_from_here=$configure
539 if [ -f "$configure_from_here" ] ; then
540 if [ -d "$d" ] ; then : ; else
541 case $d in
542 xapian-applications/*) [ -d xapian-applications ] || mkdir xapian-applications ;;
543 esac
544 mkdir "$d"
546 echo "Configuring \`$d'"
547 # Use a shared config.cache for speed and to save a bit of diskspace, but
548 # don't share it with SWIG just in case it manages to probe and cache
549 # different answers (e.g. because it uses a C compiler).
550 case $d in
551 swig)
552 case "$*" in
553 *--host=*|*--host" "*)
554 # We're cross-building, but SWIG needs to be built natively.
555 swig_configure_args=
556 skip=
557 for arg in "$@" ; do
558 if [ -n "$skip" ] ; then
559 skip=
560 continue
562 case $arg in
563 --host=*)
564 # Drop --host=xxx
565 continue ;;
566 --host)
567 # Drop --host xxx
568 skip=1
569 continue ;;
570 CC=*|CXX=*)
571 # Drop CC=xxx or CXX=xxx
572 continue ;;
573 CC_FOR_BUILD=*|CXX_FOR_BUILD=*)
574 # CC_FOR_BUILD=xxx -> CC=xxx; CXX_FOR_BUILD=xxx -> CXX=xxx
575 arg=`echo "$arg"|sed 's/_FOR_BUILD//'`
577 SWIG=*)
578 # Drop SWIG=xxx - not useful and could cause problems.
579 continue ;;
580 esac
581 swig_configure_args="$swig_configure_args "\'`echo "x$arg"|sed "s/^x//;s/'/'\\\\\\\\''/g"`\'
582 done
583 # Also handle compilers specified in environment variables. We can
584 # just reassign them unconditionally as CC and CXX are ignored if
585 # empty.
586 cd "$d" && CC=$CC_FOR_BUILD CXX=$CXX_FOR_BUILD "$configure" `eval echo $swig_configure_args`
589 cd "$d" && "$configure" ${1+"$@"}
591 esac
593 xapian-core)
594 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" ${1+"$@"}
596 xapian-applications/omega)
597 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking XAPIAN_CONFIG="$XAPIAN_CONFIG" CPPFLAGS="-I$srcdir/INST/include" LDFLAGS="-L$srcdir/INST/lib" ${1+"$@"}
600 cd "$d" && "$configure" --enable-maintainer-mode --disable-option-checking --cache-file="$here/config.cache" XAPIAN_CONFIG="$XAPIAN_CONFIG" ${1+"$@"}
602 esac
603 cd "$here"
604 dirs="$dirs $d"
605 revdirs="$d $revdirs"
607 done
609 case " $* " in
610 *" --help "*|*" --version "*)
611 # Don't generate Makefile if --help or --version specified.
612 trap - EXIT
613 exit 0
615 esac
617 rm -f Makefile.tmp
618 cat <<EOF > Makefile.tmp
619 # Makefile generated by:
620 CONFIGURE_COMMAND := $cmd
622 if [ "$srcdir" != . ] ; then
623 cat <<EOF >> Makefile.tmp
625 VPATH = $srcdir
628 targets='all install uninstall install-strip clean distclean mostlyclean maintainer-clean dist check distcheck'
629 for target in $targets ; do
630 echo
631 echo "$target:"
632 case $target in
633 uninstall|*clean)
634 # When uninstalling or cleaning, process directories in reverse order, so
635 # that we process a directory after any directories which might use it.
636 list=$revdirs ;;
638 list=$dirs ;;
639 esac
640 for d in $list ; do
641 case $d,$target in
642 swig,install*|swig,uninstall)
643 # Nothing to do with swig when installing/uninstalling.
645 swig,dist|swig,check|swig,distcheck|swig,all)
646 # Need to ensure swig is built before "make dist", "make check", etc.
647 echo " cd $d && \$(MAKE)" ;;
648 swig,mostlyclean)
649 echo " cd $d && \$(MAKE) clean" ;;
650 xapian-bindings,distcheck)
651 # FIXME: distcheck doesn't currently work for xapian-bindings because
652 # xapian-core isn't installed.
653 echo " cd $d && \$(MAKE) check && \$(MAKE) dist" ;;
655 echo " cd $d && \$(MAKE) $target" ;;
656 esac
657 done
658 case $target in
659 distclean|maintainer-clean) echo " rm -f Makefile config.cache" ;;
660 esac
661 done >> Makefile.tmp
662 cat <<EOF >> Makefile.tmp
664 recheck:
665 \$(CONFIGURE_COMMAND)
667 Makefile: $srcdir/configure
668 \$(CONFIGURE_COMMAND)
670 $srcdir/configure: \\
671 END_OF_CONFIGURE
673 : > configure.tmp2
675 # We want to rerun bootstrap if a series file changes (patch added or removed)
676 # or an existing patch changes. Since we always have an series file (even if
677 # it is empty), this also handles us adding the first patch for something.
678 patches=
679 for d in patches/* ; do
680 series=$d/series
681 echo "$series:" >> configure.tmp2
682 cat << END
683 $series\\\\
685 sed -n 's/[ ]*\(#.*\)\?$//;/./p' "$series" |\
686 while read p ; do
687 patch=$d/$p
688 cat << END
689 $patch\\\\
691 # Because there's a pipeline, this is a subshell, so use a temporary file
692 # rather than a variable to compile a list of patches to use below.
693 echo "$patch:" >> configure.tmp2
694 done
695 done >> configure.tmp
697 cat <<'END_OF_CONFIGURE' >> configure.tmp
698 $srcdir/bootstrap
699 $srcdir/bootstrap
701 .PHONY: $targets recheck
703 # Dummy dependencies to allow removing patches we no longer need.
704 END_OF_CONFIGURE
706 cat configure.tmp2 >> configure.tmp
708 cat <<'END_OF_CONFIGURE' >> configure.tmp
710 mv -f Makefile.tmp Makefile
711 trap - EXIT
712 echo "Configured successfully - now run \"${MAKE-make}\""
713 END_OF_CONFIGURE
715 rm -f configure.tmp2
717 chmod +x configure.tmp
718 mv -f configure.tmp configure
720 # git defaults to showing 7 character abbreviated hashes if that's enough to be
721 # unique for a particular commit. But you can't paste these into trac as it
722 # needs at least 8 hex digits to recognise a hex string as a commit hash. You
723 # need 9 characters to be unique across all of Xapian at the time of writing,
724 # and 12 for the Linux kernel currently (a much larger number of objects than
725 # Xapian). 12 is a manageable length and decently future-proof, so let's use
726 # that.
727 core_abbrev_recommended=12
728 core_abbrev=`git config --get core.abbrev||:`
729 if [ -z "$core_abbrev" ] ; then
730 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config"
731 git config --local core.abbrev "$core_abbrev_recommended"
732 elif [ "$core_abbrev" -lt "$core_abbrev_recommended" ] ; then
733 if [ -z "`git config --local core.abbrev`" ] ; then
734 # Set globally to < $core_abbrev_recommended, override in this repo.
735 echo "*** Setting core.abbrev=$core_abbrev_recommended in repo config to override global core.abbrev=$core_abbrev"
736 git config --local core.abbrev "$core_abbrev_recommended"
737 else
738 # Just warn.
739 echo "warning: core.abbrev=$core_abbrev set on this repo, at least $core_abbrev_recommended is recommended"
743 trap - EXIT
744 echo "Bootstrapped successfully - now run \"$srcdir/configure\" and \"${MAKE-make}\""