]> git.ipfire.org Git - thirdparty/squid.git/blob - bootstrap.sh
Merged 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.11 1.10 1.9}"
12 ltversions="${ltver:-2.2 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 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}" "`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}" "`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 bootstrap() {
68 if "$@"; then
69 true # Everything OK
70 else
71 echo "$1 failed"
72 echo "Autotool bootstrapping failed. You will need to investigate and correct" ;
73 echo "before you can develop on this source tree"
74 exit 1
75 fi
76 }
77
78 bootstrap_libtoolize() {
79 ltver=$1
80
81 # TODO: when we have libtool2, tell libtoolize where to put its files
82 # instead of manualy moving files from ltdl to lib/libLtdl
83 if egrep -q '^[[:space:]]*AC_LIBLTDL_' configure.in
84 then
85 ltdl="--ltdl"
86 else
87 ltdl=""
88 fi
89
90 bootstrap libtoolize$ltver $ltdl --force --copy --automake
91
92 # customize generated libltdl, if any
93 if test -d libltdl
94 then
95 src=libltdl
96
97 # do not bundle with the huge standard license text
98 rm -f $src/COPYING.LIB
99 makefile=$src/Makefile.in
100 sed 's/COPYING.LIB/ /g' $makefile > $makefile.new;
101 chmod u+w $makefile
102 mv $makefile.new $makefile
103 chmod u-w $makefile
104
105 # Libtool 2.2.6b we bundle is slightly broken with non-portable dependencies
106 sed 's/<libltdl\/lt_system.h>/\"libltdl\/lt_system.h\"/g' $src/ltdl.h |
107 sed 's/<libltdl\/lt_error.h>/\"libltdl\/lt_error.h\"/g' |
108 sed 's/<libltdl\/lt_dlloader.h>/\"libltdl\/lt_dlloader.h\"/g' > $src/ltdl.h.new;
109 chmod u+w $src/ltdl.h
110 mv $src/ltdl.h.new $src/ltdl.h
111 chmod u-w $src/ltdl.h
112 fi
113 }
114
115 # Adjust paths of required autool packages
116 amver=`find_variant automake ${amversions}`
117 acver=`find_variant autoconf ${acversions}`
118 ltver=`find_variant libtool ${ltversions}`
119
120 # Produce debug output about what version actually found.
121 amversion=`show_version automake ${amversions}`
122 acversion=`show_version autoconf ${acversions}`
123 ltversion=`show_version libtool ${ltversions}`
124
125 # Set environment variable to tell automake which autoconf to use.
126 AUTOCONF="autoconf${acver}" ; export AUTOCONF
127
128 echo "automake ($amversion) : automake$amver"
129 echo "autoconf ($acversion) : autoconf$acver"
130 echo "libtool ($ltversion) : libtool$ltver"
131
132 for dir in \
133 "" \
134 lib/libTrie
135 do
136 if [ -z "$dir" ] || [ -d $dir ]; then
137 if (
138 echo "Bootstrapping $dir"
139 cd ./$dir
140 if [ -n "$dir" ] && [ -f bootstrap.sh ]; then
141 ./bootstrap.sh
142 elif [ ! -f $dir/configure ]; then
143 # Make sure cfgaux exists
144 mkdir -p cfgaux
145
146 # Bootstrap the autotool subsystems
147 bootstrap aclocal$amver
148 bootstrap autoheader$acver
149 bootstrap_libtoolize $ltver
150 bootstrap automake$amver --foreign --add-missing --copy -f
151 bootstrap autoconf$acver --force
152 fi ); then
153 : # OK
154 else
155 exit 1
156 fi
157 fi
158 done
159
160 # Fixup autoconf recursion using --silent/--quiet option
161 # autoconf should inherit this option whe recursing into subdirectories
162 # but it currently doesn't for some reason.
163 if ! grep "configure_args --quiet" configure >/dev/null; then
164 echo "Fixing configure recursion"
165 ed -s configure <<'EOS' >/dev/null || true
166 /ac_sub_configure_args=/
167 +1
168 i
169 # Add --quiet option if used
170 test "$silent" = yes &&
171 ac_sub_configure_args="$ac_sub_configure_args --quiet"
172 .
173 w
174 EOS
175 fi
176
177 echo "Autotool bootstrapping complete."