1#!/bin/sh 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) 1998 - 2012, 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 24#-------------------------------------------------------------------------- 25# die prints argument string to stdout and exits this shell script. 26# 27die(){ 28 echo "buildconf: $@" 29 exit 1 30} 31 32#-------------------------------------------------------------------------- 33# findtool works as 'which' but we use a different name to make it more 34# obvious we aren't using 'which'! ;-) 35# 36findtool(){ 37 file="$1" 38 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 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 || 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." 89 exit 1 90fi 91 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. 96# 97need_autoconf="2.57" 98ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'` 99if test -z "$ac_version"; then 100 echo "buildconf: autoconf not found." 101 echo " You need autoconf version $need_autoconf or newer installed." 102 exit 1 103fi 104old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS 105if 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." 111 exit 1 112fi 113 114if test "$1" = "2" -a "$2" -eq "67"; then 115 echo "buildconf: autoconf version $ac_version (BAD)" 116 echo " Unpatched version generates broken configure script." 117elif test "$1" = "2" -a "$2" -eq "68"; then 118 echo "buildconf: autoconf version $ac_version (BAD)" 119 echo " Unpatched version generates unusable configure script." 120else 121 echo "buildconf: autoconf version $ac_version (ok)" 122fi 123 124am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'` 125if test -z "$am4te_version"; then 126 echo "buildconf: autom4te not found. Weird autoconf installation!" 127 exit 1 128fi 129if test "$am4te_version" = "$ac_version"; then 130 echo "buildconf: autom4te version $am4te_version (ok)" 131else 132 echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)" 133 exit 1 134fi 135 136#-------------------------------------------------------------------------- 137# autoheader 2.50 or newer 138# 139ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'` 140if test -z "$ah_version"; then 141 echo "buildconf: autoheader not found." 142 echo " You need autoheader version 2.50 or newer installed." 143 exit 1 144fi 145old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS 146if 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." 152 exit 1 153fi 154 155echo "buildconf: autoheader version $ah_version (ok)" 156 157#-------------------------------------------------------------------------- 158# automake 1.7 or newer 159# 160need_automake="1.7" 161am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'` 162if test -z "$am_version"; then 163 echo "buildconf: automake not found." 164 echo " You need automake version $need_automake or newer installed." 165 exit 1 166fi 167old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS 168if 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." 174 exit 1 175fi 176 177echo "buildconf: automake version $am_version (ok)" 178 179acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'` 180if test -z "$acloc_version"; then 181 echo "buildconf: aclocal not found. Weird automake installation!" 182 exit 1 183fi 184if test "$acloc_version" = "$am_version"; then 185 echo "buildconf: aclocal version $acloc_version (ok)" 186else 187 echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)" 188 exit 1 189fi 190 191#-------------------------------------------------------------------------- 192# GNU libtool preliminary check 193# 194want_lt_major=1 195want_lt_minor=4 196want_lt_patch=2 197want_lt_version=1.4.2 198 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. 201 202libtool=`findtool glibtool 2>/dev/null` 203if test ! -x "$libtool"; then 204 libtool=`findtool ${LIBTOOL:-libtool}` 205fi 206if test -z "$libtool"; then 207 echo "buildconf: libtool not found." 208 echo " You need GNU libtool $want_lt_version or newer installed." 209 exit 1 210fi 211 212lt_pver=`$libtool --version 2>/dev/null|head -n 1` 213lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"` 214lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"` 215if test -z "$lt_version"; then 216 echo "buildconf: libtool not found." 217 echo " You need GNU libtool $want_lt_version or newer installed." 218 exit 1 219fi 220old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS 221lt_major=$1 222lt_minor=$2 223lt_patch=$3 224 225if test -z "$lt_major"; then 226 lt_status="bad" 227elif test "$lt_major" -gt "$want_lt_major"; then 228 lt_status="good" 229elif test "$lt_major" -lt "$want_lt_major"; then 230 lt_status="bad" 231elif test -z "$lt_minor"; then 232 lt_status="bad" 233elif test "$lt_minor" -gt "$want_lt_minor"; then 234 lt_status="good" 235elif test "$lt_minor" -lt "$want_lt_minor"; then 236 lt_status="bad" 237elif test -z "$lt_patch"; then 238 lt_status="bad" 239elif test "$lt_patch" -gt "$want_lt_patch"; then 240 lt_status="good" 241elif test "$lt_patch" -lt "$want_lt_patch"; then 242 lt_status="bad" 243else 244 lt_status="good" 245fi 246if 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." 249 exit 1 250fi 251 252echo "buildconf: libtool version $lt_version (ok)" 253 254#-------------------------------------------------------------------------- 255# GNU libtoolize check 256# 257if test -z "$LIBTOOLIZE"; then 258 # use (g)libtoolize from same location as (g)libtool 259 libtoolize="${libtool}ize" 260else 261 libtoolize=`findtool $LIBTOOLIZE` 262fi 263if test ! -f "$libtoolize"; then 264 echo "buildconf: libtoolize not found." 265 echo " You need GNU libtoolize $want_lt_version or newer installed." 266 exit 1 267fi 268 269#-------------------------------------------------------------------------- 270# m4 check 271# 272m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`; 273m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'` 274 275if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then 276 echo "buildconf: GNU m4 version $m4_version (ok)" 277else 278 if test -z "$m4"; then 279 echo "buildconf: m4 version not recognized. You need a GNU m4 installed!" 280 else 281 echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!" 282 fi 283 exit 1 284fi 285 286#-------------------------------------------------------------------------- 287# perl check 288# 289PERL=`findtool ${PERL:-perl}` 290if test -z "$PERL"; then 291 echo "buildconf: perl not found" 292 exit 1 293fi 294 295#-------------------------------------------------------------------------- 296# Remove files generated on previous buildconf/configure run. 297# 298for fname in .deps \ 299 .libs \ 300 *.la \ 301 *.lo \ 302 *.a \ 303 *.o \ 304 Makefile \ 305 Makefile.in \ 306 aclocal.m4 \ 307 aclocal.m4.bak \ 308 ares_build.h \ 309 ares_config.h \ 310 ares_config.h.in \ 311 autom4te.cache \ 312 compile \ 313 config.guess \ 314 curl_config.h \ 315 curl_config.h.in \ 316 config.log \ 317 config.lt \ 318 config.status \ 319 config.sub \ 320 configure \ 321 configurehelp.pm \ 322 curl-config \ 323 curlbuild.h \ 324 depcomp \ 325 libcares.pc \ 326 libcurl.pc \ 327 libtool \ 328 libtool.m4 \ 329 libtool.m4.tmp \ 330 ltmain.sh \ 331 ltoptions.m4 \ 332 ltsugar.m4 \ 333 ltversion.m4 \ 334 lt~obsolete.m4 \ 335 stamp-h1 \ 336 stamp-h2 \ 337 stamp-h3 ; do 338 removethis "$fname" 339done 340 341#-------------------------------------------------------------------------- 342# run the correct scripts now 343# 344 345echo "buildconf: running libtoolize" 346${libtoolize} --copy --automake --force || die "libtoolize command failed" 347 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. 351 352if 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 358 else 359 echo "buildconf: $ac_dir/libtool.m4 not found" 360 fi 361 if test -f m4/libtool.m4; then 362 echo "buildconf: renaming some variables in local m4/libtool.m4" 363 $PERL -i.tmp -pe \ 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;' \ 366 m4/libtool.m4 367 rm -f m4/libtool.m4.tmp 368 fi 369 fi 370fi 371 372if 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 376fi 377 378echo "buildconf: running aclocal" 379${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed" 380 381echo "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 383 384echo "buildconf: running autoheader" 385${AUTOHEADER:-autoheader} || die "autoheader command failed" 386 387echo "buildconf: running autoconf" 388${AUTOCONF:-autoconf} || die "autoconf command failed" 389 390if test -d ares; then 391 cd ares 392 echo "buildconf: running in ares" 393 ./buildconf 394 cd .. 395fi 396 397echo "buildconf: running automake" 398${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed" 399 400#-------------------------------------------------------------------------- 401# GNU libtool complementary check 402# 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. 406# 407if test ! -f ./config.guess; then 408 echo "buildconf: config.guess not found" 409else 410 buildhost=`./config.guess 2>/dev/null|head -n 1` 411 case $buildhost in 412 *-*-darwin*) 413 need_lt_major=1 414 need_lt_minor=5 415 need_lt_patch=26 416 need_lt_check="yes" 417 ;; 418 *-*-hpux*) 419 need_lt_major=1 420 need_lt_minor=5 421 need_lt_patch=24 422 need_lt_check="yes" 423 ;; 424 esac 425 if test ! -z "$need_lt_check"; then 426 if test -z "$lt_major"; then 427 lt_status="bad" 428 elif test "$lt_major" -gt "$need_lt_major"; then 429 lt_status="good" 430 elif test "$lt_major" -lt "$need_lt_major"; then 431 lt_status="bad" 432 elif test -z "$lt_minor"; then 433 lt_status="bad" 434 elif test "$lt_minor" -gt "$need_lt_minor"; then 435 lt_status="good" 436 elif test "$lt_minor" -lt "$need_lt_minor"; then 437 lt_status="bad" 438 elif test -z "$lt_patch"; then 439 lt_status="bad" 440 elif test "$lt_patch" -gt "$need_lt_patch"; then 441 lt_status="good" 442 elif test "$lt_patch" -lt "$need_lt_patch"; then 443 lt_status="bad" 444 else 445 lt_status="good" 446 fi 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." 451 rm -f configure 452 exit 1 453 fi 454 fi 455fi 456 457#-------------------------------------------------------------------------- 458# Finished successfully. 459# 460echo "buildconf: OK" 461exit 0 462