1#!/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/tool_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. Unpatched version 2.67 does not generate proper 93# configure script. Unpatched version 2.68 is simply unusable, we should 94# disallow 2.68 usage. 95# 96need_autoconf="2.57" 97ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'` 98if test -z "$ac_version"; then 99 echo "buildconf: autoconf not found." 100 echo " You need autoconf version $need_autoconf or newer installed." 101 exit 1 102fi 103old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS 104if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then 105 echo "buildconf: autoconf version $ac_version found." 106 echo " You need autoconf version $need_autoconf or newer installed." 107 echo " If you have a sufficient autoconf installed, but it" 108 echo " is not named 'autoconf', then try setting the" 109 echo " AUTOCONF environment variable." 110 exit 1 111fi 112 113if test "$1" = "2" -a "$2" -eq "67"; then 114 echo "buildconf: autoconf version $ac_version (BAD)" 115 echo " Unpatched version generates broken configure script." 116elif test "$1" = "2" -a "$2" -eq "68"; then 117 echo "buildconf: autoconf version $ac_version (BAD)" 118 echo " Unpatched version generates unusable configure script." 119else 120 echo "buildconf: autoconf version $ac_version (ok)" 121fi 122 123am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'` 124if test -z "$am4te_version"; then 125 echo "buildconf: autom4te not found. Weird autoconf installation!" 126 exit 1 127fi 128if test "$am4te_version" = "$ac_version"; then 129 echo "buildconf: autom4te version $am4te_version (ok)" 130else 131 echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)" 132 exit 1 133fi 134 135#-------------------------------------------------------------------------- 136# autoheader 2.50 or newer 137# 138ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'` 139if test -z "$ah_version"; then 140 echo "buildconf: autoheader not found." 141 echo " You need autoheader version 2.50 or newer installed." 142 exit 1 143fi 144old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS 145if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then 146 echo "buildconf: autoheader version $ah_version found." 147 echo " You need autoheader version 2.50 or newer installed." 148 echo " If you have a sufficient autoheader installed, but it" 149 echo " is not named 'autoheader', then try setting the" 150 echo " AUTOHEADER environment variable." 151 exit 1 152fi 153 154echo "buildconf: autoheader version $ah_version (ok)" 155 156#-------------------------------------------------------------------------- 157# automake 1.7 or newer 158# 159need_automake="1.7" 160am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'` 161if test -z "$am_version"; then 162 echo "buildconf: automake not found." 163 echo " You need automake version $need_automake or newer installed." 164 exit 1 165fi 166old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS 167if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then 168 echo "buildconf: automake version $am_version found." 169 echo " You need automake version $need_automake or newer installed." 170 echo " If you have a sufficient automake installed, but it" 171 echo " is not named 'automake', then try setting the" 172 echo " AUTOMAKE environment variable." 173 exit 1 174fi 175 176echo "buildconf: automake version $am_version (ok)" 177 178acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'` 179if test -z "$acloc_version"; then 180 echo "buildconf: aclocal not found. Weird automake installation!" 181 exit 1 182fi 183if test "$acloc_version" = "$am_version"; then 184 echo "buildconf: aclocal version $acloc_version (ok)" 185else 186 echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)" 187 exit 1 188fi 189 190#-------------------------------------------------------------------------- 191# libtool check 192# 193LIBTOOL_WANTED_MAJOR=1 194LIBTOOL_WANTED_MINOR=4 195LIBTOOL_WANTED_PATCH=2 196LIBTOOL_WANTED_VERSION=1.4.2 197 198# this approach that tries 'glibtool' first is some kind of work-around for 199# some BSD-systems I believe that use to provide the GNU libtool named 200# glibtool, with 'libtool' being something completely different. 201libtool=`findtool glibtool 2>/dev/null` 202if test ! -x "$libtool"; then 203 libtool=`findtool ${LIBTOOL:-libtool}` 204fi 205 206if test -z "$LIBTOOLIZE"; then 207 # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found 208 # $libtool is already the full path 209 libtoolize="${libtool}ize" 210else 211 libtoolize=`findtool $LIBTOOLIZE` 212fi 213 214lt_pver=`$libtool --version 2>/dev/null|head -n 1` 215lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"` 216lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"` 217if test -z "$lt_version"; then 218 echo "buildconf: libtool not found." 219 echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed" 220 exit 1 221fi 222old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS 223lt_major=$1 224lt_minor=$2 225lt_patch=$3 226lt_status="good" 227 228if test "$lt_major" = "$LIBTOOL_WANTED_MAJOR"; then 229 if test "$lt_minor" -lt "$LIBTOOL_WANTED_MINOR"; then 230 lt_status="bad" 231 elif test -n "$LIBTOOL_WANTED_PATCH"; then 232 if test "$lt_minor" -gt "$LIBTOOL_WANTED_MINOR"; then 233 lt_status="good" 234 elif test -n "$lt_patch"; then 235 if test "$lt_patch" -lt "$LIBTOOL_WANTED_PATCH"; then 236 lt_status="bad" 237 fi 238 else 239 lt_status="bad" 240 fi 241 fi 242fi 243if test $lt_status != "good"; then 244 echo "buildconf: libtool version $lt_version found." 245 echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed" 246 exit 1 247fi 248 249echo "buildconf: libtool version $lt_version (ok)" 250 251if test -f "$libtoolize"; then 252 echo "buildconf: libtoolize found" 253else 254 echo "buildconf: libtoolize not found. Weird libtool installation!" 255 exit 1 256fi 257 258#-------------------------------------------------------------------------- 259# m4 check 260# 261m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`; 262m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'` 263 264if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then 265 echo "buildconf: GNU m4 version $m4_version (ok)" 266else 267 if test -z "$m4"; then 268 echo "buildconf: m4 version not recognized. You need a GNU m4 installed!" 269 else 270 echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!" 271 fi 272 exit 1 273fi 274 275#-------------------------------------------------------------------------- 276# perl check 277# 278PERL=`findtool ${PERL:-perl}` 279 280#-------------------------------------------------------------------------- 281# Remove files generated on previous buildconf/configure run. 282# 283for fname in .deps \ 284 .libs \ 285 *.la \ 286 *.lo \ 287 *.a \ 288 *.o \ 289 Makefile \ 290 Makefile.in \ 291 aclocal.m4 \ 292 aclocal.m4.bak \ 293 ares_build.h \ 294 ares_config.h \ 295 ares_config.h.in \ 296 autom4te.cache \ 297 compile \ 298 config.guess \ 299 curl_config.h \ 300 curl_config.h.in \ 301 config.log \ 302 config.lt \ 303 config.status \ 304 config.sub \ 305 configure \ 306 configurehelp.pm \ 307 curl-config \ 308 curlbuild.h \ 309 depcomp \ 310 libcares.pc \ 311 libcurl.pc \ 312 libtool \ 313 libtool.m4 \ 314 ltmain.sh \ 315 ltoptions.m4 \ 316 ltsugar.m4 \ 317 ltversion.m4 \ 318 lt~obsolete.m4 \ 319 stamp-h1 \ 320 stamp-h2 \ 321 stamp-h3 ; do 322 removethis "$fname" 323done 324 325#-------------------------------------------------------------------------- 326# run the correct scripts now 327# 328 329echo "buildconf: running libtoolize" 330$libtoolize --copy --automake --force || die "The libtoolize command failed" 331 332if test ! -f m4/curl-functions.m4; then 333 echo "buildconf: cURL m4 macros not found" 334 exit 1 335fi 336 337echo "buildconf: running aclocal" 338${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "The aclocal command line failed" 339 340if test -n "$PERL"; then 341 echo "buildconf: running aclocal hack to convert all mv to mv -f" 342 $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4 343else 344 echo "buildconf: perl not found" 345 exit 1 346fi 347 348echo "buildconf: running autoheader" 349${AUTOHEADER:-autoheader} || die "The autoheader command failed" 350 351echo "buildconf: cp lib/curl_config.h.in src/curl_config.h.in" 352cp lib/curl_config.h.in src/curl_config.h.in 353 354echo "buildconf: running autoconf" 355${AUTOCONF:-autoconf} || die "The autoconf command failed" 356 357if test -d ares; then 358 cd ares 359 echo "buildconf: running in ares" 360 ./buildconf 361 cd .. 362fi 363 364echo "buildconf: running automake" 365${AUTOMAKE:-automake} -a -c || die "The automake command failed" 366 367#-------------------------------------------------------------------------- 368# Depending on the libtool and automake versions being used, config.guess 369# might not be installed in the subdirectory until automake has finished. 370# So we can not attempt to use it until this very last buildconf stage. 371# 372 373if test ! -f ./config.guess; then 374 echo "buildconf: config.guess not found" 375else 376 buildhost=`./config.guess 2>/dev/null|head -n 1` 377 case $buildhost in 378 *-*-darwin*) 379 need_lt_major=1 380 need_lt_minor=5 381 need_lt_patch=26 382 need_lt_check="yes" 383 ;; 384 *-*-hpux*) 385 need_lt_major=1 386 need_lt_minor=5 387 need_lt_patch=24 388 need_lt_check="yes" 389 ;; 390 esac 391 if test ! -z "$need_lt_check"; then 392 if test -z "$lt_major"; then 393 lt_status="bad" 394 elif test "$lt_major" -gt "$need_lt_major"; then 395 lt_status="good" 396 elif test "$lt_major" -lt "$need_lt_major"; then 397 lt_status="bad" 398 elif test -z "$lt_minor"; then 399 lt_status="bad" 400 elif test "$lt_minor" -gt "$need_lt_minor"; then 401 lt_status="good" 402 elif test "$lt_minor" -lt "$need_lt_minor"; then 403 lt_status="bad" 404 elif test -z "$lt_patch"; then 405 lt_status="bad" 406 elif test "$lt_patch" -gt "$need_lt_patch"; then 407 lt_status="good" 408 elif test "$lt_patch" -lt "$need_lt_patch"; then 409 lt_status="bad" 410 else 411 lt_status="good" 412 fi 413 if test "$lt_status" != "good"; then 414 need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch" 415 echo "buildconf: libtool version $lt_version found." 416 echo " $buildhost requires libtool $need_lt_version or newer installed." 417 rm -f configure 418 exit 1 419 fi 420 fi 421fi 422 423#-------------------------------------------------------------------------- 424# Finished successfully. 425# 426 427echo "buildconf: OK" 428exit 0 429