]> git.ipfire.org Git - thirdparty/squid.git/blob - bootstrap.sh
Detect ubuntu-style of naming multiple autoconf versions.
[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.64 2.63 2.62 2.61}"
11 amversions="${amver:-1.11 1.10 1.9}"
12 ltversions="${ltver:-2.2}"
13
14 check_version()
15 {
16 eval $2 --version 2>/dev/null | grep -i "$1.* $3" >/dev/null
17 }
18
19 show_version()
20 {
21 tool=$1
22 found="NOT_FOUND"
23 shift
24 versions="$*"
25 for version in $versions; do
26 for variant in "" "${version}" "-${version}" "`echo $version | sed -e 's/\.//g'`"; do
27 if check_version $tool ${tool}${variant} $version; then
28 found="${version}"
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 found="??"
38 fi
39 echo $found
40 }
41
42 find_variant()
43 {
44 tool=$1
45 found="NOT_FOUND"
46 shift
47 versions="$*"
48 for version in $versions; do
49 for variant in "" "${version}" "-${version}" "`echo $version | sed -e 's/\.//g'`"; do
50 if check_version $tool ${tool}${variant} $version; then
51 found="${variant}"
52 break
53 fi
54 done
55 if [ "x$found" != "xNOT_FOUND" ]; then
56 break
57 fi
58 done
59 if [ "x$found" = "xNOT_FOUND" ]; then
60 echo "WARNING: Cannot find $tool version $versions" >&2
61 echo "Trying `$tool --version | head -1`" >&2
62 found=""
63 fi
64 echo $found
65 }
66
67 find_path()
68 {
69 tool=$1
70 path=`which $tool`
71 if test $? -gt 0 ; then
72 # path for $tool not found. Not defining, and hoping for the best
73 echo
74 return
75 fi
76 echo $(dirname $path)
77 }
78
79 bootstrap() {
80 if "$@"; then
81 true # Everything OK
82 else
83 echo "$1 failed"
84 echo "Autotool bootstrapping failed. You will need to investigate and correct" ;
85 echo "before you can develop on this source tree"
86 exit 1
87 fi
88 }
89
90 bootstrap_libtoolize() {
91 ltver=$1
92
93 # TODO: when we have libtool2, tell libtoolize where to put its files
94 # instead of manualy moving files from ltdl to lib/libLtdl
95 if egrep -q '^[[:space:]]*AC_LIBLTDL_' configure.in
96 then
97 ltdl="--ltdl"
98 else
99 ltdl=""
100 fi
101
102 bootstrap libtoolize$ltver $ltdl --force --copy --automake
103
104 # customize generated libltdl, if any
105 if test -d libltdl
106 then
107 src=libltdl
108
109 # do not bundle with the huge standard license text
110 rm -f $src/COPYING.LIB
111 makefile=$src/Makefile.in
112 sed 's/COPYING.LIB/ /g' $makefile > $makefile.new;
113 chmod u+w $makefile
114 mv $makefile.new $makefile
115 chmod u-w $makefile
116 fi
117 }
118
119 # Adjust paths of required autool packages
120 amver=`find_variant automake ${amversions}`
121 acver=`find_variant autoconf ${acversions}`
122 ltver=`find_variant libtool ${ltversions}`
123
124 # Produce debug output about what version actually found.
125 amversion=`show_version automake ${amversions}`
126 acversion=`show_version autoconf ${acversions}`
127 ltversion=`show_version libtool ${ltversions}`
128
129 # Find the libtool path to get the right aclocal includes
130 ltpath=`find_path libtool$ltver`
131
132 # Set environment variable to tell automake which autoconf to use.
133 AUTOCONF="autoconf${acver}" ; export AUTOCONF
134
135 echo "automake ($amversion) : automake$amver"
136 echo "autoconf ($acversion) : autoconf$acver"
137 echo "libtool ($ltversion) : libtool$ltver"
138 echo "libtool path : $ltpath"
139
140 for dir in \
141 "" \
142 lib/libTrie
143 do
144 if [ -z "$dir" ] || [ -d $dir ]; then
145 if (
146 echo "Bootstrapping $dir"
147 cd ./$dir
148 if [ -n "$dir" ] && [ -f bootstrap.sh ]; then
149 ./bootstrap.sh
150 elif [ ! -f $dir/configure ]; then
151 # Make sure cfgaux exists
152 mkdir -p cfgaux
153
154 if test -n "$ltpath"; then
155 acincludeflag="-I $ltpath/../share/aclocal"
156 else
157 acincludeflag=""
158 fi
159
160 # Bootstrap the autotool subsystems
161 bootstrap aclocal$amver $acincludeflag
162 bootstrap autoheader$acver
163 bootstrap_libtoolize $ltver
164 bootstrap automake$amver --foreign --add-missing --copy -f
165 bootstrap autoconf$acver --force
166 fi ); then
167 : # OK
168 else
169 exit 1
170 fi
171 fi
172 done
173
174 # Fixup autoconf recursion using --silent/--quiet option
175 # autoconf should inherit this option whe recursing into subdirectories
176 # but it currently doesn't for some reason.
177 if ! grep "configure_args --quiet" configure >/dev/null; then
178 echo "Fixing configure recursion"
179 ed -s configure <<'EOS' >/dev/null || true
180 /ac_sub_configure_args=/
181 +1
182 i
183 # Add --quiet option if used
184 test "$silent" = yes &&
185 ac_sub_configure_args="$ac_sub_configure_args --quiet"
186 .
187 w
188 EOS
189 fi
190
191 echo "Autotool bootstrapping complete."