2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 ###########################################################################
24 #--------------------------------------------------------------------------
25 # die prints argument string to stdout and exits this shell script.
32 #--------------------------------------------------------------------------
33 # findtool works as 'which' but we use a different name to make it more
34 # obvious we aren't using 'which'! ;-)
39 if { echo "$file" | grep "/" >/dev/null 2>&1; } then
40 # when file is given with a path check it first
41 if test -f "$file"; then
51 # echo "checks for $file in $path" >&2
52 if test -f "$path/$file"; then
60 #--------------------------------------------------------------------------
61 # removethis() removes all files and subdirectories with the given name,
62 # inside and below the current subdirectory at invocation time.
65 if test "$#" = "1"; then
66 find . -depth -name $1 -print > buildconf.tmp.$$
69 if test -f "$fdname"; then
71 elif test -d "$fdname"; then
74 done < buildconf.tmp.$$
75 rm -f buildconf.tmp.$$
79 #--------------------------------------------------------------------------
80 # Ensure that buildconf runs from the subdirectory where configure.ac lives
82 if test ! -f configure.ac ||
83 test ! -f src/tool_main.c ||
84 test ! -f lib/urldata.h ||
85 test ! -f include/curl/curl.h ||
86 test ! -f m4/curl-functions.m4; then
87 echo "Can not run buildconf from outside of curl's source subdirectory!"
88 echo "Change to the subdirectory where buildconf is found, and try again."
92 #--------------------------------------------------------------------------
93 # autoconf 2.57 or newer. Unpatched version 2.67 does not generate proper
94 # configure script. Unpatched version 2.68 is simply unusable, we should
95 # disallow 2.68 usage.
98 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
99 if test -z "$ac_version"; then
100 echo "buildconf: autoconf not found."
101 echo " You need autoconf version $need_autoconf or newer installed."
104 old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
105 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
106 echo "buildconf: autoconf version $ac_version found."
107 echo " You need autoconf version $need_autoconf or newer installed."
108 echo " If you have a sufficient autoconf installed, but it"
109 echo " is not named 'autoconf', then try setting the"
110 echo " AUTOCONF environment variable."
114 if test "$1" = "2" -a "$2" -eq "67"; then
115 echo "buildconf: autoconf version $ac_version (BAD)"
116 echo " Unpatched version generates broken configure script."
117 elif test "$1" = "2" -a "$2" -eq "68"; then
118 echo "buildconf: autoconf version $ac_version (BAD)"
119 echo " Unpatched version generates unusable configure script."
121 echo "buildconf: autoconf version $ac_version (ok)"
124 am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
125 if test -z "$am4te_version"; then
126 echo "buildconf: autom4te not found. Weird autoconf installation!"
129 if test "$am4te_version" = "$ac_version"; then
130 echo "buildconf: autom4te version $am4te_version (ok)"
132 echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
136 #--------------------------------------------------------------------------
137 # autoheader 2.50 or newer
139 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
140 if test -z "$ah_version"; then
141 echo "buildconf: autoheader not found."
142 echo " You need autoheader version 2.50 or newer installed."
145 old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
146 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
147 echo "buildconf: autoheader version $ah_version found."
148 echo " You need autoheader version 2.50 or newer installed."
149 echo " If you have a sufficient autoheader installed, but it"
150 echo " is not named 'autoheader', then try setting the"
151 echo " AUTOHEADER environment variable."
155 echo "buildconf: autoheader version $ah_version (ok)"
157 #--------------------------------------------------------------------------
158 # automake 1.7 or newer
161 am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
162 if test -z "$am_version"; then
163 echo "buildconf: automake not found."
164 echo " You need automake version $need_automake or newer installed."
167 old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
168 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
169 echo "buildconf: automake version $am_version found."
170 echo " You need automake version $need_automake or newer installed."
171 echo " If you have a sufficient automake installed, but it"
172 echo " is not named 'automake', then try setting the"
173 echo " AUTOMAKE environment variable."
177 echo "buildconf: automake version $am_version (ok)"
179 acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
180 if test -z "$acloc_version"; then
181 echo "buildconf: aclocal not found. Weird automake installation!"
184 if test "$acloc_version" = "$am_version"; then
185 echo "buildconf: aclocal version $acloc_version (ok)"
187 echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
191 #--------------------------------------------------------------------------
192 # GNU libtool preliminary check
197 want_lt_version=1.4.2
199 # This approach that tries 'glibtool' first is intended for systems that
200 # have GNU libtool named as 'glibtool' and libtool not being GNU's.
202 libtool=`findtool glibtool 2>/dev/null`
203 if test ! -x "$libtool"; then
204 libtool=`findtool ${LIBTOOL:-libtool}`
206 if test -z "$libtool"; then
207 echo "buildconf: libtool not found."
208 echo " You need GNU libtool $want_lt_version or newer installed."
212 lt_pver=`$libtool --version 2>/dev/null|head -n 1`
213 lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
214 lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
215 if test -z "$lt_version"; then
216 echo "buildconf: libtool not found."
217 echo " You need GNU libtool $want_lt_version or newer installed."
220 old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
225 if test -z "$lt_major"; then
227 elif test "$lt_major" -gt "$want_lt_major"; then
229 elif test "$lt_major" -lt "$want_lt_major"; then
231 elif test -z "$lt_minor"; then
233 elif test "$lt_minor" -gt "$want_lt_minor"; then
235 elif test "$lt_minor" -lt "$want_lt_minor"; then
237 elif test -z "$lt_patch"; then
239 elif test "$lt_patch" -gt "$want_lt_patch"; then
241 elif test "$lt_patch" -lt "$want_lt_patch"; then
246 if test "$lt_status" != "good"; then
247 echo "buildconf: libtool version $lt_version found."
248 echo " You need GNU libtool $want_lt_version or newer installed."
252 echo "buildconf: libtool version $lt_version (ok)"
254 #--------------------------------------------------------------------------
255 # GNU libtoolize check
257 if test -z "$LIBTOOLIZE"; then
258 # use (g)libtoolize from same location as (g)libtool
259 libtoolize="${libtool}ize"
261 libtoolize=`findtool $LIBTOOLIZE`
263 if test ! -f "$libtoolize"; then
264 echo "buildconf: libtoolize not found."
265 echo " You need GNU libtoolize $want_lt_version or newer installed."
269 #--------------------------------------------------------------------------
272 m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`;
273 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
275 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
276 echo "buildconf: GNU m4 version $m4_version (ok)"
278 if test -z "$m4"; then
279 echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
281 echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
286 #--------------------------------------------------------------------------
289 PERL=`findtool ${PERL:-perl}`
290 if test -z "$PERL"; then
291 echo "buildconf: perl not found"
295 #--------------------------------------------------------------------------
296 # Remove files generated on previous buildconf/configure run.
341 #--------------------------------------------------------------------------
342 # run the correct scripts now
345 echo "buildconf: running libtoolize"
346 ${libtoolize} --copy --automake --force || die "libtoolize command failed"
348 # When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
349 # subdirectory and this local copy is patched to fix some warnings that
350 # are triggered when running aclocal and using autoconf 2.62 or later.
352 if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
353 if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
354 echo "buildconf: copying libtool.m4 to local m4 subdir"
355 ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
356 if test -f $ac_dir/libtool.m4; then
357 cp -f $ac_dir/libtool.m4 m4/libtool.m4
359 echo "buildconf: $ac_dir/libtool.m4 not found"
361 if test -f m4/libtool.m4; then
362 echo "buildconf: renaming some variables in local m4/libtool.m4"
364 's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
365 s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
367 rm -f m4/libtool.m4.tmp
372 if test -f m4/libtool.m4; then
373 echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
374 $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
375 rm -f m4/libtool.m4.tmp
378 echo "buildconf: running aclocal"
379 ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
381 echo "buildconf: converting all mv to mv -f in local aclocal.m4"
382 $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
384 echo "buildconf: running autoheader"
385 ${AUTOHEADER:-autoheader} || die "autoheader command failed"
387 echo "buildconf: running autoconf"
388 ${AUTOCONF:-autoconf} || die "autoconf command failed"
390 if test -d ares; then
392 echo "buildconf: running in ares"
397 echo "buildconf: running automake"
398 ${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
400 #--------------------------------------------------------------------------
401 # GNU libtool complementary check
403 # Depending on the libtool and automake versions being used, config.guess
404 # might not be installed in the subdirectory until automake has finished.
405 # So we can not attempt to use it until this very last buildconf stage.
407 if test ! -f ./config.guess; then
408 echo "buildconf: config.guess not found"
410 buildhost=`./config.guess 2>/dev/null|head -n 1`
425 if test ! -z "$need_lt_check"; then
426 if test -z "$lt_major"; then
428 elif test "$lt_major" -gt "$need_lt_major"; then
430 elif test "$lt_major" -lt "$need_lt_major"; then
432 elif test -z "$lt_minor"; then
434 elif test "$lt_minor" -gt "$need_lt_minor"; then
436 elif test "$lt_minor" -lt "$need_lt_minor"; then
438 elif test -z "$lt_patch"; then
440 elif test "$lt_patch" -gt "$need_lt_patch"; then
442 elif test "$lt_patch" -lt "$need_lt_patch"; then
447 if test "$lt_status" != "good"; then
448 need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
449 echo "buildconf: libtool version $lt_version found."
450 echo " $buildhost requires GNU libtool $need_lt_version or newer installed."
457 #--------------------------------------------------------------------------
458 # Finished successfully.