]> git.draconx.ca Git - upkg.git/blob - bootstrap
Update bootstrapping bits.
[upkg.git] / bootstrap
1 #!/bin/sh
2 #
3 # Copyright © 2011-2012, 2015, 2021-2022 Nick Bowler
4 #
5 # Simple script to get started from a fresh git checkout.
6 #
7 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
8 # This is free software: you are free to do what the fuck you want to.
9 # There is NO WARRANTY, to the extent permitted by law.
10
11 scriptname=$0
12
13 err() { printf '%s: %s\n' "$scriptname" "$*" 1>&2; }
14 die() { err "$@"; exit 1; }
15
16 : ${LIBTOOLIZE=libtoolize}
17 : ${AUTORECONF=autoreconf}
18 : ${AUTOMAKE=automake}
19 : ${GNULIB=gnulib}
20 : ${GIT=git}
21 : ${PERL=perl}
22
23 $GIT submodule update --init || err "Failed to update submodules from git."
24
25 if test -x $GNULIB/gnulib-tool; then
26   $GNULIB/gnulib-tool --update -S || die "Failed to update Gnulib."
27 else
28   err "Gnulib sources are not properly installed in $GNULIB/"
29   cat >&2 <<'EOF'
30
31 To bootstrap this package using an external Gnulib, you can set the GNULIB
32 environment variable to indicate the location of the Gnulib sources.
33 EOF
34
35   test ! -f configure || cat >&2 <<'EOF'
36
37 However, it seems this package is already bootstrapped.  It should not
38 normally be necessary to run this script from a release tarball.
39 EOF
40   exit 1
41 fi
42
43 $PERL common/scripts/fix-gnulib.pl -o lib/gnulib.mk -i lib/gnulib.mk.in \
44   || die "Failed to fixup Gnulib makefile fragment."
45
46 # Frustratingly, libtoolize has changed the name of its nonrecursive ltdl
47 # makefile output, which broke all packages depending on previous documented
48 # behaviour.  Work around the issue by renaming the output.
49 rm -f libltdl/ltdl.mk
50 $LIBTOOLIZE -f || die "Failed to run libtoolize."
51 test ! -f libltdl/Makefile.inc || mv -f libltdl/Makefile.inc libltdl/ltdl.mk.in
52 test ! -f libltdl/ltdl.mk || mv -f libltdl/ltdl.mk libltdl/ltdl.mk.in
53
54 $PERL common/scripts/fix-ltdl.pl -o libltdl/ltdl.mk -i libltdl/ltdl.mk.in \
55         || die "Failed to fixup libltdl makefile fragment."
56
57 # Rewrite if ! ... construts produced by gnulib conditional dependencies
58 # as these fail in heirloom-sh.
59 sed 's/if ! *\(.*gnulib_enabled[^;]*\); then/if \1; then :; else/' \
60   m4/gnulib-comp.m4 >m4/gnulib-comp.m4.new || exit
61 mv -f m4/gnulib-comp.m4.new m4/gnulib-comp.m4 || exit
62
63 # Punt some automake-generated files so that Gentoo's wrapper script doesn't
64 # try to detect the automake version in use.
65 rm -f Makefile.in aclocal.m4
66 LIBTOOLIZE=true $AUTORECONF -fis || exit
67
68 amdir=`$AUTOMAKE --print-libdir`
69 if test -f "$amdir/INSTALL"; then
70   ln -sf "$amdir/INSTALL" INSTALL
71 fi