blob: 705f0d34ead062b3d70ec85a372c30df7dcd492f [file] [log] [blame]
Lucas Eckels9bd90e62012-08-06 15:07:02 -07001#!/bin/sh
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07009# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070010#
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.
14#
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.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22###########################################################################
23
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070024#--------------------------------------------------------------------------
25# die prints argument string to stdout and exits this shell script.
26#
Lucas Eckels9bd90e62012-08-06 15:07:02 -070027die(){
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070028 echo "buildconf: $@"
29 exit 1
Lucas Eckels9bd90e62012-08-06 15:07:02 -070030}
31
32#--------------------------------------------------------------------------
33# findtool works as 'which' but we use a different name to make it more
34# obvious we aren't using 'which'! ;-)
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070035# Unlike 'which' does, the current directory is ignored.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070036#
37findtool(){
38 file="$1"
39
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070040 if { echo "$file" | grep "/" >/dev/null 2>&1; } then
41 # when file is given with a path check it first
Lucas Eckels9bd90e62012-08-06 15:07:02 -070042 if test -f "$file"; then
43 echo "$file"
44 return
45 fi
46 fi
47
48 old_IFS=$IFS; IFS=':'
49 for path in $PATH
50 do
51 IFS=$old_IFS
52 # echo "checks for $file in $path" >&2
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070053 if test "$path" -a "$path" != '.' -a -f "$path/$file"; then
Lucas Eckels9bd90e62012-08-06 15:07:02 -070054 echo "$path/$file"
55 return
56 fi
57 done
58 IFS=$old_IFS
59}
60
61#--------------------------------------------------------------------------
62# removethis() removes all files and subdirectories with the given name,
63# inside and below the current subdirectory at invocation time.
64#
65removethis(){
66 if test "$#" = "1"; then
67 find . -depth -name $1 -print > buildconf.tmp.$$
68 while read fdname
69 do
70 if test -f "$fdname"; then
71 rm -f "$fdname"
72 elif test -d "$fdname"; then
73 rm -f -r "$fdname"
74 fi
75 done < buildconf.tmp.$$
76 rm -f buildconf.tmp.$$
77 fi
78}
79
80#--------------------------------------------------------------------------
81# Ensure that buildconf runs from the subdirectory where configure.ac lives
82#
83if test ! -f configure.ac ||
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070084 test ! -f src/tool_main.c ||
Lucas Eckels9bd90e62012-08-06 15:07:02 -070085 test ! -f lib/urldata.h ||
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070086 test ! -f include/curl/curl.h ||
87 test ! -f m4/curl-functions.m4; then
Lucas Eckels9bd90e62012-08-06 15:07:02 -070088 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."
90 exit 1
91fi
92
93#--------------------------------------------------------------------------
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070094# 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.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070097#
98need_autoconf="2.57"
99ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
100if test -z "$ac_version"; then
101 echo "buildconf: autoconf not found."
102 echo " You need autoconf version $need_autoconf or newer installed."
103 exit 1
104fi
105old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
106if 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."
112 exit 1
113fi
114
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700115if test "$1" = "2" -a "$2" -eq "67"; then
116 echo "buildconf: autoconf version $ac_version (BAD)"
117 echo " Unpatched version generates broken configure script."
118elif test "$1" = "2" -a "$2" -eq "68"; then
119 echo "buildconf: autoconf version $ac_version (BAD)"
120 echo " Unpatched version generates unusable configure script."
121else
122 echo "buildconf: autoconf version $ac_version (ok)"
123fi
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700124
125am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
126if test -z "$am4te_version"; then
127 echo "buildconf: autom4te not found. Weird autoconf installation!"
128 exit 1
129fi
130if test "$am4te_version" = "$ac_version"; then
131 echo "buildconf: autom4te version $am4te_version (ok)"
132else
133 echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
134 exit 1
135fi
136
137#--------------------------------------------------------------------------
138# autoheader 2.50 or newer
139#
140ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
141if test -z "$ah_version"; then
142 echo "buildconf: autoheader not found."
143 echo " You need autoheader version 2.50 or newer installed."
144 exit 1
145fi
146old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
147if 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."
153 exit 1
154fi
155
156echo "buildconf: autoheader version $ah_version (ok)"
157
158#--------------------------------------------------------------------------
159# automake 1.7 or newer
160#
161need_automake="1.7"
162am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
163if test -z "$am_version"; then
164 echo "buildconf: automake not found."
165 echo " You need automake version $need_automake or newer installed."
166 exit 1
167fi
168old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
169if 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."
175 exit 1
176fi
177
178echo "buildconf: automake version $am_version (ok)"
179
180acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
181if test -z "$acloc_version"; then
182 echo "buildconf: aclocal not found. Weird automake installation!"
183 exit 1
184fi
185if test "$acloc_version" = "$am_version"; then
186 echo "buildconf: aclocal version $acloc_version (ok)"
187else
188 echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
189 exit 1
190fi
191
192#--------------------------------------------------------------------------
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700193# GNU libtoolize preliminary check
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700194#
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700195want_lt_major=1
196want_lt_minor=4
197want_lt_patch=2
198want_lt_version=1.4.2
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700199
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700200# This approach that tries 'glibtoolize' first is intended for systems that
201# have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
202
203libtoolize=`findtool glibtoolize 2>/dev/null`
204if test ! -x "$libtoolize"; then
205 libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
206fi
207if test -z "$libtoolize"; then
208 echo "buildconf: libtoolize not found."
209 echo " You need GNU libtoolize $want_lt_version or newer installed."
210 exit 1
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700211fi
212
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700213lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700214lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
215lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
216if test -z "$lt_version"; then
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700217 echo "buildconf: libtoolize not found."
218 echo " You need GNU libtoolize $want_lt_version or newer installed."
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700219 exit 1
220fi
221old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
222lt_major=$1
223lt_minor=$2
224lt_patch=$3
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700225
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700226if test -z "$lt_major"; then
227 lt_status="bad"
228elif test "$lt_major" -gt "$want_lt_major"; then
229 lt_status="good"
230elif test "$lt_major" -lt "$want_lt_major"; then
231 lt_status="bad"
232elif test -z "$lt_minor"; then
233 lt_status="bad"
234elif test "$lt_minor" -gt "$want_lt_minor"; then
235 lt_status="good"
236elif test "$lt_minor" -lt "$want_lt_minor"; then
237 lt_status="bad"
238elif test -z "$lt_patch"; then
239 lt_status="bad"
240elif test "$lt_patch" -gt "$want_lt_patch"; then
241 lt_status="good"
242elif test "$lt_patch" -lt "$want_lt_patch"; then
243 lt_status="bad"
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700244else
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700245 lt_status="good"
246fi
247if 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."
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700250 exit 1
251fi
252
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700253echo "buildconf: libtoolize version $lt_version (ok)"
254
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700255#--------------------------------------------------------------------------
256# m4 check
257#
258m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`;
259m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
260
261if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
262 echo "buildconf: GNU m4 version $m4_version (ok)"
263else
264 if test -z "$m4"; then
265 echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
266 else
267 echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
268 fi
269 exit 1
270fi
271
272#--------------------------------------------------------------------------
273# perl check
274#
275PERL=`findtool ${PERL:-perl}`
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700276if test -z "$PERL"; then
277 echo "buildconf: perl not found"
278 exit 1
279fi
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700280
281#--------------------------------------------------------------------------
282# Remove files generated on previous buildconf/configure run.
283#
284for fname in .deps \
285 .libs \
286 *.la \
287 *.lo \
288 *.a \
289 *.o \
290 Makefile \
291 Makefile.in \
292 aclocal.m4 \
293 aclocal.m4.bak \
294 ares_build.h \
295 ares_config.h \
296 ares_config.h.in \
297 autom4te.cache \
298 compile \
299 config.guess \
300 curl_config.h \
301 curl_config.h.in \
302 config.log \
303 config.lt \
304 config.status \
305 config.sub \
306 configure \
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700307 configurehelp.pm \
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700308 curl-config \
309 curlbuild.h \
310 depcomp \
311 libcares.pc \
312 libcurl.pc \
313 libtool \
314 libtool.m4 \
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700315 libtool.m4.tmp \
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700316 ltmain.sh \
317 ltoptions.m4 \
318 ltsugar.m4 \
319 ltversion.m4 \
320 lt~obsolete.m4 \
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700321 missing \
322 install-sh \
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700323 stamp-h1 \
324 stamp-h2 \
325 stamp-h3 ; do
326 removethis "$fname"
327done
328
329#--------------------------------------------------------------------------
330# run the correct scripts now
331#
332
333echo "buildconf: running libtoolize"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700334${libtoolize} --copy --force || die "libtoolize command failed"
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700335
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700336# When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
337# subdirectory and this local copy is patched to fix some warnings that
338# are triggered when running aclocal and using autoconf 2.62 or later.
339
340if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
341 if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
342 echo "buildconf: copying libtool.m4 to local m4 subdir"
343 ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
344 if test -f $ac_dir/libtool.m4; then
345 cp -f $ac_dir/libtool.m4 m4/libtool.m4
346 else
347 echo "buildconf: $ac_dir/libtool.m4 not found"
348 fi
349 if test -f m4/libtool.m4; then
350 echo "buildconf: renaming some variables in local m4/libtool.m4"
351 $PERL -i.tmp -pe \
352 's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
353 s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
354 m4/libtool.m4
355 rm -f m4/libtool.m4.tmp
356 fi
357 fi
358fi
359
360if test -f m4/libtool.m4; then
361 echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
362 $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
363 rm -f m4/libtool.m4.tmp
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700364fi
365
366echo "buildconf: running aclocal"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700367${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700368
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700369echo "buildconf: converting all mv to mv -f in local aclocal.m4"
370$PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700371
372echo "buildconf: running autoheader"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700373${AUTOHEADER:-autoheader} || die "autoheader command failed"
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700374
375echo "buildconf: running autoconf"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700376${AUTOCONF:-autoconf} || die "autoconf command failed"
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700377
378if test -d ares; then
379 cd ares
380 echo "buildconf: running in ares"
381 ./buildconf
382 cd ..
383fi
384
385echo "buildconf: running automake"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700386${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700387
388#--------------------------------------------------------------------------
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700389# GNU libtool complementary check
390#
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700391# Depending on the libtool and automake versions being used, config.guess
392# might not be installed in the subdirectory until automake has finished.
393# So we can not attempt to use it until this very last buildconf stage.
394#
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700395if test ! -f ./config.guess; then
396 echo "buildconf: config.guess not found"
397else
398 buildhost=`./config.guess 2>/dev/null|head -n 1`
399 case $buildhost in
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700400 *-*-darwin*)
401 need_lt_major=1
402 need_lt_minor=5
403 need_lt_patch=26
404 need_lt_check="yes"
405 ;;
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700406 *-*-hpux*)
407 need_lt_major=1
408 need_lt_minor=5
409 need_lt_patch=24
410 need_lt_check="yes"
411 ;;
412 esac
413 if test ! -z "$need_lt_check"; then
414 if test -z "$lt_major"; then
415 lt_status="bad"
416 elif test "$lt_major" -gt "$need_lt_major"; then
417 lt_status="good"
418 elif test "$lt_major" -lt "$need_lt_major"; then
419 lt_status="bad"
420 elif test -z "$lt_minor"; then
421 lt_status="bad"
422 elif test "$lt_minor" -gt "$need_lt_minor"; then
423 lt_status="good"
424 elif test "$lt_minor" -lt "$need_lt_minor"; then
425 lt_status="bad"
426 elif test -z "$lt_patch"; then
427 lt_status="bad"
428 elif test "$lt_patch" -gt "$need_lt_patch"; then
429 lt_status="good"
430 elif test "$lt_patch" -lt "$need_lt_patch"; then
431 lt_status="bad"
432 else
433 lt_status="good"
434 fi
435 if test "$lt_status" != "good"; then
436 need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
437 echo "buildconf: libtool version $lt_version found."
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700438 echo " $buildhost requires GNU libtool $need_lt_version or newer installed."
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700439 rm -f configure
440 exit 1
441 fi
442 fi
443fi
444
445#--------------------------------------------------------------------------
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700446# Finished successfully.
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700447#
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700448echo "buildconf: OK"
449exit 0