2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) 1998 - 2017, 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 https://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'! ;-)
35 # Unlike 'which' does, the current directory is ignored.
40 if { echo "$file" | grep "/" >/dev/null 2>&1; } then
41 # when file is given with a path check it first
42 if test -f "$file"; then
52 # echo "checks for $file in $path" >&2
53 if test "$path" -a "$path" != '.' -a -f "$path/$file"; then
61 #--------------------------------------------------------------------------
62 # removethis() removes all files and subdirectories with the given name,
63 # inside and below the current subdirectory at invocation time.
66 if test "$#" = "1"; then
67 find . -depth -name $1 -print > buildconf.tmp.$$
70 if test -f "$fdname"; then
72 elif test -d "$fdname"; then
75 done < buildconf.tmp.$$
76 rm -f buildconf.tmp.$$
80 #--------------------------------------------------------------------------
81 # Ensure that buildconf runs from the subdirectory where configure.ac lives
83 if test ! -f configure.ac ||
84 test ! -f src/tool_main.c ||
85 test ! -f lib/urldata.h ||
86 test ! -f include/curl/curl.h ||
87 test ! -f m4/curl-functions.m4; then
88 echo "Can not run buildconf from outside of curl's source subdirectory!"
89 echo "Change to the subdirectory where buildconf is found, and try again."
93 #--------------------------------------------------------------------------
94 # autoconf 2.57 or newer. Unpatched version 2.67 does not generate proper
95 # configure script. Unpatched version 2.68 is simply unusable, we should
96 # disallow 2.68 usage.
99 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
100 if test -z "$ac_version"; then
101 echo "buildconf: autoconf not found."
102 echo " You need autoconf version $need_autoconf or newer installed."
105 old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
106 if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
107 echo "buildconf: autoconf version $ac_version found."
108 echo " You need autoconf version $need_autoconf or newer installed."
109 echo " If you have a sufficient autoconf installed, but it"
110 echo " is not named 'autoconf', then try setting the"
111 echo " AUTOCONF environment variable."
115 if test "$1" = "2" -a "$2" -eq "67"; then
116 echo "buildconf: autoconf version $ac_version (BAD)"
117 echo " Unpatched version generates broken configure script."
118 elif test "$1" = "2" -a "$2" -eq "68"; then
119 echo "buildconf: autoconf version $ac_version (BAD)"
120 echo " Unpatched version generates unusable configure script."
122 echo "buildconf: autoconf version $ac_version (ok)"
125 am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
126 if test -z "$am4te_version"; then
127 echo "buildconf: autom4te not found. Weird autoconf installation!"
130 if test "$am4te_version" = "$ac_version"; then
131 echo "buildconf: autom4te version $am4te_version (ok)"
133 echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
137 #--------------------------------------------------------------------------
138 # autoheader 2.50 or newer
140 ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
141 if test -z "$ah_version"; then
142 echo "buildconf: autoheader not found."
143 echo " You need autoheader version 2.50 or newer installed."
146 old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
147 if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
148 echo "buildconf: autoheader version $ah_version found."
149 echo " You need autoheader version 2.50 or newer installed."
150 echo " If you have a sufficient autoheader installed, but it"
151 echo " is not named 'autoheader', then try setting the"
152 echo " AUTOHEADER environment variable."
156 echo "buildconf: autoheader version $ah_version (ok)"
158 #--------------------------------------------------------------------------
159 # automake 1.7 or newer
162 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/'`
163 if test -z "$am_version"; then
164 echo "buildconf: automake not found."
165 echo " You need automake version $need_automake or newer installed."
168 old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
169 if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
170 echo "buildconf: automake version $am_version found."
171 echo " You need automake version $need_automake or newer installed."
172 echo " If you have a sufficient automake installed, but it"
173 echo " is not named 'automake', then try setting the"
174 echo " AUTOMAKE environment variable."
178 echo "buildconf: automake version $am_version (ok)"
180 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/'`
181 if test -z "$acloc_version"; then
182 echo "buildconf: aclocal not found. Weird automake installation!"
185 if test "$acloc_version" = "$am_version"; then
186 echo "buildconf: aclocal version $acloc_version (ok)"
188 echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
192 #--------------------------------------------------------------------------
193 # GNU libtoolize preliminary check
198 want_lt_version=1.4.2
200 # This approach that tries 'glibtoolize' first is intended for systems that
201 # have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
203 libtoolize=`findtool glibtoolize 2>/dev/null`
204 if test ! -x "$libtoolize"; then
205 libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
207 if test -z "$libtoolize"; then
208 echo "buildconf: libtoolize not found."
209 echo " You need GNU libtoolize $want_lt_version or newer installed."
213 lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
214 lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
215 lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
216 if test -z "$lt_version"; then
217 echo "buildconf: libtoolize not found."
218 echo " You need GNU libtoolize $want_lt_version or newer installed."
221 old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
226 if test -z "$lt_major"; then
228 elif test "$lt_major" -gt "$want_lt_major"; then
230 elif test "$lt_major" -lt "$want_lt_major"; then
232 elif test -z "$lt_minor"; then
234 elif test "$lt_minor" -gt "$want_lt_minor"; then
236 elif test "$lt_minor" -lt "$want_lt_minor"; then
238 elif test -z "$lt_patch"; then
240 elif test "$lt_patch" -gt "$want_lt_patch"; then
242 elif test "$lt_patch" -lt "$want_lt_patch"; then
247 if test "$lt_status" != "good"; then
248 echo "buildconf: libtoolize version $lt_version found."
249 echo " You need GNU libtoolize $want_lt_version or newer installed."
253 echo "buildconf: libtoolize version $lt_version (ok)"
255 #--------------------------------------------------------------------------
258 m4=`(${M4:-m4} --version 0<&- || ${M4:-gm4} --version) 2>/dev/null 0<&- | head -n 1`;
259 m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
261 if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
262 echo "buildconf: GNU m4 version $m4_version (ok)"
264 if test -z "$m4"; then
265 echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
267 echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
272 #--------------------------------------------------------------------------
275 PERL=`findtool ${PERL:-perl}`
276 if test -z "$PERL"; then
277 echo "buildconf: perl not found"
281 #--------------------------------------------------------------------------
282 # Remove files generated on previous buildconf/configure run.
328 #--------------------------------------------------------------------------
329 # run the correct scripts now
332 echo "buildconf: running libtoolize"
333 ${libtoolize} --copy --force || die "libtoolize command failed"
335 # When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
336 # subdirectory and this local copy is patched to fix some warnings that
337 # are triggered when running aclocal and using autoconf 2.62 or later.
339 if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
340 if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
341 echo "buildconf: copying libtool.m4 to local m4 subdir"
342 ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
343 if test -f $ac_dir/libtool.m4; then
344 cp -f $ac_dir/libtool.m4 m4/libtool.m4
346 echo "buildconf: $ac_dir/libtool.m4 not found"
348 if test -f m4/libtool.m4; then
349 echo "buildconf: renaming some variables in local m4/libtool.m4"
351 's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
352 s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
354 rm -f m4/libtool.m4.tmp
359 if test -f m4/libtool.m4; then
360 echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
361 $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
362 rm -f m4/libtool.m4.tmp
365 echo "buildconf: running aclocal"
366 ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
368 echo "buildconf: converting all mv to mv -f in local aclocal.m4"
369 $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
371 echo "buildconf: running autoheader"
372 ${AUTOHEADER:-autoheader} || die "autoheader command failed"
374 echo "buildconf: running autoconf"
375 ${AUTOCONF:-autoconf} || die "autoconf command failed"
377 if test -d ares; then
379 echo "buildconf: running in ares"
384 echo "buildconf: running automake"
385 ${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
387 #--------------------------------------------------------------------------
388 # GNU libtool complementary check
390 # Depending on the libtool and automake versions being used, config.guess
391 # might not be installed in the subdirectory until automake has finished.
392 # So we can not attempt to use it until this very last buildconf stage.
394 if test ! -f ./config.guess; then
395 echo "buildconf: config.guess not found"
397 buildhost=`./config.guess 2>/dev/null|head -n 1`
412 if test ! -z "$need_lt_check"; then
413 if test -z "$lt_major"; then
415 elif test "$lt_major" -gt "$need_lt_major"; then
417 elif test "$lt_major" -lt "$need_lt_major"; then
419 elif test -z "$lt_minor"; then
421 elif test "$lt_minor" -gt "$need_lt_minor"; then
423 elif test "$lt_minor" -lt "$need_lt_minor"; then
425 elif test -z "$lt_patch"; then
427 elif test "$lt_patch" -gt "$need_lt_patch"; then
429 elif test "$lt_patch" -lt "$need_lt_patch"; then
434 if test "$lt_status" != "good"; then
435 need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
436 echo "buildconf: libtool version $lt_version found."
437 echo " $buildhost requires GNU libtool $need_lt_version or newer installed."
444 #--------------------------------------------------------------------------
445 # Finished successfully.