blob: f77ed7665e4a7a7efa519f0dd6fe0d2d2461bdea [file] [log] [blame]
9487f7f2011-08-03 07:05:30 -07001#!/bin/sh
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
9# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
10#
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
24die(){
25 echo "$@"
26 exit
27}
28
29#--------------------------------------------------------------------------
30# findtool works as 'which' but we use a different name to make it more
31# obvious we aren't using 'which'! ;-)
32#
33findtool(){
34 file="$1"
35
36 if { echo $file | grep "/" >/dev/null 2>&1; } then
37 # we only check for the explicit file name if the file is given
38 # including a slash. Use ./ for current dir. Previously this would
39 # otherwise always cause findtool to search the local dir first, which
40 # is wrong.
41 if test -f "$file"; then
42 echo "$file"
43 return
44 fi
45 fi
46
47 old_IFS=$IFS; IFS=':'
48 for path in $PATH
49 do
50 IFS=$old_IFS
51 # echo "checks for $file in $path" >&2
52 if test -f "$path/$file"; then
53 echo "$path/$file"
54 return
55 fi
56 done
57 IFS=$old_IFS
58}
59
60#--------------------------------------------------------------------------
61# removethis() removes all files and subdirectories with the given name,
62# inside and below the current subdirectory at invocation time.
63#
64removethis(){
65 if test "$#" = "1"; then
66 find . -depth -name $1 -print > buildconf.tmp.$$
67 while read fdname
68 do
69 if test -f "$fdname"; then
70 rm -f "$fdname"
71 elif test -d "$fdname"; then
72 rm -f -r "$fdname"
73 fi
74 done < buildconf.tmp.$$
75 rm -f buildconf.tmp.$$
76 fi
77}
78
79#--------------------------------------------------------------------------
80# Ensure that buildconf runs from the subdirectory where configure.ac lives
81#
82if test ! -f configure.ac ||
83 test ! -f src/main.c ||
84 test ! -f lib/urldata.h ||
85 test ! -f include/curl/curl.h; then
86 echo "Can not run buildconf from outside of curl's source subdirectory!"
87 echo "Change to the subdirectory where buildconf is found, and try again."
88 exit 1
89fi
90
91#--------------------------------------------------------------------------
92# autoconf 2.57 or newer
93#
94need_autoconf="2.57"
95ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
96if test -z "$ac_version"; then
97 echo "buildconf: autoconf not found."
98 echo " You need autoconf version $need_autoconf or newer installed."
99 exit 1
100fi
101old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
102if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
103 echo "buildconf: autoconf version $ac_version found."
104 echo " You need autoconf version $need_autoconf or newer installed."
105 echo " If you have a sufficient autoconf installed, but it"
106 echo " is not named 'autoconf', then try setting the"
107 echo " AUTOCONF environment variable."
108 exit 1
109fi
110
111echo "buildconf: autoconf version $ac_version (ok)"
112
113am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
114if test -z "$am4te_version"; then
115 echo "buildconf: autom4te not found. Weird autoconf installation!"
116 exit 1
117fi
118if test "$am4te_version" = "$ac_version"; then
119 echo "buildconf: autom4te version $am4te_version (ok)"
120else
121 echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
122 exit 1
123fi
124
125#--------------------------------------------------------------------------
126# autoheader 2.50 or newer
127#
128ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
129if test -z "$ah_version"; then
130 echo "buildconf: autoheader not found."
131 echo " You need autoheader version 2.50 or newer installed."
132 exit 1
133fi
134old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
135if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
136 echo "buildconf: autoheader version $ah_version found."
137 echo " You need autoheader version 2.50 or newer installed."
138 echo " If you have a sufficient autoheader installed, but it"
139 echo " is not named 'autoheader', then try setting the"
140 echo " AUTOHEADER environment variable."
141 exit 1
142fi
143
144echo "buildconf: autoheader version $ah_version (ok)"
145
146#--------------------------------------------------------------------------
147# automake 1.7 or newer
148#
149need_automake="1.7"
150am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
151if test -z "$am_version"; then
152 echo "buildconf: automake not found."
153 echo " You need automake version $need_automake or newer installed."
154 exit 1
155fi
156old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
157if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
158 echo "buildconf: automake version $am_version found."
159 echo " You need automake version $need_automake or newer installed."
160 echo " If you have a sufficient automake installed, but it"
161 echo " is not named 'automake', then try setting the"
162 echo " AUTOMAKE environment variable."
163 exit 1
164fi
165
166echo "buildconf: automake version $am_version (ok)"
167
168acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
169if test -z "$acloc_version"; then
170 echo "buildconf: aclocal not found. Weird automake installation!"
171 exit 1
172fi
173if test "$acloc_version" = "$am_version"; then
174 echo "buildconf: aclocal version $acloc_version (ok)"
175else
176 echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
177 exit 1
178fi
179
180#--------------------------------------------------------------------------
181# libtool check
182#
183LIBTOOL_WANTED_MAJOR=1
184LIBTOOL_WANTED_MINOR=4
185LIBTOOL_WANTED_PATCH=2
186LIBTOOL_WANTED_VERSION=1.4.2
187
188# this approach that tries 'glibtool' first is some kind of work-around for
189# some BSD-systems I believe that use to provide the GNU libtool named
190# glibtool, with 'libtool' being something completely different.
191libtool=`findtool glibtool 2>/dev/null`
192if test ! -x "$libtool"; then
193 libtool=`findtool ${LIBTOOL:-libtool}`
194fi
195
196if test -z "$LIBTOOLIZE"; then
197 # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
198 # $libtool is already the full path
199 libtoolize="${libtool}ize"
200else
201 libtoolize=`findtool $LIBTOOLIZE`
202fi
203
204lt_pver=`$libtool --version 2>/dev/null|head -n 1`
205lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
206lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
207if test -z "$lt_version"; then
208 echo "buildconf: libtool not found."
209 echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
210 exit 1
211fi
212old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
213lt_major=$1
214lt_minor=$2
215lt_patch=$3
216lt_status="good"
217
218if test "$lt_major" = "$LIBTOOL_WANTED_MAJOR"; then
219 if test "$lt_minor" -lt "$LIBTOOL_WANTED_MINOR"; then
220 lt_status="bad"
221 elif test -n "$LIBTOOL_WANTED_PATCH"; then
222 if test "$lt_minor" -gt "$LIBTOOL_WANTED_MINOR"; then
223 lt_status="good"
224 elif test -n "$lt_patch"; then
225 if test "$lt_patch" -lt "$LIBTOOL_WANTED_PATCH"; then
226 lt_status="bad"
227 fi
228 else
229 lt_status="bad"
230 fi
231 fi
232fi
233if test $lt_status != "good"; then
234 echo "buildconf: libtool version $lt_version found."
235 echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
236 exit 1
237fi
238
239echo "buildconf: libtool version $lt_version (ok)"
240
241if test -f "$libtoolize"; then
242 echo "buildconf: libtoolize found"
243else
244 echo "buildconf: libtoolize not found. Weird libtool installation!"
245 exit 1
246fi
247
248#--------------------------------------------------------------------------
249# m4 check
250#
251m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`;
252m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
253
254if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
255 echo "buildconf: GNU m4 version $m4_version (ok)"
256else
257 if test -z "$m4"; then
258 echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
259 else
260 echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
261 fi
262 exit 1
263fi
264
265#--------------------------------------------------------------------------
266# perl check
267#
268PERL=`findtool ${PERL:-perl}`
269
270#--------------------------------------------------------------------------
271# Remove files generated on previous buildconf/configure run.
272#
273for fname in .deps \
274 .libs \
275 *.la \
276 *.lo \
277 *.a \
278 *.o \
279 Makefile \
280 Makefile.in \
281 aclocal.m4 \
282 aclocal.m4.bak \
283 ares_build.h \
284 ares_config.h \
285 ares_config.h.in \
286 autom4te.cache \
287 compile \
288 config.guess \
289 curl_config.h \
290 curl_config.h.in \
291 config.log \
292 config.lt \
293 config.status \
294 config.sub \
295 configure \
296 configurehelp.pm \
297 curl-config \
298 curlbuild.h \
299 depcomp \
300 libcares.pc \
301 libcurl.pc \
302 libtool \
303 libtool.m4 \
304 ltmain.sh \
305 ltoptions.m4 \
306 ltsugar.m4 \
307 ltversion.m4 \
308 lt~obsolete.m4 \
309 stamp-h1 \
310 stamp-h2 \
311 stamp-h3 ; do
312 removethis "$fname"
313done
314
315#--------------------------------------------------------------------------
316# run the correct scripts now
317#
318
319echo "buildconf: running libtoolize"
320$libtoolize --copy --automake --force || die "The libtoolize command failed"
321
322if test ! -f m4/curl-functions.m4; then
323 echo "buildconf: cURL m4 macros not found"
324 exit 1
325fi
326
327echo "buildconf: running aclocal"
328${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "The aclocal command line failed"
329
330if test -n "$PERL"; then
331 echo "buildconf: running aclocal hack to convert all mv to mv -f"
332 $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
333else
334 echo "buildconf: perl not found"
335 exit 1
336fi
337
338echo "buildconf: running autoheader"
339${AUTOHEADER:-autoheader} || die "The autoheader command failed"
340
341echo "buildconf: cp lib/curl_config.h.in src/curl_config.h.in"
342cp lib/curl_config.h.in src/curl_config.h.in
343
344echo "buildconf: running autoconf"
345${AUTOCONF:-autoconf} || die "The autoconf command failed"
346
347if test -d ares; then
348 cd ares
349 echo "buildconf: running in ares"
350 ./buildconf
351 cd ..
352fi
353
354echo "buildconf: running automake"
355${AUTOMAKE:-automake} -a -c || die "The automake command failed"
356
357#--------------------------------------------------------------------------
358# Depending on the libtool and automake versions being used, config.guess
359# might not be installed in the subdirectory until automake has finished.
360# So we can not attempt to use it until this very last buildconf stage.
361#
362
363if test ! -f ./config.guess; then
364 echo "buildconf: config.guess not found"
365else
366 buildhost=`./config.guess 2>/dev/null|head -n 1`
367 case $buildhost in
368 *-*-darwin*)
369 need_lt_major=1
370 need_lt_minor=5
371 need_lt_patch=26
372 need_lt_check="yes"
373 ;;
374 *-*-hpux*)
375 need_lt_major=1
376 need_lt_minor=5
377 need_lt_patch=24
378 need_lt_check="yes"
379 ;;
380 esac
381 if test ! -z "$need_lt_check"; then
382 if test -z "$lt_major"; then
383 lt_status="bad"
384 elif test "$lt_major" -gt "$need_lt_major"; then
385 lt_status="good"
386 elif test "$lt_major" -lt "$need_lt_major"; then
387 lt_status="bad"
388 elif test -z "$lt_minor"; then
389 lt_status="bad"
390 elif test "$lt_minor" -gt "$need_lt_minor"; then
391 lt_status="good"
392 elif test "$lt_minor" -lt "$need_lt_minor"; then
393 lt_status="bad"
394 elif test -z "$lt_patch"; then
395 lt_status="bad"
396 elif test "$lt_patch" -gt "$need_lt_patch"; then
397 lt_status="good"
398 elif test "$lt_patch" -lt "$need_lt_patch"; then
399 lt_status="bad"
400 else
401 lt_status="good"
402 fi
403 if test "$lt_status" != "good"; then
404 need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
405 echo "buildconf: libtool version $lt_version found."
406 echo " $buildhost requires libtool $need_lt_version or newer installed."
407 rm -f configure
408 exit 1
409 fi
410 fi
411fi
412
413#--------------------------------------------------------------------------
414# Finished succesfully.
415#
416
417echo "buildconf: OK"
418exit 0