]> git.ipfire.org Git - thirdparty/squid.git/blob - bootstrap.sh
Merge from trunk
[thirdparty/squid.git] / bootstrap.sh
1 #!/bin/sh
2 # Used to setup the configure.in, autoheader and Makefile.in's if configure
3 # has not been generated. This script is only needed for developers when
4 # configure has not been run, or if a Makefile.am in a non-configured directory
5 # has been updated
6
7 # Autotool versions preferred. To override either edit the script
8 # to match the versions you want to use, or set the variables on
9 # the command line like "env acver=.. amver=... ./bootstrap.sh"
10 acversions="${acver:-2.63 2.62 2.61}"
11 amversions="${amver:-1.10 1.9 1.7 1.6 1.5}"
12 ltversions="${ltver:-1.5 1.4}"
13
14 check_version()
15 {
16 eval $2 --version 2>/dev/null | grep -i "$1.*$3" >/dev/null
17 }
18
19 find_version()
20 {
21 tool=$1
22 found="NOT_FOUND"
23 shift
24 versions="$*"
25 for version in $versions; do
26 for variant in "" "-${version}" "`echo $version | sed -e 's/\.//g'`"; do
27 if check_version $tool ${tool}${variant} $version; then
28 found="${variant}"
29 break
30 fi
31 done
32 if [ "x$found" != "xNOT_FOUND" ]; then
33 break
34 fi
35 done
36 if [ "x$found" = "xNOT_FOUND" ]; then
37 echo "WARNING: Cannot find $tool version $versions" >&2
38 echo "Trying `$tool --version | head -1`" >&2
39 found=""
40 fi
41 echo $found
42 }
43
44 bootstrap() {
45 if "$@"; then
46 true # Everything OK
47 else
48 echo "$1 failed"
49 echo "Autotool bootstrapping failed. You will need to investigate and correct" ;
50 echo "before you can develop on this source tree"
51 exit 1
52 fi
53 }
54
55 bootstrap_libtoolize() {
56 ltver=$1
57
58 # TODO: when we have libtool2, tell libtoolize where to put its files
59 # instead of manualy moving files from ltdl to lib/libLtdl
60 if egrep -q '^[[:space:]]*AC_LIBLTDL_' configure.in
61 then
62 if libtoolize$ltver --help | grep -q -- --ltdl.=; then
63 ltdl="--ltdl=lib/libLtdl"
64 else
65 ltdl="--ltdl"
66 copy_libltdl=1
67 fi
68 else
69 ltdl=""
70 fi
71
72 bootstrap libtoolize$ltver $ltdl --force --copy --automake
73
74 # customize generated libltdl, if any
75 if test -d libltdl && [ $copy_libltdl ]
76 then
77 src=libltdl
78
79 # do not bundle with the huge standard license text
80 rm -fv $src/COPYING.LIB
81 makefile=$src/Makefile.in
82 sed 's/COPYING.LIB/ /g' $makefile > $makefile.new;
83 chmod u+w $makefile
84 mv $makefile.new $makefile
85 chmod u-w $makefile
86
87 dest=lib/libLtdl
88 # move $src to $dest
89 if test -d $dest # already exists
90 then
91 echo "Updating $dest from $src."
92 chmod u+w $dest/*
93 mv $src/* $dest/
94 rmdir $src
95 else
96 echo "Creating $dest from $src."
97 mv $src $dest
98 fi
99 fi
100 }
101
102 # Adjust paths of required autool packages
103 amver=`find_version automake ${amversions}`
104 acver=`find_version autoconf ${acversions}`
105 ltver=`find_version libtool ${ltversions}`
106
107 # Set environment variable to tell automake which autoconf to use.
108 AUTOCONF="autoconf${acver}" ; export AUTOCONF
109
110 echo "automake : $amver"
111 echo "autoconfg: $acver"
112 echo "libtool : $ltver"
113
114 for dir in \
115 "" \
116 lib/libTrie \
117 helpers/negotiate_auth/squid_kerb_auth
118 do
119 if [ -z "$dir" ] || [ -d $dir ]; then
120 if (
121 echo "Bootstrapping $dir"
122 cd ./$dir
123 if [ -n "$dir" ] && [ -f bootstrap.sh ]; then
124 ./bootstrap.sh
125 elif [ ! -f $dir/configure ]; then
126 # Make sure cfgaux exists
127 mkdir -p cfgaux
128
129 # Bootstrap the autotool subsystems
130 bootstrap aclocal$amver
131 bootstrap autoheader$acver
132 bootstrap_libtoolize $ltver
133 bootstrap automake$amver --foreign --add-missing --copy -f
134 bootstrap autoconf$acver --force
135 fi ); then
136 : # OK
137 else
138 exit 1
139 fi
140 fi
141 done
142
143 # Fixup autoconf recursion using --silent/--quiet option
144 # autoconf should inherit this option whe recursing into subdirectories
145 # but it currently doesn't for some reason.
146 if ! grep "configure_args --quiet" configure >/dev/null; then
147 echo "Fixing configure recursion"
148 ed -s configure <<'EOS' >/dev/null || true
149 /ac_sub_configure_args=/
150 +1
151 i
152 # Add --quiet option if used
153 test "$silent" = yes &&
154 ac_sub_configure_args="$ac_sub_configure_args --quiet"
155 .
156 w
157 EOS
158 fi
159
160 echo "Autotool bootstrapping complete."