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