Annotation of embedaddon/curl/buildconf, revision 1.1.1.1

1.1       misho       1: #!/bin/sh
                      2: #***************************************************************************
                      3: #                                  _   _ ____  _
                      4: #  Project                     ___| | | |  _ \| |
                      5: #                             / __| | | | |_) | |
                      6: #                            | (__| |_| |  _ <| |___
                      7: #                             \___|\___/|_| \_\_____|
                      8: #
                      9: # Copyright (C) 1998 - 2020, 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 https://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: #
                     27: die(){
                     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: # Unlike 'which' does, the current directory is ignored.
                     36: #
                     37: findtool(){
                     38:   file="$1"
                     39: 
                     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
                     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
                     53:     if test "$path" -a "$path" != '.' -a -f "$path/$file"; then
                     54:       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: #
                     65: removethis(){
                     66:   if test "$#" = "1"; then
                     67:     find . -depth -name $1 -execdir rm -rf {} \;
                     68:   fi
                     69: }
                     70: 
                     71: #--------------------------------------------------------------------------
                     72: # Ensure that buildconf runs from the subdirectory where configure.ac lives
                     73: #
                     74: if test ! -f configure.ac ||
                     75:   test ! -f src/tool_main.c ||
                     76:   test ! -f lib/urldata.h ||
                     77:   test ! -f include/curl/curl.h ||
                     78:   test ! -f m4/curl-functions.m4; then
                     79:   echo "Can not run buildconf from outside of curl's source subdirectory!"
                     80:   echo "Change to the subdirectory where buildconf is found, and try again."
                     81:   exit 1
                     82: fi
                     83: 
                     84: #--------------------------------------------------------------------------
                     85: # autoconf 2.57 or newer. Unpatched version 2.67 does not generate proper
                     86: # configure script. Unpatched version 2.68 is simply unusable, we should
                     87: # disallow 2.68 usage.
                     88: #
                     89: need_autoconf="2.57"
                     90: ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
                     91: if test -z "$ac_version"; then
                     92:   echo "buildconf: autoconf not found."
                     93:   echo "            You need autoconf version $need_autoconf or newer installed."
                     94:   exit 1
                     95: fi
                     96: old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
                     97: if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
                     98:   echo "buildconf: autoconf version $ac_version found."
                     99:   echo "            You need autoconf version $need_autoconf or newer installed."
                    100:   echo "            If you have a sufficient autoconf installed, but it"
                    101:   echo "            is not named 'autoconf', then try setting the"
                    102:   echo "            AUTOCONF environment variable."
                    103:   exit 1
                    104: fi
                    105: 
                    106: if test "$1" = "2" -a "$2" -eq "67"; then
                    107:   echo "buildconf: autoconf version $ac_version (BAD)"
                    108:   echo "            Unpatched version generates broken configure script."
                    109: elif test "$1" = "2" -a "$2" -eq "68"; then
                    110:   echo "buildconf: autoconf version $ac_version (BAD)"
                    111:   echo "            Unpatched version generates unusable configure script."
                    112: else
                    113:   echo "buildconf: autoconf version $ac_version (ok)"
                    114: fi
                    115: 
                    116: am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
                    117: if test -z "$am4te_version"; then
                    118:   echo "buildconf: autom4te not found. Weird autoconf installation!"
                    119:   exit 1
                    120: fi
                    121: if test "$am4te_version" = "$ac_version"; then
                    122:   echo "buildconf: autom4te version $am4te_version (ok)"
                    123: else
                    124:   echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
                    125:   exit 1
                    126: fi
                    127: 
                    128: #--------------------------------------------------------------------------
                    129: # autoheader 2.50 or newer
                    130: #
                    131: ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
                    132: if test -z "$ah_version"; then
                    133:   echo "buildconf: autoheader not found."
                    134:   echo "            You need autoheader version 2.50 or newer installed."
                    135:   exit 1
                    136: fi
                    137: old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
                    138: if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
                    139:   echo "buildconf: autoheader version $ah_version found."
                    140:   echo "            You need autoheader version 2.50 or newer installed."
                    141:   echo "            If you have a sufficient autoheader installed, but it"
                    142:   echo "            is not named 'autoheader', then try setting the"
                    143:   echo "            AUTOHEADER environment variable."
                    144:   exit 1
                    145: fi
                    146: 
                    147: echo "buildconf: autoheader version $ah_version (ok)"
                    148: 
                    149: #--------------------------------------------------------------------------
                    150: # automake 1.7 or newer
                    151: #
                    152: need_automake="1.7"
                    153: 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/'`
                    154: if test -z "$am_version"; then
                    155:   echo "buildconf: automake not found."
                    156:   echo "            You need automake version $need_automake or newer installed."
                    157:   exit 1
                    158: fi
                    159: old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
                    160: if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
                    161:   echo "buildconf: automake version $am_version found."
                    162:   echo "            You need automake version $need_automake or newer installed."
                    163:   echo "            If you have a sufficient automake installed, but it"
                    164:   echo "            is not named 'automake', then try setting the"
                    165:   echo "            AUTOMAKE environment variable."
                    166:   exit 1
                    167: fi
                    168: 
                    169: echo "buildconf: automake version $am_version (ok)"
                    170: 
                    171: 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/'`
                    172: if test -z "$acloc_version"; then
                    173:   echo "buildconf: aclocal not found. Weird automake installation!"
                    174:   exit 1
                    175: fi
                    176: if test "$acloc_version" = "$am_version"; then
                    177:   echo "buildconf: aclocal version $acloc_version (ok)"
                    178: else
                    179:   echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
                    180:   exit 1
                    181: fi
                    182: 
                    183: #--------------------------------------------------------------------------
                    184: # GNU libtoolize preliminary check
                    185: #
                    186: want_lt_major=1
                    187: want_lt_minor=4
                    188: want_lt_patch=2
                    189: want_lt_version=1.4.2
                    190: 
                    191: # This approach that tries 'glibtoolize' first is intended for systems that
                    192: # have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
                    193: 
                    194: libtoolize=`findtool glibtoolize 2>/dev/null`
                    195: if test ! -x "$libtoolize"; then
                    196:   libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
                    197: fi
                    198: if test -z "$libtoolize"; then
                    199:   echo "buildconf: libtoolize not found."
                    200:   echo "  You need GNU libtoolize $want_lt_version or newer installed."
                    201:   exit 1
                    202: fi
                    203: 
                    204: lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
                    205: lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
                    206: lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
                    207: if test -z "$lt_version"; then
                    208:   echo "buildconf: libtoolize not found."
                    209:   echo "  You need GNU libtoolize $want_lt_version or newer installed."
                    210:   exit 1
                    211: fi
                    212: old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
                    213: lt_major=$1
                    214: lt_minor=$2
                    215: lt_patch=$3
                    216: 
                    217: if test -z "$lt_major"; then
                    218:   lt_status="bad"
                    219: elif test "$lt_major" -gt "$want_lt_major"; then
                    220:   lt_status="good"
                    221: elif test "$lt_major" -lt "$want_lt_major"; then
                    222:   lt_status="bad"
                    223: elif test -z "$lt_minor"; then
                    224:   lt_status="bad"
                    225: elif test "$lt_minor" -gt "$want_lt_minor"; then
                    226:   lt_status="good"
                    227: elif test "$lt_minor" -lt "$want_lt_minor"; then
                    228:   lt_status="bad"
                    229: elif test -z "$lt_patch"; then
                    230:   lt_status="bad"
                    231: elif test "$lt_patch" -gt "$want_lt_patch"; then
                    232:   lt_status="good"
                    233: elif test "$lt_patch" -lt "$want_lt_patch"; then
                    234:   lt_status="bad"
                    235: else
                    236:   lt_status="good"
                    237: fi
                    238: if test "$lt_status" != "good"; then
                    239:   echo "buildconf: libtoolize version $lt_version found."
                    240:   echo "  You need GNU libtoolize $want_lt_version or newer installed."
                    241:   exit 1
                    242: fi
                    243: 
                    244: echo "buildconf: libtoolize version $lt_version (ok)"
                    245: 
                    246: #--------------------------------------------------------------------------
                    247: # m4 check
                    248: #
                    249: m4=`(${M4:-m4} --version 0<&- || ${M4:-gm4} --version) 2>/dev/null 0<&- | head -n 1`;
                    250: m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
                    251: 
                    252: if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
                    253:   echo "buildconf: GNU m4 version $m4_version (ok)"
                    254: else
                    255:   if test -z "$m4"; then
                    256:     echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
                    257:   else
                    258:     echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
                    259:   fi
                    260:   exit 1
                    261: fi
                    262: 
                    263: #--------------------------------------------------------------------------
                    264: # perl check
                    265: #
                    266: PERL=`findtool ${PERL:-perl}`
                    267: if test -z "$PERL"; then
                    268:   echo "buildconf: perl not found"
                    269:   exit 1
                    270: fi
                    271: 
                    272: #--------------------------------------------------------------------------
                    273: # Remove files generated on previous buildconf/configure run.
                    274: #
                    275: for fname in .deps \
                    276:     .libs \
                    277:     *.la \
                    278:     *.lo \
                    279:     *.a \
                    280:     *.o \
                    281:     Makefile \
                    282:     Makefile.in \
                    283:     aclocal.m4 \
                    284:     aclocal.m4.bak \
                    285:     autom4te.cache \
                    286:     compile \
                    287:     config.guess \
                    288:     curl_config.h \
                    289:     curl_config.h.in \
                    290:     config.log \
                    291:     config.lt \
                    292:     config.status \
                    293:     config.sub \
                    294:     configure \
                    295:     configurehelp.pm \
                    296:     curl-config \
                    297:     depcomp \
                    298:     libcares.pc \
                    299:     libcurl.pc \
                    300:     libtool \
                    301:     libtool.m4 \
                    302:     libtool.m4.tmp \
                    303:     ltmain.sh \
                    304:     ltoptions.m4 \
                    305:     ltsugar.m4 \
                    306:     ltversion.m4 \
                    307:     lt~obsolete.m4 \
                    308:     missing \
                    309:     install-sh \
                    310:     stamp-h1 \
                    311:     stamp-h2 \
                    312:     stamp-h3 ; do
                    313:   removethis "$fname"
                    314: done
                    315: 
                    316: #--------------------------------------------------------------------------
                    317: # run the correct scripts now
                    318: #
                    319: 
                    320: echo "buildconf: running libtoolize"
                    321: ${libtoolize} --copy --force || die "libtoolize command failed"
                    322: 
                    323: # When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
                    324: # subdirectory and this local copy is patched to fix some warnings that
                    325: # are triggered when running aclocal and using autoconf 2.62 or later.
                    326: 
                    327: if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
                    328:   if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
                    329:     echo "buildconf: copying libtool.m4 to local m4 subdir"
                    330:     ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
                    331:     if test -f $ac_dir/libtool.m4; then
                    332:       cp -f $ac_dir/libtool.m4 m4/libtool.m4
                    333:     else
                    334:       echo "buildconf: $ac_dir/libtool.m4 not found"
                    335:     fi
                    336:     if test -f m4/libtool.m4; then
                    337:       echo "buildconf: renaming some variables in local m4/libtool.m4"
                    338:       $PERL -i.tmp -pe \
                    339:         's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
                    340:          s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
                    341:         m4/libtool.m4
                    342:       rm -f m4/libtool.m4.tmp
                    343:     fi
                    344:   fi
                    345: fi
                    346: 
                    347: if test -f m4/libtool.m4; then
                    348:   echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
                    349:   $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
                    350:   rm -f m4/libtool.m4.tmp
                    351: fi
                    352: 
                    353: echo "buildconf: running aclocal"
                    354: ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
                    355: 
                    356: echo "buildconf: converting all mv to mv -f in local aclocal.m4"
                    357: $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
                    358: 
                    359: echo "buildconf: running autoheader"
                    360: ${AUTOHEADER:-autoheader} || die "autoheader command failed"
                    361: 
                    362: echo "buildconf: running autoconf"
                    363: ${AUTOCONF:-autoconf} || die "autoconf command failed"
                    364: 
                    365: if test -d ares; then
                    366:   cd ares
                    367:   echo "buildconf: running in ares"
                    368:   ./buildconf
                    369:   cd ..
                    370: fi
                    371: 
                    372: echo "buildconf: running automake"
                    373: ${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
                    374: 
                    375: #--------------------------------------------------------------------------
                    376: # GNU libtool complementary check
                    377: #
                    378: # Depending on the libtool and automake versions being used, config.guess
                    379: # might not be installed in the subdirectory until automake has finished.
                    380: # So we can not attempt to use it until this very last buildconf stage.
                    381: #
                    382: if test ! -f ./config.guess; then
                    383:   echo "buildconf: config.guess not found"
                    384: else
                    385:   buildhost=`./config.guess 2>/dev/null|head -n 1`
                    386:   case $buildhost in
                    387:     *-*-darwin*)
                    388:       need_lt_major=1
                    389:       need_lt_minor=5
                    390:       need_lt_patch=26
                    391:       need_lt_check="yes"
                    392:       ;;
                    393:     *-*-hpux*)
                    394:       need_lt_major=1
                    395:       need_lt_minor=5
                    396:       need_lt_patch=24
                    397:       need_lt_check="yes"
                    398:       ;;
                    399:   esac
                    400:   if test ! -z "$need_lt_check"; then
                    401:     if test -z "$lt_major"; then
                    402:       lt_status="bad"
                    403:     elif test "$lt_major" -gt "$need_lt_major"; then
                    404:       lt_status="good"
                    405:     elif test "$lt_major" -lt "$need_lt_major"; then
                    406:       lt_status="bad"
                    407:     elif test -z "$lt_minor"; then
                    408:       lt_status="bad"
                    409:     elif test "$lt_minor" -gt "$need_lt_minor"; then
                    410:       lt_status="good"
                    411:     elif test "$lt_minor" -lt "$need_lt_minor"; then
                    412:       lt_status="bad"
                    413:     elif test -z "$lt_patch"; then
                    414:       lt_status="bad"
                    415:     elif test "$lt_patch" -gt "$need_lt_patch"; then
                    416:       lt_status="good"
                    417:     elif test "$lt_patch" -lt "$need_lt_patch"; then
                    418:       lt_status="bad"
                    419:     else
                    420:       lt_status="good"
                    421:     fi
                    422:     if test "$lt_status" != "good"; then
                    423:       need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
                    424:       echo "buildconf: libtool version $lt_version found."
                    425:       echo "            $buildhost requires GNU libtool $need_lt_version or newer installed."
                    426:       rm -f configure
                    427:       exit 1
                    428:     fi
                    429:   fi
                    430: fi
                    431: 
                    432: #--------------------------------------------------------------------------
                    433: # Finished successfully.
                    434: #
                    435: echo "buildconf: OK"
                    436: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>