Andy Green | 94c62c6 | 2012-10-06 15:17:01 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # a u t o g e n . s h |
| 3 | # |
| 4 | # Copyright (c) 2005-2009 United States Government as represented by |
| 5 | # the U.S. Army Research Laboratory. |
| 6 | # |
| 7 | # Redistribution and use in source and binary forms, with or without |
| 8 | # modification, are permitted provided that the following conditions |
| 9 | # are met: |
| 10 | # |
| 11 | # 1. Redistributions of source code must retain the above copyright |
| 12 | # notice, this list of conditions and the following disclaimer. |
| 13 | # |
| 14 | # 2. Redistributions in binary form must reproduce the above |
| 15 | # copyright notice, this list of conditions and the following |
| 16 | # disclaimer in the documentation and/or other materials provided |
| 17 | # with the distribution. |
| 18 | # |
| 19 | # 3. The name of the author may not be used to endorse or promote |
| 20 | # products derived from this software without specific prior written |
| 21 | # permission. |
| 22 | # |
| 23 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 24 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 25 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 27 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 29 | # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 30 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 31 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 32 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 33 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | # |
| 35 | ### |
| 36 | # |
| 37 | # Script for automatically preparing the sources for compilation by |
| 38 | # performing the myriad of necessary steps. The script attempts to |
| 39 | # detect proper version support, and outputs warnings about particular |
| 40 | # systems that have autotool peculiarities. |
| 41 | # |
| 42 | # Basically, if everything is set up and installed correctly, the |
| 43 | # script will validate that minimum versions of the GNU Build System |
| 44 | # tools are installed, account for several common configuration |
| 45 | # issues, and then simply run autoreconf for you. |
| 46 | # |
| 47 | # If autoreconf fails, which can happen for many valid configurations, |
| 48 | # this script proceeds to run manual preparation steps effectively |
| 49 | # providing a POSIX shell script (mostly complete) reimplementation of |
| 50 | # autoreconf. |
| 51 | # |
| 52 | # The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER |
| 53 | # environment variables and corresponding _OPTIONS variables (e.g. |
| 54 | # AUTORECONF_OPTIONS) may be used to override the default automatic |
| 55 | # detection behaviors. Similarly the _VERSION variables will override |
| 56 | # the minimum required version numbers. |
| 57 | # |
| 58 | # Examples: |
| 59 | # |
| 60 | # To obtain help on usage: |
| 61 | # ./autogen.sh --help |
| 62 | # |
| 63 | # To obtain verbose output: |
| 64 | # ./autogen.sh --verbose |
| 65 | # |
| 66 | # To skip autoreconf and prepare manually: |
| 67 | # AUTORECONF=false ./autogen.sh |
| 68 | # |
| 69 | # To verbosely try running with an older (unsupported) autoconf: |
| 70 | # AUTOCONF_VERSION=2.50 ./autogen.sh --verbose |
| 71 | # |
| 72 | # Author: |
| 73 | # Christopher Sean Morrison <morrison@brlcad.org> |
| 74 | # |
| 75 | # Patches: |
| 76 | # Sebastian Pipping <sebastian@pipping.org> |
| 77 | # |
| 78 | ###################################################################### |
| 79 | |
| 80 | # set to minimum acceptable version of autoconf |
| 81 | if [ "x$AUTOCONF_VERSION" = "x" ] ; then |
| 82 | AUTOCONF_VERSION=2.52 |
| 83 | fi |
| 84 | # set to minimum acceptable version of automake |
| 85 | if [ "x$AUTOMAKE_VERSION" = "x" ] ; then |
| 86 | AUTOMAKE_VERSION=1.6.0 |
| 87 | fi |
| 88 | # set to minimum acceptable version of libtool |
| 89 | if [ "x$LIBTOOL_VERSION" = "x" ] ; then |
| 90 | LIBTOOL_VERSION=1.4.2 |
| 91 | fi |
| 92 | |
| 93 | |
| 94 | ################## |
| 95 | # ident function # |
| 96 | ################## |
| 97 | ident ( ) { |
| 98 | # extract copyright from header |
| 99 | __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`" |
| 100 | if [ "x$__copyright" = "x" ] ; then |
| 101 | __copyright="`date +%Y`" |
| 102 | fi |
| 103 | |
| 104 | # extract version from CVS Id string |
| 105 | __id="$Id: autogen.sh 33925 2009-03-01 23:27:06Z brlcad $" |
| 106 | __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`" |
| 107 | if [ "x$__version" = "x" ] ; then |
| 108 | __version="" |
| 109 | fi |
| 110 | |
| 111 | echo "autogen.sh build preparation script by Christopher Sean Morrison" |
| 112 | echo " + config.guess download patch by Sebastian Pipping (2008-12-03)" |
| 113 | echo "revised 3-clause BSD-style license, copyright (c) $__copyright" |
| 114 | echo "script version $__version, ISO/IEC 9945 POSIX shell script" |
| 115 | } |
| 116 | |
| 117 | |
| 118 | ################## |
| 119 | # USAGE FUNCTION # |
| 120 | ################## |
| 121 | usage ( ) { |
| 122 | echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [-d|--download] [--version]" |
| 123 | echo " --help Help on $NAME_OF_AUTOGEN usage" |
| 124 | echo " --verbose Verbose progress output" |
| 125 | echo " --quiet Quiet suppressed progress output" |
| 126 | echo " --download Download the latest config.guess from gnulib" |
| 127 | echo " --version Only perform GNU Build System version checks" |
| 128 | echo |
| 129 | echo "Description: This script will validate that minimum versions of the" |
| 130 | echo "GNU Build System tools are installed and then run autoreconf for you." |
| 131 | echo "Should autoreconf fail, manual preparation steps will be run" |
| 132 | echo "potentially accounting for several common preparation issues. The" |
| 133 | |
| 134 | echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER," |
| 135 | echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS" |
| 136 | echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the" |
| 137 | echo "default automatic detection behavior." |
| 138 | echo |
| 139 | |
| 140 | ident |
| 141 | |
| 142 | return 0 |
| 143 | } |
| 144 | |
| 145 | |
| 146 | ########################## |
| 147 | # VERSION_ERROR FUNCTION # |
| 148 | ########################## |
| 149 | version_error ( ) { |
| 150 | if [ "x$1" = "x" ] ; then |
| 151 | echo "INTERNAL ERROR: version_error was not provided a version" |
| 152 | exit 1 |
| 153 | fi |
| 154 | if [ "x$2" = "x" ] ; then |
| 155 | echo "INTERNAL ERROR: version_error was not provided an application name" |
| 156 | exit 1 |
| 157 | fi |
| 158 | $ECHO |
| 159 | $ECHO "ERROR: To prepare the ${PROJECT} build system from scratch," |
| 160 | $ECHO " at least version $1 of $2 must be installed." |
| 161 | $ECHO |
| 162 | $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will" |
| 163 | $ECHO "run configure or make. Either the GNU Autotools will need to be installed" |
| 164 | $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source" |
| 165 | $ECHO "code on another system and then transferred to here. -- Cheers!" |
| 166 | $ECHO |
| 167 | } |
| 168 | |
| 169 | ########################## |
| 170 | # VERSION_CHECK FUNCTION # |
| 171 | ########################## |
| 172 | version_check ( ) { |
| 173 | if [ "x$1" = "x" ] ; then |
| 174 | echo "INTERNAL ERROR: version_check was not provided a minimum version" |
| 175 | exit 1 |
| 176 | fi |
| 177 | _min="$1" |
| 178 | if [ "x$2" = "x" ] ; then |
| 179 | echo "INTERNAL ERROR: version check was not provided a comparison version" |
| 180 | exit 1 |
| 181 | fi |
| 182 | _cur="$2" |
| 183 | |
| 184 | # needed to handle versions like 1.10 and 1.4-p6 |
| 185 | _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" |
| 186 | _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`" |
| 187 | |
| 188 | _min_major="`echo $_min | cut -d. -f1`" |
| 189 | _min_minor="`echo $_min | cut -d. -f2`" |
| 190 | _min_patch="`echo $_min | cut -d. -f3`" |
| 191 | |
| 192 | _cur_major="`echo $_cur | cut -d. -f1`" |
| 193 | _cur_minor="`echo $_cur | cut -d. -f2`" |
| 194 | _cur_patch="`echo $_cur | cut -d. -f3`" |
| 195 | |
| 196 | if [ "x$_min_major" = "x" ] ; then |
| 197 | _min_major=0 |
| 198 | fi |
| 199 | if [ "x$_min_minor" = "x" ] ; then |
| 200 | _min_minor=0 |
| 201 | fi |
| 202 | if [ "x$_min_patch" = "x" ] ; then |
| 203 | _min_patch=0 |
| 204 | fi |
| 205 | if [ "x$_cur_minor" = "x" ] ; then |
| 206 | _cur_major=0 |
| 207 | fi |
| 208 | if [ "x$_cur_minor" = "x" ] ; then |
| 209 | _cur_minor=0 |
| 210 | fi |
| 211 | if [ "x$_cur_patch" = "x" ] ; then |
| 212 | _cur_patch=0 |
| 213 | fi |
| 214 | |
| 215 | $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}" |
| 216 | |
| 217 | if [ $_min_major -lt $_cur_major ] ; then |
| 218 | return 0 |
| 219 | elif [ $_min_major -eq $_cur_major ] ; then |
| 220 | if [ $_min_minor -lt $_cur_minor ] ; then |
| 221 | return 0 |
| 222 | elif [ $_min_minor -eq $_cur_minor ] ; then |
| 223 | if [ $_min_patch -lt $_cur_patch ] ; then |
| 224 | return 0 |
| 225 | elif [ $_min_patch -eq $_cur_patch ] ; then |
| 226 | return 0 |
| 227 | fi |
| 228 | fi |
| 229 | fi |
| 230 | return 1 |
| 231 | } |
| 232 | |
| 233 | |
| 234 | ###################################### |
| 235 | # LOCATE_CONFIGURE_TEMPLATE FUNCTION # |
| 236 | ###################################### |
| 237 | locate_configure_template ( ) { |
| 238 | _pwd="`pwd`" |
| 239 | if test -f "./configure.ac" ; then |
| 240 | echo "./configure.ac" |
| 241 | elif test -f "./configure.in" ; then |
| 242 | echo "./configure.in" |
| 243 | elif test -f "$_pwd/configure.ac" ; then |
| 244 | echo "$_pwd/configure.ac" |
| 245 | elif test -f "$_pwd/configure.in" ; then |
| 246 | echo "$_pwd/configure.in" |
| 247 | elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then |
| 248 | echo "$PATH_TO_AUTOGEN/configure.ac" |
| 249 | elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then |
| 250 | echo "$PATH_TO_AUTOGEN/configure.in" |
| 251 | fi |
| 252 | } |
| 253 | |
| 254 | |
| 255 | ################## |
| 256 | # argument check # |
| 257 | ################## |
| 258 | ARGS="$*" |
| 259 | PATH_TO_AUTOGEN="`dirname $0`" |
| 260 | NAME_OF_AUTOGEN="`basename $0`" |
| 261 | AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN" |
| 262 | |
| 263 | LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4" |
| 264 | |
| 265 | if [ "x$HELP" = "x" ] ; then |
| 266 | HELP=no |
| 267 | fi |
| 268 | if [ "x$QUIET" = "x" ] ; then |
| 269 | QUIET=no |
| 270 | fi |
| 271 | if [ "x$VERBOSE" = "x" ] ; then |
| 272 | VERBOSE=no |
| 273 | fi |
| 274 | if [ "x$VERSION_ONLY" = "x" ] ; then |
| 275 | VERSION_ONLY=no |
| 276 | fi |
| 277 | if [ "x$DOWNLOAD" = "x" ] ; then |
| 278 | DOWNLOAD=no |
| 279 | fi |
| 280 | if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then |
| 281 | AUTORECONF_OPTIONS="-i -f" |
| 282 | fi |
| 283 | if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then |
| 284 | AUTOCONF_OPTIONS="-f" |
| 285 | fi |
| 286 | if [ "x$AUTOMAKE_OPTIONS" = "x" ] ; then |
| 287 | AUTOMAKE_OPTIONS="-a -c -f" |
| 288 | fi |
| 289 | ALT_AUTOMAKE_OPTIONS="-a -c" |
| 290 | if [ "x$LIBTOOLIZE_OPTIONS" = "x" ] ; then |
| 291 | LIBTOOLIZE_OPTIONS="--automake -c -f" |
| 292 | fi |
| 293 | ALT_LIBTOOLIZE_OPTIONS="--automake --copy --force" |
| 294 | if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then |
| 295 | ACLOCAL_OPTIONS="" |
| 296 | fi |
| 297 | if [ "x$AUTOHEADER_OPTIONS" = "x" ] ; then |
| 298 | AUTOHEADER_OPTIONS="" |
| 299 | fi |
| 300 | if [ "x$CONFIG_GUESS_URL" = "x" ] ; then |
| 301 | CONFIG_GUESS_URL="http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/config.guess;hb=HEAD" |
| 302 | fi |
| 303 | for arg in $ARGS ; do |
| 304 | case "x$arg" in |
| 305 | x--help) HELP=yes ;; |
| 306 | x-[hH]) HELP=yes ;; |
| 307 | x--quiet) QUIET=yes ;; |
| 308 | x-[qQ]) QUIET=yes ;; |
| 309 | x--verbose) VERBOSE=yes ;; |
| 310 | x-[dD]) DOWNLOAD=yes ;; |
| 311 | x--download) DOWNLOAD=yes ;; |
| 312 | x-[vV]) VERBOSE=yes ;; |
| 313 | x--version) VERSION_ONLY=yes ;; |
| 314 | *) |
| 315 | echo "Unknown option: $arg" |
| 316 | echo |
| 317 | usage |
| 318 | exit 1 |
| 319 | ;; |
| 320 | esac |
| 321 | done |
| 322 | |
| 323 | |
| 324 | ##################### |
| 325 | # environment check # |
| 326 | ##################### |
| 327 | |
| 328 | # sanity check before recursions potentially begin |
| 329 | if [ ! -f "$AUTOGEN_SH" ] ; then |
| 330 | echo "INTERNAL ERROR: $AUTOGEN_SH does not exist" |
| 331 | if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then |
| 332 | echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH" |
| 333 | fi |
| 334 | exit 1 |
| 335 | fi |
| 336 | |
| 337 | # force locale setting to C so things like date output as expected |
| 338 | LC_ALL=C |
| 339 | |
| 340 | # commands that this script expects |
| 341 | for __cmd in echo head tail pwd ; do |
| 342 | echo "test" | $__cmd > /dev/null 2>&1 |
| 343 | if [ $? != 0 ] ; then |
| 344 | echo "INTERNAL ERROR: '${__cmd}' command is required" |
| 345 | exit 2 |
| 346 | fi |
| 347 | done |
| 348 | echo "test" | grep "test" > /dev/null 2>&1 |
| 349 | if test ! x$? = x0 ; then |
| 350 | echo "INTERNAL ERROR: grep command is required" |
| 351 | exit 1 |
| 352 | fi |
| 353 | echo "test" | sed "s/test/test/" > /dev/null 2>&1 |
| 354 | if test ! x$? = x0 ; then |
| 355 | echo "INTERNAL ERROR: sed command is required" |
| 356 | exit 1 |
| 357 | fi |
| 358 | |
| 359 | |
| 360 | # determine the behavior of echo |
| 361 | case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in |
| 362 | *c*,-n*) ECHO_N= ECHO_C=' |
| 363 | ' ECHO_T=' ' ;; |
| 364 | *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; |
| 365 | *) ECHO_N= ECHO_C='\c' ECHO_T= ;; |
| 366 | esac |
| 367 | |
| 368 | # determine the behavior of head |
| 369 | case "x`echo 'head' | head -n 1 2>&1`" in |
| 370 | *xhead*) HEAD_N="n " ;; |
| 371 | *) HEAD_N="" ;; |
| 372 | esac |
| 373 | |
| 374 | # determine the behavior of tail |
| 375 | case "x`echo 'tail' | tail -n 1 2>&1`" in |
| 376 | *xtail*) TAIL_N="n " ;; |
| 377 | *) TAIL_N="" ;; |
| 378 | esac |
| 379 | |
| 380 | VERBOSE_ECHO=: |
| 381 | ECHO=: |
| 382 | if [ "x$QUIET" = "xyes" ] ; then |
| 383 | if [ "x$VERBOSE" = "xyes" ] ; then |
| 384 | echo "Verbose output quelled by quiet option. Further output disabled." |
| 385 | fi |
| 386 | else |
| 387 | ECHO=echo |
| 388 | if [ "x$VERBOSE" = "xyes" ] ; then |
| 389 | echo "Verbose output enabled" |
| 390 | VERBOSE_ECHO=echo |
| 391 | fi |
| 392 | fi |
| 393 | |
| 394 | |
| 395 | # allow a recursive run to disable further recursions |
| 396 | if [ "x$RUN_RECURSIVE" = "x" ] ; then |
| 397 | RUN_RECURSIVE=yes |
| 398 | fi |
| 399 | |
| 400 | |
| 401 | ################################################ |
| 402 | # check for help arg and bypass version checks # |
| 403 | ################################################ |
| 404 | if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then |
| 405 | HELP=yes |
| 406 | fi |
| 407 | if [ "x$HELP" = "xyes" ] ; then |
| 408 | usage |
| 409 | $ECHO "---" |
| 410 | $ECHO "Help was requested. No preparation or configuration will be performed." |
| 411 | exit 0 |
| 412 | fi |
| 413 | |
| 414 | |
| 415 | ####################### |
| 416 | # set up signal traps # |
| 417 | ####################### |
| 418 | untrap_abnormal ( ) { |
| 419 | for sig in 1 2 13 15; do |
| 420 | trap - $sig |
| 421 | done |
| 422 | } |
| 423 | |
| 424 | # do this cleanup whenever we exit. |
| 425 | trap ' |
| 426 | # start from the root |
| 427 | if test -d "$START_PATH" ; then |
| 428 | cd "$START_PATH" |
| 429 | fi |
| 430 | |
| 431 | # restore/delete backup files |
| 432 | if test "x$PFC_INIT" = "x1" ; then |
| 433 | recursive_restore |
| 434 | fi |
| 435 | ' 0 |
| 436 | |
| 437 | # trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15) |
| 438 | for sig in 1 2 13 15; do |
| 439 | trap ' |
| 440 | $ECHO "" |
| 441 | $ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'" |
| 442 | |
| 443 | # start from the root |
| 444 | if test -d "$START_PATH" ; then |
| 445 | cd "$START_PATH" |
| 446 | fi |
| 447 | |
| 448 | # clean up on abnormal exit |
| 449 | $VERBOSE_ECHO "rm -rf autom4te.cache" |
| 450 | rm -rf autom4te.cache |
| 451 | |
| 452 | if test -f "acinclude.m4.$$.backup" ; then |
| 453 | $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4" |
| 454 | chmod u+w acinclude.m4 |
| 455 | cat acinclude.m4.$$.backup > acinclude.m4 |
| 456 | |
| 457 | $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup" |
| 458 | rm -f acinclude.m4.$$.backup |
| 459 | fi |
| 460 | |
| 461 | { (exit 1); exit 1; } |
| 462 | ' $sig |
| 463 | done |
| 464 | |
| 465 | |
| 466 | ############################# |
| 467 | # look for a configure file # |
| 468 | ############################# |
| 469 | if [ "x$CONFIGURE" = "x" ] ; then |
| 470 | CONFIGURE="`locate_configure_template`" |
| 471 | if [ ! "x$CONFIGURE" = "x" ] ; then |
| 472 | $VERBOSE_ECHO "Found a configure template: $CONFIGURE" |
| 473 | fi |
| 474 | else |
| 475 | $ECHO "Using CONFIGURE environment variable override: $CONFIGURE" |
| 476 | fi |
| 477 | if [ "x$CONFIGURE" = "x" ] ; then |
| 478 | if [ "x$VERSION_ONLY" = "xyes" ] ; then |
| 479 | CONFIGURE=/dev/null |
| 480 | else |
| 481 | $ECHO |
| 482 | $ECHO "A configure.ac or configure.in file could not be located implying" |
| 483 | $ECHO "that the GNU Build System is at least not used in this directory. In" |
| 484 | $ECHO "any case, there is nothing to do here without one of those files." |
| 485 | $ECHO |
| 486 | $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" |
| 487 | exit 1 |
| 488 | fi |
| 489 | fi |
| 490 | |
| 491 | #################### |
| 492 | # get project name # |
| 493 | #################### |
| 494 | if [ "x$PROJECT" = "x" ] ; then |
| 495 | PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 496 | if [ "x$PROJECT" = "xAC_INIT" ] ; then |
| 497 | # projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead |
| 498 | PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 499 | fi |
| 500 | if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then |
| 501 | PROJECT="project" |
| 502 | fi |
| 503 | if [ "x$PROJECT" = "x" ] ; then |
| 504 | PROJECT="project" |
| 505 | fi |
| 506 | else |
| 507 | $ECHO "Using PROJECT environment variable override: $PROJECT" |
| 508 | fi |
| 509 | $ECHO "Preparing the $PROJECT build system...please wait" |
| 510 | $ECHO |
| 511 | |
| 512 | |
| 513 | ######################## |
| 514 | # check for autoreconf # |
| 515 | ######################## |
| 516 | HAVE_AUTORECONF=no |
| 517 | if [ "x$AUTORECONF" = "x" ] ; then |
| 518 | for AUTORECONF in autoreconf ; do |
| 519 | $VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version" |
| 520 | $AUTORECONF --version > /dev/null 2>&1 |
| 521 | if [ $? = 0 ] ; then |
| 522 | HAVE_AUTORECONF=yes |
| 523 | break |
| 524 | fi |
| 525 | done |
| 526 | else |
| 527 | HAVE_AUTORECONF=yes |
| 528 | $ECHO "Using AUTORECONF environment variable override: $AUTORECONF" |
| 529 | fi |
| 530 | |
| 531 | |
| 532 | ########################## |
| 533 | # autoconf version check # |
| 534 | ########################## |
| 535 | _acfound=no |
| 536 | if [ "x$AUTOCONF" = "x" ] ; then |
| 537 | for AUTOCONF in autoconf ; do |
| 538 | $VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version" |
| 539 | $AUTOCONF --version > /dev/null 2>&1 |
| 540 | if [ $? = 0 ] ; then |
| 541 | _acfound=yes |
| 542 | break |
| 543 | fi |
| 544 | done |
| 545 | else |
| 546 | _acfound=yes |
| 547 | $ECHO "Using AUTOCONF environment variable override: $AUTOCONF" |
| 548 | fi |
| 549 | |
| 550 | _report_error=no |
| 551 | if [ ! "x$_acfound" = "xyes" ] ; then |
| 552 | $ECHO "ERROR: Unable to locate GNU Autoconf." |
| 553 | _report_error=yes |
| 554 | else |
| 555 | _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" |
| 556 | if [ "x$_version" = "x" ] ; then |
| 557 | _version="0.0.0" |
| 558 | fi |
| 559 | $ECHO "Found GNU Autoconf version $_version" |
| 560 | version_check "$AUTOCONF_VERSION" "$_version" |
| 561 | if [ $? -ne 0 ] ; then |
| 562 | _report_error=yes |
| 563 | fi |
| 564 | fi |
| 565 | if [ "x$_report_error" = "xyes" ] ; then |
| 566 | version_error "$AUTOCONF_VERSION" "GNU Autoconf" |
| 567 | exit 1 |
| 568 | fi |
| 569 | |
| 570 | |
| 571 | ########################## |
| 572 | # automake version check # |
| 573 | ########################## |
| 574 | _amfound=no |
| 575 | if [ "x$AUTOMAKE" = "x" ] ; then |
| 576 | for AUTOMAKE in automake ; do |
| 577 | $VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version" |
| 578 | $AUTOMAKE --version > /dev/null 2>&1 |
| 579 | if [ $? = 0 ] ; then |
| 580 | _amfound=yes |
| 581 | break |
| 582 | fi |
| 583 | done |
| 584 | else |
| 585 | _amfound=yes |
| 586 | $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE" |
| 587 | fi |
| 588 | |
| 589 | |
| 590 | _report_error=no |
| 591 | if [ ! "x$_amfound" = "xyes" ] ; then |
| 592 | $ECHO |
| 593 | $ECHO "ERROR: Unable to locate GNU Automake." |
| 594 | _report_error=yes |
| 595 | else |
| 596 | _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" |
| 597 | if [ "x$_version" = "x" ] ; then |
| 598 | _version="0.0.0" |
| 599 | fi |
| 600 | $ECHO "Found GNU Automake version $_version" |
| 601 | version_check "$AUTOMAKE_VERSION" "$_version" |
| 602 | if [ $? -ne 0 ] ; then |
| 603 | _report_error=yes |
| 604 | fi |
| 605 | fi |
| 606 | if [ "x$_report_error" = "xyes" ] ; then |
| 607 | version_error "$AUTOMAKE_VERSION" "GNU Automake" |
| 608 | exit 1 |
| 609 | fi |
| 610 | |
| 611 | |
| 612 | ######################## |
| 613 | # check for libtoolize # |
| 614 | ######################## |
| 615 | HAVE_LIBTOOLIZE=yes |
| 616 | HAVE_ALT_LIBTOOLIZE=no |
| 617 | _ltfound=no |
| 618 | if [ "x$LIBTOOLIZE" = "x" ] ; then |
| 619 | LIBTOOLIZE=libtoolize |
| 620 | $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version" |
| 621 | $LIBTOOLIZE --version > /dev/null 2>&1 |
| 622 | if [ ! $? = 0 ] ; then |
| 623 | HAVE_LIBTOOLIZE=no |
| 624 | $ECHO |
| 625 | if [ "x$HAVE_AUTORECONF" = "xno" ] ; then |
| 626 | $ECHO "Warning: libtoolize does not appear to be available." |
| 627 | else |
| 628 | $ECHO "Warning: libtoolize does not appear to be available. This means that" |
| 629 | $ECHO "the automatic build preparation via autoreconf will probably not work." |
| 630 | $ECHO "Preparing the build by running each step individually, however, should" |
| 631 | $ECHO "work and will be done automatically for you if autoreconf fails." |
| 632 | fi |
| 633 | |
| 634 | # look for some alternates |
| 635 | for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do |
| 636 | $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version" |
| 637 | _glibtoolize="`$tool --version > /dev/null 2>&1`" |
| 638 | if [ $? = 0 ] ; then |
| 639 | $VERBOSE_ECHO "Found $tool --version" |
| 640 | _glti="`which $tool`" |
| 641 | if [ "x$_glti" = "x" ] ; then |
| 642 | $VERBOSE_ECHO "Cannot find $tool with which" |
| 643 | continue; |
| 644 | fi |
| 645 | if test ! -f "$_glti" ; then |
| 646 | $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file" |
| 647 | continue; |
| 648 | fi |
| 649 | _gltidir="`dirname $_glti`" |
| 650 | if [ "x$_gltidir" = "x" ] ; then |
| 651 | $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti" |
| 652 | continue; |
| 653 | fi |
| 654 | if test ! -d "$_gltidir" ; then |
| 655 | $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory" |
| 656 | continue; |
| 657 | fi |
| 658 | HAVE_ALT_LIBTOOLIZE=yes |
| 659 | LIBTOOLIZE="$tool" |
| 660 | $ECHO |
| 661 | $ECHO "Fortunately, $tool was found which means that your system may simply" |
| 662 | $ECHO "have a non-standard or incomplete GNU Autotools install. If you have" |
| 663 | $ECHO "sufficient system access, it may be possible to quell this warning by" |
| 664 | $ECHO "running:" |
| 665 | $ECHO |
| 666 | sudo -V > /dev/null 2>&1 |
| 667 | if [ $? = 0 ] ; then |
| 668 | $ECHO " sudo ln -s $_glti $_gltidir/libtoolize" |
| 669 | $ECHO |
| 670 | else |
| 671 | $ECHO " ln -s $_glti $_gltidir/libtoolize" |
| 672 | $ECHO |
| 673 | $ECHO "Run that as root or with proper permissions to the $_gltidir directory" |
| 674 | $ECHO |
| 675 | fi |
| 676 | _ltfound=yes |
| 677 | break |
| 678 | fi |
| 679 | done |
| 680 | else |
| 681 | _ltfound=yes |
| 682 | fi |
| 683 | else |
| 684 | _ltfound=yes |
| 685 | $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE" |
| 686 | fi |
| 687 | |
| 688 | |
| 689 | ############################ |
| 690 | # libtoolize version check # |
| 691 | ############################ |
| 692 | _report_error=no |
| 693 | if [ ! "x$_ltfound" = "xyes" ] ; then |
| 694 | $ECHO |
| 695 | $ECHO "ERROR: Unable to locate GNU Libtool." |
| 696 | _report_error=yes |
| 697 | else |
| 698 | _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`" |
| 699 | if [ "x$_version" = "x" ] ; then |
| 700 | _version="0.0.0" |
| 701 | fi |
| 702 | $ECHO "Found GNU Libtool version $_version" |
| 703 | version_check "$LIBTOOL_VERSION" "$_version" |
| 704 | if [ $? -ne 0 ] ; then |
| 705 | _report_error=yes |
| 706 | fi |
| 707 | fi |
| 708 | if [ "x$_report_error" = "xyes" ] ; then |
| 709 | version_error "$LIBTOOL_VERSION" "GNU Libtool" |
| 710 | exit 1 |
| 711 | fi |
| 712 | |
| 713 | |
| 714 | ##################### |
| 715 | # check for aclocal # |
| 716 | ##################### |
| 717 | if [ "x$ACLOCAL" = "x" ] ; then |
| 718 | for ACLOCAL in aclocal ; do |
| 719 | $VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version" |
| 720 | $ACLOCAL --version > /dev/null 2>&1 |
| 721 | if [ $? = 0 ] ; then |
| 722 | break |
| 723 | fi |
| 724 | done |
| 725 | else |
| 726 | $ECHO "Using ACLOCAL environment variable override: $ACLOCAL" |
| 727 | fi |
| 728 | |
| 729 | |
| 730 | ######################## |
| 731 | # check for autoheader # |
| 732 | ######################## |
| 733 | if [ "x$AUTOHEADER" = "x" ] ; then |
| 734 | for AUTOHEADER in autoheader ; do |
| 735 | $VERBOSE_ECHO "Checking autoheader version: $AUTOHEADER --version" |
| 736 | $AUTOHEADER --version > /dev/null 2>&1 |
| 737 | if [ $? = 0 ] ; then |
| 738 | break |
| 739 | fi |
| 740 | done |
| 741 | else |
| 742 | $ECHO "Using AUTOHEADER environment variable override: $AUTOHEADER" |
| 743 | fi |
| 744 | |
| 745 | |
| 746 | ######################### |
| 747 | # check if version only # |
| 748 | ######################### |
| 749 | $VERBOSE_ECHO "Checking whether to only output version information" |
| 750 | if [ "x$VERSION_ONLY" = "xyes" ] ; then |
| 751 | $ECHO |
| 752 | ident |
| 753 | $ECHO "---" |
| 754 | $ECHO "Version requested. No preparation or configuration will be performed." |
| 755 | exit 0 |
| 756 | fi |
| 757 | |
| 758 | |
| 759 | ################################# |
| 760 | # PROTECT_FROM_CLOBBER FUNCTION # |
| 761 | ################################# |
| 762 | protect_from_clobber ( ) { |
| 763 | PFC_INIT=1 |
| 764 | |
| 765 | # protect COPYING & INSTALL from overwrite by automake. the |
| 766 | # automake force option will (inappropriately) ignore the existing |
| 767 | # contents of a COPYING and/or INSTALL files (depending on the |
| 768 | # version) instead of just forcing *missing* files like it does |
| 769 | # for AUTHORS, NEWS, and README. this is broken but extremely |
| 770 | # prevalent behavior, so we protect against it by keeping a backup |
| 771 | # of the file that can later be restored. |
| 772 | |
| 773 | for file in COPYING INSTALL ; do |
| 774 | if test -f ${file} ; then |
| 775 | if test -f ${file}.$$.protect_from_automake.backup ; then |
| 776 | $VERBOSE_ECHO "Already backed up ${file} in `pwd`" |
| 777 | else |
| 778 | $VERBOSE_ECHO "Backing up ${file} in `pwd`" |
| 779 | $VERBOSE_ECHO "cp -p ${file} ${file}.$$.protect_from_automake.backup" |
| 780 | cp -p ${file} ${file}.$$.protect_from_automake.backup |
| 781 | fi |
| 782 | fi |
| 783 | done |
| 784 | } |
| 785 | |
| 786 | |
| 787 | ############################## |
| 788 | # RECURSIVE_PROTECT FUNCTION # |
| 789 | ############################## |
| 790 | recursive_protect ( ) { |
| 791 | |
| 792 | # for projects using recursive configure, run the build |
| 793 | # preparation steps for the subdirectories. this function assumes |
| 794 | # START_PATH was set to pwd before recursion begins so that |
| 795 | # relative paths work. |
| 796 | |
| 797 | # git 'r done, protect COPYING and INSTALL from being clobbered |
| 798 | protect_from_clobber |
| 799 | |
| 800 | if test -d autom4te.cache ; then |
| 801 | $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" |
| 802 | $VERBOSE_ECHO "rm -rf autom4te.cache" |
| 803 | rm -rf autom4te.cache |
| 804 | fi |
| 805 | |
| 806 | # find configure template |
| 807 | _configure="`locate_configure_template`" |
| 808 | if [ "x$_configure" = "x" ] ; then |
| 809 | return |
| 810 | fi |
| 811 | # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure" |
| 812 | |
| 813 | # look for subdirs |
| 814 | # $VERBOSE_ECHO "Looking for subdirs in `pwd`" |
| 815 | _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 816 | CHECK_DIRS="" |
| 817 | for dir in $_det_config_subdirs ; do |
| 818 | if test -d "`pwd`/$dir" ; then |
| 819 | CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" |
| 820 | fi |
| 821 | done |
| 822 | |
| 823 | # process subdirs |
| 824 | if [ ! "x$CHECK_DIRS" = "x" ] ; then |
| 825 | $VERBOSE_ECHO "Recursively scanning the following directories:" |
| 826 | $VERBOSE_ECHO " $CHECK_DIRS" |
| 827 | for dir in $CHECK_DIRS ; do |
| 828 | $VERBOSE_ECHO "Protecting files from automake in $dir" |
| 829 | cd "$START_PATH" |
| 830 | eval "cd $dir" |
| 831 | |
| 832 | # recursively git 'r done |
| 833 | recursive_protect |
| 834 | done |
| 835 | fi |
| 836 | } # end of recursive_protect |
| 837 | |
| 838 | |
| 839 | ############################# |
| 840 | # RESTORE_CLOBBERED FUNCION # |
| 841 | ############################# |
| 842 | restore_clobbered ( ) { |
| 843 | |
| 844 | # The automake (and autoreconf by extension) -f/--force-missing |
| 845 | # option may overwrite COPYING and INSTALL even if they do exist. |
| 846 | # Here we restore the files if necessary. |
| 847 | |
| 848 | spacer=no |
| 849 | |
| 850 | for file in COPYING INSTALL ; do |
| 851 | if test -f ${file}.$$.protect_from_automake.backup ; then |
| 852 | if test -f ${file} ; then |
| 853 | # compare entire content, restore if needed |
| 854 | if test "x`cat ${file}`" != "x`cat ${file}.$$.protect_from_automake.backup`" ; then |
| 855 | if test "x$spacer" = "xno" ; then |
| 856 | $VERBOSE_ECHO |
| 857 | spacer=yes |
| 858 | fi |
| 859 | # restore the backup |
| 860 | $VERBOSE_ECHO "Restoring ${file} from backup (automake -f likely clobbered it)" |
| 861 | $VERBOSE_ECHO "rm -f ${file}" |
| 862 | rm -f ${file} |
| 863 | $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" |
| 864 | mv ${file}.$$.protect_from_automake.backup ${file} |
| 865 | fi # check contents |
| 866 | elif test -f ${file}.$$.protect_from_automake.backup ; then |
| 867 | $VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}" |
| 868 | mv ${file}.$$.protect_from_automake.backup ${file} |
| 869 | fi # -f ${file} |
| 870 | |
| 871 | # just in case |
| 872 | $VERBOSE_ECHO "rm -f ${file}.$$.protect_from_automake.backup" |
| 873 | rm -f ${file}.$$.protect_from_automake.backup |
| 874 | fi # -f ${file}.$$.protect_from_automake.backup |
| 875 | done |
| 876 | |
| 877 | CONFIGURE="`locate_configure_template`" |
| 878 | if [ "x$CONFIGURE" = "x" ] ; then |
| 879 | return |
| 880 | fi |
| 881 | |
| 882 | _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 883 | if test ! -d "$_aux_dir" ; then |
| 884 | _aux_dir=. |
| 885 | fi |
| 886 | |
| 887 | for file in config.guess config.sub ltmain.sh ; do |
| 888 | if test -f "${_aux_dir}/${file}" ; then |
| 889 | $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\"" |
| 890 | rm -f "${_aux_dir}/${file}.backup" |
| 891 | fi |
| 892 | done |
| 893 | } # end of restore_clobbered |
| 894 | |
| 895 | |
| 896 | ############################## |
| 897 | # RECURSIVE_RESTORE FUNCTION # |
| 898 | ############################## |
| 899 | recursive_restore ( ) { |
| 900 | |
| 901 | # restore COPYING and INSTALL from backup if they were clobbered |
| 902 | # for each directory recursively. |
| 903 | |
| 904 | # git 'r undone |
| 905 | restore_clobbered |
| 906 | |
| 907 | # find configure template |
| 908 | _configure="`locate_configure_template`" |
| 909 | if [ "x$_configure" = "x" ] ; then |
| 910 | return |
| 911 | fi |
| 912 | |
| 913 | # look for subdirs |
| 914 | _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 915 | CHECK_DIRS="" |
| 916 | for dir in $_det_config_subdirs ; do |
| 917 | if test -d "`pwd`/$dir" ; then |
| 918 | CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\"" |
| 919 | fi |
| 920 | done |
| 921 | |
| 922 | # process subdirs |
| 923 | if [ ! "x$CHECK_DIRS" = "x" ] ; then |
| 924 | $VERBOSE_ECHO "Recursively scanning the following directories:" |
| 925 | $VERBOSE_ECHO " $CHECK_DIRS" |
| 926 | for dir in $CHECK_DIRS ; do |
| 927 | $VERBOSE_ECHO "Checking files for automake damage in $dir" |
| 928 | cd "$START_PATH" |
| 929 | eval "cd $dir" |
| 930 | |
| 931 | # recursively git 'r undone |
| 932 | recursive_restore |
| 933 | done |
| 934 | fi |
| 935 | } # end of recursive_restore |
| 936 | |
| 937 | |
| 938 | ####################### |
| 939 | # INITIALIZE FUNCTION # |
| 940 | ####################### |
| 941 | initialize ( ) { |
| 942 | |
| 943 | # this routine performs a variety of directory-specific |
| 944 | # initializations. some are sanity checks, some are preventive, |
| 945 | # and some are necessary setup detection. |
| 946 | # |
| 947 | # this function sets: |
| 948 | # CONFIGURE |
| 949 | # SEARCH_DIRS |
| 950 | # CONFIG_SUBDIRS |
| 951 | |
| 952 | ################################## |
| 953 | # check for a configure template # |
| 954 | ################################## |
| 955 | CONFIGURE="`locate_configure_template`" |
| 956 | if [ "x$CONFIGURE" = "x" ] ; then |
| 957 | $ECHO |
| 958 | $ECHO "A configure.ac or configure.in file could not be located implying" |
| 959 | $ECHO "that the GNU Build System is at least not used in this directory. In" |
| 960 | $ECHO "any case, there is nothing to do here without one of those files." |
| 961 | $ECHO |
| 962 | $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`" |
| 963 | exit 1 |
| 964 | fi |
| 965 | |
| 966 | ##################### |
| 967 | # detect an aux dir # |
| 968 | ##################### |
| 969 | _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 970 | if test ! -d "$_aux_dir" ; then |
| 971 | _aux_dir=. |
| 972 | else |
| 973 | $VERBOSE_ECHO "Detected auxillary directory: $_aux_dir" |
| 974 | fi |
| 975 | |
| 976 | ################################ |
| 977 | # detect a recursive configure # |
| 978 | ################################ |
| 979 | CONFIG_SUBDIRS="" |
| 980 | _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`" |
| 981 | for dir in $_det_config_subdirs ; do |
| 982 | if test -d "`pwd`/$dir" ; then |
| 983 | $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir" |
| 984 | CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir" |
| 985 | fi |
| 986 | done |
| 987 | |
| 988 | ########################################################### |
| 989 | # make sure certain required files exist for GNU projects # |
| 990 | ########################################################### |
| 991 | _marker_found="" |
| 992 | _marker_found_message_intro='Detected non-GNU marker "' |
| 993 | _marker_found_message_mid='" in ' |
| 994 | for marker in foreign cygnus ; do |
| 995 | _marker_found_message=${_marker_found_message_intro}${marker}${_marker_found_message_mid} |
| 996 | _marker_found="`grep 'AM_INIT_AUTOMAKE.*'${marker} $CONFIGURE`" |
| 997 | if [ ! "x$_marker_found" = "x" ] ; then |
| 998 | $VERBOSE_ECHO "${_marker_found_message}`basename \"$CONFIGURE\"`" |
| 999 | break |
| 1000 | fi |
| 1001 | if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then |
| 1002 | _marker_found="`grep 'AUTOMAKE_OPTIONS.*'${marker} Makefile.am`" |
| 1003 | if [ ! "x$_marker_found" = "x" ] ; then |
| 1004 | $VERBOSE_ECHO "${_marker_found_message}Makefile.am" |
| 1005 | break |
| 1006 | fi |
| 1007 | fi |
| 1008 | done |
| 1009 | if [ "x${_marker_found}" = "x" ] ; then |
| 1010 | _suggest_foreign=no |
| 1011 | for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do |
| 1012 | if [ ! -f $file ] ; then |
| 1013 | $VERBOSE_ECHO "Touching ${file} since it does not exist" |
| 1014 | _suggest_foreign=yes |
| 1015 | touch $file |
| 1016 | fi |
| 1017 | done |
| 1018 | |
| 1019 | if [ "x${_suggest_foreign}" = "xyes" ] ; then |
| 1020 | $ECHO |
| 1021 | $ECHO "Warning: Several files expected of projects that conform to the GNU" |
| 1022 | $ECHO "coding standards were not found. The files were automatically added" |
| 1023 | $ECHO "for you since you do not have a 'foreign' declaration specified." |
| 1024 | $ECHO |
| 1025 | $ECHO "Considered adding 'foreign' to AM_INIT_AUTOMAKE in `basename \"$CONFIGURE\"`" |
| 1026 | if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then |
| 1027 | $ECHO "or to AUTOMAKE_OPTIONS in your top-level Makefile.am file." |
| 1028 | fi |
| 1029 | $ECHO |
| 1030 | fi |
| 1031 | fi |
| 1032 | |
| 1033 | ################################################## |
| 1034 | # make sure certain generated files do not exist # |
| 1035 | ################################################## |
| 1036 | for file in config.guess config.sub ltmain.sh ; do |
| 1037 | if test -f "${_aux_dir}/${file}" ; then |
| 1038 | $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\"" |
| 1039 | mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup" |
| 1040 | fi |
| 1041 | done |
| 1042 | |
| 1043 | ############################ |
| 1044 | # search alternate m4 dirs # |
| 1045 | ############################ |
| 1046 | SEARCH_DIRS="" |
| 1047 | for dir in m4 ; do |
| 1048 | if [ -d $dir ] ; then |
| 1049 | $VERBOSE_ECHO "Found extra aclocal search directory: $dir" |
| 1050 | SEARCH_DIRS="$SEARCH_DIRS -I $dir" |
| 1051 | fi |
| 1052 | done |
| 1053 | |
| 1054 | ###################################### |
| 1055 | # remove any previous build products # |
| 1056 | ###################################### |
| 1057 | if test -d autom4te.cache ; then |
| 1058 | $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it" |
| 1059 | $VERBOSE_ECHO "rm -rf autom4te.cache" |
| 1060 | rm -rf autom4te.cache |
| 1061 | fi |
| 1062 | # tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it |
| 1063 | # if test -f aclocal.m4 ; then |
| 1064 | # $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it" |
| 1065 | # $VERBOSE_ECHO "rm -f aclocal.m4" |
| 1066 | # rm -f aclocal.m4 |
| 1067 | # fi |
| 1068 | |
| 1069 | } # end of initialize() |
| 1070 | |
| 1071 | |
| 1072 | ############## |
| 1073 | # initialize # |
| 1074 | ############## |
| 1075 | |
| 1076 | # stash path |
| 1077 | START_PATH="`pwd`" |
| 1078 | |
| 1079 | # Before running autoreconf or manual steps, some prep detection work |
| 1080 | # is necessary or useful. Only needs to occur once per directory, but |
| 1081 | # does need to traverse the entire subconfigure hierarchy to protect |
| 1082 | # files from being clobbered even by autoreconf. |
| 1083 | recursive_protect |
| 1084 | |
| 1085 | # start from where we started |
| 1086 | cd "$START_PATH" |
| 1087 | |
| 1088 | # get ready to process |
| 1089 | initialize |
| 1090 | |
| 1091 | |
| 1092 | ######################################### |
| 1093 | # DOWNLOAD_GNULIB_CONFIG_GUESS FUNCTION # |
| 1094 | ######################################### |
| 1095 | |
| 1096 | # TODO - should make sure wget/curl exist and/or work before trying to |
| 1097 | # use them. |
| 1098 | |
| 1099 | download_gnulib_config_guess () { |
| 1100 | # abuse gitweb to download gnulib's latest config.guess via HTTP |
| 1101 | config_guess_temp="config.guess.$$.download" |
| 1102 | ret=1 |
| 1103 | for __cmd in wget curl fetch ; do |
| 1104 | $VERBOSE_ECHO "Checking for command ${__cmd}" |
| 1105 | ${__cmd} --version > /dev/null 2>&1 |
| 1106 | ret=$? |
| 1107 | if [ ! $ret = 0 ] ; then |
| 1108 | continue |
| 1109 | fi |
| 1110 | |
| 1111 | __cmd_version=`${__cmd} --version | head -n 1 | sed -e 's/^[^0-9]\+//' -e 's/ .*//'` |
| 1112 | $VERBOSE_ECHO "Found ${__cmd} ${__cmd_version}" |
| 1113 | |
| 1114 | opts="" |
| 1115 | case ${__cmd} in |
| 1116 | wget) |
| 1117 | opts="-O" |
| 1118 | ;; |
| 1119 | curl) |
| 1120 | opts="-o" |
| 1121 | ;; |
| 1122 | fetch) |
| 1123 | opts="-t 5 -f" |
| 1124 | ;; |
| 1125 | esac |
| 1126 | |
| 1127 | $VERBOSE_ECHO "Running $__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" |
| 1128 | eval "$__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" > /dev/null 2>&1 |
| 1129 | if [ $? = 0 ] ; then |
| 1130 | mv -f "${config_guess_temp}" ${_aux_dir}/config.guess |
| 1131 | ret=0 |
| 1132 | break |
| 1133 | fi |
| 1134 | done |
| 1135 | |
| 1136 | if [ ! $ret = 0 ] ; then |
| 1137 | $ECHO "Warning: config.guess download failed from: $CONFIG_GUESS_URL" |
| 1138 | rm -f "${config_guess_temp}" |
| 1139 | fi |
| 1140 | } |
| 1141 | |
| 1142 | |
| 1143 | ############################## |
| 1144 | # LIBTOOLIZE_NEEDED FUNCTION # |
| 1145 | ############################## |
| 1146 | libtoolize_needed () { |
| 1147 | ret=1 # means no, don't need libtoolize |
| 1148 | for feature in AC_PROG_LIBTOOL AM_PROG_LIBTOOL LT_INIT ; do |
| 1149 | $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" |
| 1150 | found="`grep \"^$feature.*\" $CONFIGURE`" |
| 1151 | if [ ! "x$found" = "x" ] ; then |
| 1152 | ret=0 # means yes, need to run libtoolize |
| 1153 | break |
| 1154 | fi |
| 1155 | done |
| 1156 | return ${ret} |
| 1157 | } |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | ############################################ |
| 1162 | # prepare build via autoreconf or manually # |
| 1163 | ############################################ |
| 1164 | reconfigure_manually=no |
| 1165 | if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then |
| 1166 | $ECHO |
| 1167 | $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C" |
| 1168 | |
| 1169 | $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS" |
| 1170 | autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`" |
| 1171 | ret=$? |
| 1172 | $VERBOSE_ECHO "$autoreconf_output" |
| 1173 | |
| 1174 | if [ ! $ret = 0 ] ; then |
| 1175 | if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then |
| 1176 | if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then |
| 1177 | $ECHO |
| 1178 | $ECHO "Warning: autoreconf failed but due to what is usually a common libtool" |
| 1179 | $ECHO "misconfiguration issue. This problem is encountered on systems that" |
| 1180 | $ECHO "have installed libtoolize under a different name without providing a" |
| 1181 | $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable." |
| 1182 | $ECHO |
| 1183 | $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE" |
| 1184 | |
| 1185 | export LIBTOOLIZE |
| 1186 | RUN_RECURSIVE=no |
| 1187 | export RUN_RECURSIVE |
| 1188 | untrap_abnormal |
| 1189 | |
| 1190 | $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" |
| 1191 | sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" |
| 1192 | exit $? |
| 1193 | fi |
| 1194 | fi |
| 1195 | |
| 1196 | $ECHO "Warning: $AUTORECONF failed" |
| 1197 | |
| 1198 | if test -f ltmain.sh ; then |
| 1199 | $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should" |
| 1200 | fi |
| 1201 | |
| 1202 | $ECHO "Attempting to run the preparation steps individually" |
| 1203 | reconfigure_manually=yes |
| 1204 | else |
| 1205 | if [ "x$DOWNLOAD" = "xyes" ] ; then |
| 1206 | if libtoolize_needed ; then |
| 1207 | download_gnulib_config_guess |
| 1208 | fi |
| 1209 | fi |
| 1210 | fi |
| 1211 | else |
| 1212 | reconfigure_manually=yes |
| 1213 | fi |
| 1214 | |
| 1215 | |
| 1216 | ############################ |
| 1217 | # LIBTOOL_FAILURE FUNCTION # |
| 1218 | ############################ |
| 1219 | libtool_failure ( ) { |
| 1220 | |
| 1221 | # libtool is rather error-prone in comparison to the other |
| 1222 | # autotools and this routine attempts to compensate for some |
| 1223 | # common failures. the output after a libtoolize failure is |
| 1224 | # parsed for an error related to AC_PROG_LIBTOOL and if found, we |
| 1225 | # attempt to inject a project-provided libtool.m4 file. |
| 1226 | |
| 1227 | _autoconf_output="$1" |
| 1228 | |
| 1229 | if [ "x$RUN_RECURSIVE" = "xno" ] ; then |
| 1230 | # we already tried the libtool.m4, don't try again |
| 1231 | return 1 |
| 1232 | fi |
| 1233 | |
| 1234 | if test -f "$LIBTOOL_M4" ; then |
| 1235 | found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`" |
| 1236 | if test ! "x$found_libtool" = "x" ; then |
| 1237 | if test -f acinclude.m4 ; then |
| 1238 | rm -f acinclude.m4.$$.backup |
| 1239 | $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup" |
| 1240 | cat acinclude.m4 > acinclude.m4.$$.backup |
| 1241 | fi |
| 1242 | $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4" |
| 1243 | chmod u+w acinclude.m4 |
| 1244 | cat "$LIBTOOL_M4" >> acinclude.m4 |
| 1245 | |
| 1246 | # don't keep doing this |
| 1247 | RUN_RECURSIVE=no |
| 1248 | export RUN_RECURSIVE |
| 1249 | untrap_abnormal |
| 1250 | |
| 1251 | $ECHO |
| 1252 | $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4" |
| 1253 | $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" |
| 1254 | sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" |
| 1255 | exit $? |
| 1256 | fi |
| 1257 | fi |
| 1258 | } |
| 1259 | |
| 1260 | |
| 1261 | ########################### |
| 1262 | # MANUAL_AUTOGEN FUNCTION # |
| 1263 | ########################### |
| 1264 | manual_autogen ( ) { |
| 1265 | |
| 1266 | ################################################## |
| 1267 | # Manual preparation steps taken are as follows: # |
| 1268 | # aclocal [-I m4] # |
| 1269 | # libtoolize --automake -c -f # |
| 1270 | # aclocal [-I m4] # |
| 1271 | # autoconf -f # |
| 1272 | # autoheader # |
| 1273 | # automake -a -c -f # |
| 1274 | ################################################## |
| 1275 | |
| 1276 | ########### |
| 1277 | # aclocal # |
| 1278 | ########### |
| 1279 | $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" |
| 1280 | aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" |
| 1281 | ret=$? |
| 1282 | $VERBOSE_ECHO "$aclocal_output" |
| 1283 | if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi |
| 1284 | |
| 1285 | ############## |
| 1286 | # libtoolize # |
| 1287 | ############## |
| 1288 | if libtoolize_needed ; then |
| 1289 | if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then |
| 1290 | $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS" |
| 1291 | libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`" |
| 1292 | ret=$? |
| 1293 | $VERBOSE_ECHO "$libtoolize_output" |
| 1294 | |
| 1295 | if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi |
| 1296 | else |
| 1297 | if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then |
| 1298 | $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS" |
| 1299 | libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`" |
| 1300 | ret=$? |
| 1301 | $VERBOSE_ECHO "$libtoolize_output" |
| 1302 | |
| 1303 | if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi |
| 1304 | fi |
| 1305 | fi |
| 1306 | |
| 1307 | ########### |
| 1308 | # aclocal # |
| 1309 | ########### |
| 1310 | # re-run again as instructed by libtoolize |
| 1311 | $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS" |
| 1312 | aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`" |
| 1313 | ret=$? |
| 1314 | $VERBOSE_ECHO "$aclocal_output" |
| 1315 | |
| 1316 | # libtoolize might put ltmain.sh in the wrong place |
| 1317 | if test -f ltmain.sh ; then |
| 1318 | if test ! -f "${_aux_dir}/ltmain.sh" ; then |
| 1319 | $ECHO |
| 1320 | $ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory" |
| 1321 | $ECHO |
| 1322 | $ECHO "Fortunately, the problem can be worked around by simply copying the" |
| 1323 | $ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you." |
| 1324 | $ECHO |
| 1325 | $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\"" |
| 1326 | cp -p ltmain.sh "${_aux_dir}/ltmain.sh" |
| 1327 | $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C" |
| 1328 | fi |
| 1329 | fi # ltmain.sh |
| 1330 | |
| 1331 | if [ "x$DOWNLOAD" = "xyes" ] ; then |
| 1332 | download_gnulib_config_guess |
| 1333 | fi |
| 1334 | fi # libtoolize_needed |
| 1335 | |
| 1336 | ############ |
| 1337 | # autoconf # |
| 1338 | ############ |
| 1339 | $VERBOSE_ECHO |
| 1340 | $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS" |
| 1341 | autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`" |
| 1342 | ret=$? |
| 1343 | $VERBOSE_ECHO "$autoconf_output" |
| 1344 | |
| 1345 | if [ ! $ret = 0 ] ; then |
| 1346 | # retry without the -f and check for usage of macros that are too new |
| 1347 | ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE" |
| 1348 | ac2_55_macros="AC_COMPILER_IFELSE AC_FUNC_MBRTOWC AC_HEADER_STDBOOL AC_LANG_CONFTEST AC_LANG_SOURCE AC_LANG_PROGRAM AC_LANG_CALL AC_LANG_FUNC_TRY_LINK AC_MSG_FAILURE AC_PREPROC_IFELSE" |
| 1349 | ac2_54_macros="AC_C_BACKSLASH_A AC_CONFIG_LIBOBJ_DIR AC_GNU_SOURCE AC_PROG_EGREP AC_PROG_FGREP AC_REPLACE_FNMATCH AC_FUNC_FNMATCH_GNU AC_FUNC_REALLOC AC_TYPE_MBSTATE_T" |
| 1350 | |
| 1351 | macros_to_search="" |
| 1352 | ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`" |
| 1353 | ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`" |
| 1354 | |
| 1355 | if [ $ac_major -lt 2 ] ; then |
| 1356 | macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros" |
| 1357 | else |
| 1358 | if [ $ac_minor -lt 54 ] ; then |
| 1359 | macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros" |
| 1360 | elif [ $ac_minor -lt 55 ] ; then |
| 1361 | macros_to_search="$ac2_59_macros $ac2_55_macros" |
| 1362 | elif [ $ac_minor -lt 59 ] ; then |
| 1363 | macros_to_search="$ac2_59_macros" |
| 1364 | fi |
| 1365 | fi |
| 1366 | |
| 1367 | configure_ac_macros=__none__ |
| 1368 | for feature in $macros_to_search ; do |
| 1369 | $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" |
| 1370 | found="`grep \"^$feature.*\" $CONFIGURE`" |
| 1371 | if [ ! "x$found" = "x" ] ; then |
| 1372 | if [ "x$configure_ac_macros" = "x__none__" ] ; then |
| 1373 | configure_ac_macros="$feature" |
| 1374 | else |
| 1375 | configure_ac_macros="$feature $configure_ac_macros" |
| 1376 | fi |
| 1377 | fi |
| 1378 | done |
| 1379 | if [ ! "x$configure_ac_macros" = "x__none__" ] ; then |
| 1380 | $ECHO |
| 1381 | $ECHO "Warning: Unsupported macros were found in $CONFIGURE" |
| 1382 | $ECHO |
| 1383 | $ECHO "The `basename \"$CONFIGURE\"` file was scanned in order to determine if any" |
| 1384 | $ECHO "unsupported macros are used that exceed the minimum version" |
| 1385 | $ECHO "settings specified within this file. As such, the following macros" |
| 1386 | $ECHO "should be removed from configure.ac or the version numbers in this" |
| 1387 | $ECHO "file should be increased:" |
| 1388 | $ECHO |
| 1389 | $ECHO "$configure_ac_macros" |
| 1390 | $ECHO |
| 1391 | $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C" |
| 1392 | fi |
| 1393 | |
| 1394 | ################### |
| 1395 | # autoconf, retry # |
| 1396 | ################### |
| 1397 | $VERBOSE_ECHO |
| 1398 | $VERBOSE_ECHO "$AUTOCONF" |
| 1399 | autoconf_output="`$AUTOCONF 2>&1`" |
| 1400 | ret=$? |
| 1401 | $VERBOSE_ECHO "$autoconf_output" |
| 1402 | |
| 1403 | if [ ! $ret = 0 ] ; then |
| 1404 | # test if libtool is busted |
| 1405 | libtool_failure "$autoconf_output" |
| 1406 | |
| 1407 | # let the user know what went wrong |
| 1408 | cat <<EOF |
| 1409 | $autoconf_output |
| 1410 | EOF |
| 1411 | $ECHO "ERROR: $AUTOCONF failed" |
| 1412 | exit 2 |
| 1413 | else |
| 1414 | # autoconf sans -f and possibly sans unsupported options succeed so warn verbosely |
| 1415 | $ECHO |
| 1416 | $ECHO "Warning: autoconf seems to have succeeded by removing the following options:" |
| 1417 | $ECHO " AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\"" |
| 1418 | $ECHO |
| 1419 | $ECHO "Removing those options should not be necessary and indicate some other" |
| 1420 | $ECHO "problem with the build system. The build preparation is highly suspect" |
| 1421 | $ECHO "and may result in configuration or compilation errors. Consider" |
| 1422 | if [ "x$VERBOSE_ECHO" = "x:" ] ; then |
| 1423 | $ECHO "rerunning the build preparation with verbose output enabled." |
| 1424 | $ECHO " $AUTOGEN_SH --verbose" |
| 1425 | else |
| 1426 | $ECHO "reviewing the minimum GNU Autotools version settings contained in" |
| 1427 | $ECHO "this script along with the macros being used in your `basename \"$CONFIGURE\"` file." |
| 1428 | fi |
| 1429 | $ECHO |
| 1430 | $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C" |
| 1431 | fi # autoconf ret = 0 |
| 1432 | fi # autoconf ret = 0 |
| 1433 | |
| 1434 | ############## |
| 1435 | # autoheader # |
| 1436 | ############## |
| 1437 | need_autoheader=no |
| 1438 | for feature in AM_CONFIG_HEADER AC_CONFIG_HEADER ; do |
| 1439 | $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" |
| 1440 | found="`grep \"^$feature.*\" $CONFIGURE`" |
| 1441 | if [ ! "x$found" = "x" ] ; then |
| 1442 | need_autoheader=yes |
| 1443 | break |
| 1444 | fi |
| 1445 | done |
| 1446 | if [ "x$need_autoheader" = "xyes" ] ; then |
| 1447 | $VERBOSE_ECHO "$AUTOHEADER $AUTOHEADER_OPTIONS" |
| 1448 | autoheader_output="`$AUTOHEADER $AUTOHEADER_OPTIONS 2>&1`" |
| 1449 | ret=$? |
| 1450 | $VERBOSE_ECHO "$autoheader_output" |
| 1451 | if [ ! $ret = 0 ] ; then $ECHO "ERROR: $AUTOHEADER failed" && exit 2 ; fi |
| 1452 | fi # need_autoheader |
| 1453 | |
| 1454 | ############ |
| 1455 | # automake # |
| 1456 | ############ |
| 1457 | need_automake=no |
| 1458 | for feature in AM_INIT_AUTOMAKE ; do |
| 1459 | $VERBOSE_ECHO "Searching for $feature in $CONFIGURE" |
| 1460 | found="`grep \"^$feature.*\" $CONFIGURE`" |
| 1461 | if [ ! "x$found" = "x" ] ; then |
| 1462 | need_automake=yes |
| 1463 | break |
| 1464 | fi |
| 1465 | done |
| 1466 | |
| 1467 | if [ "x$need_automake" = "xyes" ] ; then |
| 1468 | $VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS" |
| 1469 | automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`" |
| 1470 | ret=$? |
| 1471 | $VERBOSE_ECHO "$automake_output" |
| 1472 | |
| 1473 | if [ ! $ret = 0 ] ; then |
| 1474 | |
| 1475 | ################### |
| 1476 | # automake, retry # |
| 1477 | ################### |
| 1478 | $VERBOSE_ECHO |
| 1479 | $VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS" |
| 1480 | # retry without the -f |
| 1481 | automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`" |
| 1482 | ret=$? |
| 1483 | $VERBOSE_ECHO "$automake_output" |
| 1484 | |
| 1485 | if [ ! $ret = 0 ] ; then |
| 1486 | # test if libtool is busted |
| 1487 | libtool_failure "$automake_output" |
| 1488 | |
| 1489 | # let the user know what went wrong |
| 1490 | cat <<EOF |
| 1491 | $automake_output |
| 1492 | EOF |
| 1493 | $ECHO "ERROR: $AUTOMAKE failed" |
| 1494 | exit 2 |
| 1495 | fi # automake retry |
| 1496 | fi # automake ret = 0 |
| 1497 | fi # need_automake |
| 1498 | } # end of manual_autogen |
| 1499 | |
| 1500 | |
| 1501 | ##################################### |
| 1502 | # RECURSIVE_MANUAL_AUTOGEN FUNCTION # |
| 1503 | ##################################### |
| 1504 | recursive_manual_autogen ( ) { |
| 1505 | |
| 1506 | # run the build preparation steps manually for this directory |
| 1507 | manual_autogen |
| 1508 | |
| 1509 | # for projects using recursive configure, run the build |
| 1510 | # preparation steps for the subdirectories. |
| 1511 | if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then |
| 1512 | $VERBOSE_ECHO "Recursively configuring the following directories:" |
| 1513 | $VERBOSE_ECHO " $CONFIG_SUBDIRS" |
| 1514 | for dir in $CONFIG_SUBDIRS ; do |
| 1515 | $VERBOSE_ECHO "Processing recursive configure in $dir" |
| 1516 | cd "$START_PATH" |
| 1517 | cd "$dir" |
| 1518 | |
| 1519 | # new directory, prepare |
| 1520 | initialize |
| 1521 | |
| 1522 | # run manual steps for the subdir and any others below |
| 1523 | recursive_manual_autogen |
| 1524 | done |
| 1525 | fi |
| 1526 | } |
| 1527 | |
| 1528 | |
| 1529 | ################################ |
| 1530 | # run manual preparation steps # |
| 1531 | ################################ |
| 1532 | if [ "x$reconfigure_manually" = "xyes" ] ; then |
| 1533 | $ECHO |
| 1534 | $ECHO $ECHO_N "Preparing build ... $ECHO_C" |
| 1535 | |
| 1536 | recursive_manual_autogen |
| 1537 | fi |
| 1538 | |
| 1539 | |
| 1540 | ######################### |
| 1541 | # restore and summarize # |
| 1542 | ######################### |
| 1543 | cd "$START_PATH" |
| 1544 | |
| 1545 | # restore COPYING and INSTALL from backup if necessary |
| 1546 | recursive_restore |
| 1547 | |
| 1548 | # make sure we end up with a configure script |
| 1549 | config_ac="`locate_configure_template`" |
| 1550 | config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`" |
| 1551 | if [ "x$config" = "x" ] ; then |
| 1552 | $VERBOSE_ECHO "Could not locate the configure template (from `pwd`)" |
| 1553 | fi |
| 1554 | |
| 1555 | # summarize |
| 1556 | $ECHO "done" |
| 1557 | $ECHO |
| 1558 | if test "x$config" = "x" -o ! -f "$config" ; then |
| 1559 | $ECHO "WARNING: The $PROJECT build system should now be prepared but there" |
| 1560 | $ECHO "does not seem to be a resulting configure file. This is unexpected" |
| 1561 | $ECHO "and likely the result of an error. You should run $NAME_OF_AUTOGEN" |
| 1562 | $ECHO "with the --verbose option to get more details on a potential" |
| 1563 | $ECHO "misconfiguration." |
| 1564 | else |
| 1565 | $ECHO "The $PROJECT build system is now prepared. To build here, run:" |
| 1566 | $ECHO " $config" |
| 1567 | $ECHO " make" |
| 1568 | fi |
| 1569 | |
| 1570 | |
| 1571 | # Local Variables: |
| 1572 | # mode: sh |
| 1573 | # tab-width: 8 |
| 1574 | # sh-basic-offset: 4 |
| 1575 | # sh-indentation: 4 |
| 1576 | # indent-tabs-mode: t |
| 1577 | # End: |
| 1578 | # ex: shiftwidth=4 tabstop=8 |