4
# Copyright (c) 2005-2007 United States Government as represented by
5
# the U.S. Army Research Laboratory.
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions
11
# 1. Redistributions of source code must retain the above copyright
12
# notice, this list of conditions and the following disclaimer.
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.
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
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.
37
# Script for automatically preparing the sources for compilation by
38
# performing the myrid of necessary steps. The script attempts to
39
# detect proper version support, and outputs warnings about particular
40
# systems that have autotool peculiarities.
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.
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
52
# The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL
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.
60
# To obtain help on usage:
63
# To obtain verbose output:
64
# ./autogen.sh --verbose
66
# To skip autoreconf and prepare manually:
67
# AUTORECONF=false ./autogen.sh
69
# To verbosely try running with an older (unsupported) autoconf:
70
# AUTOCONF_VERSION=2.50 ./autogen.sh --verbose
72
# Author: Christopher Sean Morrison <morrison@brlcad.org>
74
######################################################################
76
# set to minimum acceptible version of autoconf
77
if [ "x$AUTOCONF_VERSION" = "x" ] ; then
80
# set to minimum acceptible version of automake
81
if [ "x$AUTOMAKE_VERSION" = "x" ] ; then
82
AUTOMAKE_VERSION=1.6.0
84
# set to minimum acceptible version of libtool
85
if [ "x$LIBTOOL_VERSION" = "x" ] ; then
94
# extract copyright from header
95
__copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`"
96
if [ "x$__copyright" = "x" ] ; then
97
__copyright="`date +%Y`"
100
# extract version from CVS Id string
101
__id="$Id: autogen.sh,v 14.97 2007/06/18 22:25:02 brlcad Exp $"
102
__version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`"
103
if [ "x$__version" = "x" ] ; then
107
echo "autogen.sh build preparation script by Christopher Sean Morrison"
108
echo "revised 3-clause BSD-style license, copyright (c) $__copyright"
109
echo "script version $__version, ISO/IEC 9945 POSIX shell script"
117
echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [--version]"
118
echo " --help Help on $NAME_OF_AUTOGEN usage"
119
echo " --verbose Verbose progress output"
120
echo " --quiet Quiet suppressed progress output"
121
echo " --version Only perform GNU Build System version checks"
123
echo "Description: This script will validate that minimum versions of the"
124
echo "GNU Build System tools are installed and then run autoreconf for you."
125
echo "Should autoreconf fail, manual preparation steps will be run"
126
echo "potentially accounting for several common preparation issues. The"
128
echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL"
129
echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS"
130
echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the"
131
echo "default automatic detection behavior."
140
##########################
141
# VERSION_ERROR FUNCTION #
142
##########################
144
if [ "x$1" = "x" ] ; then
145
echo "INTERNAL ERROR: version_error was not provided a version"
148
if [ "x$2" = "x" ] ; then
149
echo "INTERNAL ERROR: version_error was not provided an application name"
153
$ECHO "ERROR: To prepare the ${PROJECT} build system from scratch,"
154
$ECHO " at least version $1 of $2 must be installed."
156
$ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will"
157
$ECHO "run configure or make. Either the GNU Autotools will need to be installed"
158
$ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source"
159
$ECHO "code on another system and then transferred to here. -- Cheers!"
163
##########################
164
# VERSION_CHECK FUNCTION #
165
##########################
167
if [ "x$1" = "x" ] ; then
168
echo "INTERNAL ERROR: version_check was not provided a minimum version"
172
if [ "x$2" = "x" ] ; then
173
echo "INTERNAL ERROR: version check was not provided a comparison version"
178
# needed to handle versions like 1.10 and 1.4-p6
179
_min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
180
_cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
182
_min_major="`echo $_min | cut -d. -f1`"
183
_min_minor="`echo $_min | cut -d. -f2`"
184
_min_patch="`echo $_min | cut -d. -f3`"
186
_cur_major="`echo $_cur | cut -d. -f1`"
187
_cur_minor="`echo $_cur | cut -d. -f2`"
188
_cur_patch="`echo $_cur | cut -d. -f3`"
190
if [ "x$_min_major" = "x" ] ; then
193
if [ "x$_min_minor" = "x" ] ; then
196
if [ "x$_min_patch" = "x" ] ; then
199
if [ "x$_cur_minor" = "x" ] ; then
202
if [ "x$_cur_minor" = "x" ] ; then
205
if [ "x$_cur_patch" = "x" ] ; then
209
$VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}"
211
if [ $_min_major -lt $_cur_major ] ; then
213
elif [ $_min_major -eq $_cur_major ] ; then
214
if [ $_min_minor -lt $_cur_minor ] ; then
216
elif [ $_min_minor -eq $_cur_minor ] ; then
217
if [ $_min_patch -lt $_cur_patch ] ; then
219
elif [ $_min_patch -eq $_cur_patch ] ; then
228
######################################
229
# LOCATE_CONFIGURE_TEMPLATE FUNCTION #
230
######################################
231
locate_configure_template ( ) {
233
if test -f "./configure.ac" ; then
234
echo "./configure.ac"
235
elif test -f "./configure.in" ; then
236
echo "./configure.in"
237
elif test -f "$_pwd/configure.ac" ; then
238
echo "$_pwd/configure.ac"
239
elif test -f "$_pwd/configure.in" ; then
240
echo "$_pwd/configure.in"
241
elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then
242
echo "$PATH_TO_AUTOGEN/configure.ac"
243
elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then
244
echo "$PATH_TO_AUTOGEN/configure.in"
253
PATH_TO_AUTOGEN="`dirname $0`"
254
NAME_OF_AUTOGEN="`basename $0`"
255
AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN"
257
LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4"
259
if [ "x$HELP" = "x" ] ; then
262
if [ "x$QUIET" = "x" ] ; then
265
if [ "x$VERBOSE" = "x" ] ; then
268
if [ "x$VERSION_ONLY" = "x" ] ; then
271
if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then
272
AUTORECONF_OPTIONS="-i -f"
274
if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then
275
AUTOCONF_OPTIONS="-f"
277
if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then
280
for arg in $ARGS ; do
284
x--quiet) QUIET=yes ;;
286
x--verbose) VERBOSE=yes ;;
287
x-[vV]) VERBOSE=yes ;;
288
x--version) VERSION_ONLY=yes ;;
290
echo "Unknown option: $arg"
299
#####################
300
# environment check #
301
#####################
303
# sanity check before recursions potentially begin
304
if [ ! -f "$AUTOGEN_SH" ] ; then
305
echo "INTERNAL ERROR: $AUTOGEN_SH does not exist"
306
if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then
307
echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH"
312
# force locale setting to C so things like date output as expected
315
# commands that this script expects
316
for __cmd in echo head tail pwd ; do
317
echo "test" | $__cmd > /dev/null 2>&1
318
if [ $? != 0 ] ; then
319
echo "INTERNAL ERROR: '${__cmd}' command is required"
323
echo "test" | grep "test" > /dev/null 2>&1
324
if test ! x$? = x0 ; then
325
echo "INTERNAL ERROR: grep command is required"
328
echo "test" | sed "s/test/test/" > /dev/null 2>&1
329
if test ! x$? = x0 ; then
330
echo "INTERNAL ERROR: sed command is required"
335
# determine the behavior of echo
336
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
337
*c*,-n*) ECHO_N= ECHO_C='
339
*c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
340
*) ECHO_N= ECHO_C='\c' ECHO_T= ;;
343
# determine the behavior of head
344
case "x`echo 'head' | head -n 1 2>&1`" in
345
*xhead*) HEAD_N="n " ;;
349
# determine the behavior of tail
350
case "x`echo 'tail' | tail -n 1 2>&1`" in
351
*xtail*) TAIL_N="n " ;;
357
if [ "x$QUIET" = "xyes" ] ; then
358
if [ "x$VERBOSE" = "xyes" ] ; then
359
echo "Verbose output quelled by quiet option. Further output disabled."
363
if [ "x$VERBOSE" = "xyes" ] ; then
364
echo "Verbose output enabled"
370
# allow a recursive run to disable further recursions
371
if [ "x$RUN_RECURSIVE" = "x" ] ; then
376
################################################
377
# check for help arg and bypass version checks #
378
################################################
379
if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then
382
if [ "x$HELP" = "xyes" ] ; then
385
$ECHO "Help was requested. No preparation or configuration will be performed."
390
#######################
391
# set up signal traps #
392
#######################
393
untrap_abnormal ( ) {
394
for sig in 1 2 13 15; do
399
# do this cleanup whenever we exit.
401
# start from the root
402
if test -d "$START_PATH" ; then
406
# restore/delete backup files
407
if test "x$PFC_INIT" = "x1" ; then
412
# trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15)
413
for sig in 1 2 13 15; do
416
$ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'"
418
# start from the root
419
if test -d "$START_PATH" ; then
423
# clean up on abnormal exit
424
$VERBOSE_ECHO "rm -rf autom4te.cache"
425
rm -rf autom4te.cache
427
if test -f "acinclude.m4.$$.backup" ; then
428
$VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4"
429
chmod u+w acinclude.m4
430
cat acinclude.m4.$$.backup > acinclude.m4
432
$VERBOSE_ECHO "rm -f acinclude.m4.$$.backup"
433
rm -f acinclude.m4.$$.backup
436
{ (exit 1); exit 1; }
441
#############################
442
# look for a configure file #
443
#############################
444
if [ "x$CONFIGURE" = "x" ] ; then
445
CONFIGURE="`locate_configure_template`"
446
if [ ! "x$CONFIGURE" = "x" ] ; then
447
$VERBOSE_ECHO "Found a configure template: $CONFIGURE"
450
$ECHO "Using CONFIGURE environment variable override: $CONFIGURE"
452
if [ "x$CONFIGURE" = "x" ] ; then
453
if [ "x$VERSION_ONLY" = "xyes" ] ; then
457
$ECHO "A configure.ac or configure.in file could not be located implying"
458
$ECHO "that the GNU Build System is at least not used in this directory. In"
459
$ECHO "any case, there is nothing to do here without one of those files."
461
$ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
469
if [ "x$PROJECT" = "x" ] ; then
470
PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
471
if [ "x$PROJECT" = "xAC_INIT" ] ; then
472
# projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead
473
PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
475
if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then
478
if [ "x$PROJECT" = "x" ] ; then
482
$ECHO "Using PROJECT environment variable override: $PROJECT"
484
$ECHO "Preparing the $PROJECT build system...please wait"
488
########################
489
# check for autoreconf #
490
########################
492
if [ "x$AUTORECONF" = "x" ] ; then
493
for AUTORECONF in autoreconf ; do
494
$VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version"
495
$AUTORECONF --version > /dev/null 2>&1
503
$ECHO "Using AUTORECONF environment variable override: $AUTORECONF"
507
##########################
508
# autoconf version check #
509
##########################
511
if [ "x$AUTOCONF" = "x" ] ; then
512
for AUTOCONF in autoconf ; do
513
$VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version"
514
$AUTOCONF --version > /dev/null 2>&1
522
$ECHO "Using AUTOCONF environment variable override: $AUTOCONF"
526
if [ ! "x$_acfound" = "xyes" ] ; then
527
$ECHO "ERROR: Unable to locate GNU Autoconf."
530
_version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
531
if [ "x$_version" = "x" ] ; then
534
$ECHO "Found GNU Autoconf version $_version"
535
version_check "$AUTOCONF_VERSION" "$_version"
536
if [ $? -ne 0 ] ; then
540
if [ "x$_report_error" = "xyes" ] ; then
541
version_error "$AUTOCONF_VERSION" "GNU Autoconf"
546
##########################
547
# automake version check #
548
##########################
550
if [ "x$AUTOMAKE" = "x" ] ; then
551
for AUTOMAKE in automake ; do
552
$VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version"
553
$AUTOMAKE --version > /dev/null 2>&1
561
$ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE"
566
if [ ! "x$_amfound" = "xyes" ] ; then
568
$ECHO "ERROR: Unable to locate GNU Automake."
571
_version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
572
if [ "x$_version" = "x" ] ; then
575
$ECHO "Found GNU Automake version $_version"
576
version_check "$AUTOMAKE_VERSION" "$_version"
577
if [ $? -ne 0 ] ; then
581
if [ "x$_report_error" = "xyes" ] ; then
582
version_error "$AUTOMAKE_VERSION" "GNU Automake"
587
########################
588
# check for libtoolize #
589
########################
591
HAVE_ALT_LIBTOOLIZE=no
593
if [ "x$LIBTOOLIZE" = "x" ] ; then
594
LIBTOOLIZE=libtoolize
595
$VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version"
596
$LIBTOOLIZE --version > /dev/null 2>&1
597
if [ ! $? = 0 ] ; then
600
if [ "x$HAVE_AUTORECONF" = "xno" ] ; then
601
$ECHO "Warning: libtoolize does not appear to be available."
603
$ECHO "Warning: libtoolize does not appear to be available. This means that"
604
$ECHO "the automatic build preparation via autoreconf will probably not work."
605
$ECHO "Preparing the build by running each step individually, however, should"
606
$ECHO "work and will be done automatically for you if autoreconf fails."
609
# look for some alternates
610
for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do
611
$VERBOSE_ECHO "Checking libtoolize alternate: $tool --version"
612
_glibtoolize="`$tool --version > /dev/null 2>&1`"
614
$VERBOSE_ECHO "Found $tool --version"
615
_glti="`which $tool`"
616
if [ "x$_glti" = "x" ] ; then
617
$VERBOSE_ECHO "Cannot find $tool with which"
620
if test ! -f "$_glti" ; then
621
$VERBOSE_ECHO "Cannot use $tool, $_glti is not a file"
624
_gltidir="`dirname $_glti`"
625
if [ "x$_gltidir" = "x" ] ; then
626
$VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti"
629
if test ! -d "$_gltidir" ; then
630
$VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory"
633
HAVE_ALT_LIBTOOLIZE=yes
636
$ECHO "Fortunately, $tool was found which means that your system may simply"
637
$ECHO "have a non-standard or incomplete GNU Autotools install. If you have"
638
$ECHO "sufficient system access, it may be possible to quell this warning by"
641
sudo -V > /dev/null 2>&1
643
$ECHO " sudo ln -s $_glti $_gltidir/libtoolize"
646
$ECHO " ln -s $_glti $_gltidir/libtoolize"
648
$ECHO "Run that as root or with proper permissions to the $_gltidir directory"
660
$ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE"
664
############################
665
# libtoolize version check #
666
############################
668
if [ ! "x$_ltfound" = "xyes" ] ; then
670
$ECHO "ERROR: Unable to locate GNU Libtool."
673
_version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
674
if [ "x$_version" = "x" ] ; then
677
$ECHO "Found GNU Libtool version $_version"
678
version_check "$LIBTOOL_VERSION" "$_version"
679
if [ $? -ne 0 ] ; then
683
if [ "x$_report_error" = "xyes" ] ; then
684
version_error "$LIBTOOL_VERSION" "GNU Libtool"
689
#####################
690
# check for aclocal #
691
#####################
692
if [ "x$ACLOCAL" = "x" ] ; then
693
for ACLOCAL in aclocal ; do
694
$VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version"
695
$ACLOCAL --version > /dev/null 2>&1
701
$ECHO "Using ACLOCAL environment variable override: $ACLOCAL"
705
#########################
706
# check if version only #
707
#########################
708
$VERBOSE_ECHO "Checking whether to only output version information"
709
if [ "x$VERSION_ONLY" = "xyes" ] ; then
713
$ECHO "Version requested. No preparation or configuration will be performed."
718
#################################
719
# PROTECT_FROM_CLOBBER FUNCTION #
720
#################################
721
protect_from_clobber ( ) {
724
# protect COPYING & INSTALL from overwrite by automake. the
725
# automake force option will (inappropriately) ignore the existing
726
# contents of a COPYING and/or INSTALL files (depending on the
727
# version) instead of just forcing *missing* files like it does
728
# for AUTHORS, NEWS, and README. this is broken but extremely
729
# prevalent behavior, so we protect against it by keeping a backup
730
# of the file that can later be restored.
732
if test -f COPYING ; then
733
if test -f COPYING.$$.protect_from_automake.backup ; then
734
$VERBOSE_ECHO "Already backed up COPYING in `pwd`"
736
$VERBOSE_ECHO "Backing up COPYING in `pwd`"
737
$VERBOSE_ECHO "cp -p COPYING COPYING.$$.protect_from_automake.backup"
738
cp -p COPYING COPYING.$$.protect_from_automake.backup
741
if test -f INSTALL ; then
742
if test -f INSTALL.$$.protect_from_automake.backup ; then
743
$VERBOSE_ECHO "Already backed up INSTALL in `pwd`"
745
$VERBOSE_ECHO "Backing up INSTALL in `pwd`"
746
$VERBOSE_ECHO "cp -p INSTALL INSTALL.$$.protect_from_automake.backup"
747
cp -p INSTALL INSTALL.$$.protect_from_automake.backup
753
##############################
754
# RECURSIVE_PROTECT FUNCTION #
755
##############################
756
recursive_protect ( ) {
758
# for projects using recursive configure, run the build
759
# preparation steps for the subdirectories. this function assumes
760
# START_PATH was set to pwd before recursion begins so that
761
# relative paths work.
763
# git 'r done, protect COPYING and INSTALL from being clobbered
766
if test -d autom4te.cache ; then
767
$VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
768
$VERBOSE_ECHO "rm -rf autom4te.cache"
769
rm -rf autom4te.cache
772
# find configure template
773
_configure="`locate_configure_template`"
774
if [ "x$_configure" = "x" ] ; then
777
# $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure"
780
# $VERBOSE_ECHO "Looking for subdirs in `pwd`"
781
_det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
783
for dir in $_det_config_subdirs ; do
784
if test -d "`pwd`/$dir" ; then
785
CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
790
if [ ! "x$CHECK_DIRS" = "x" ] ; then
791
$VERBOSE_ECHO "Recursively scanning the following directories:"
792
$VERBOSE_ECHO " $CHECK_DIRS"
793
for dir in $CHECK_DIRS ; do
794
$VERBOSE_ECHO "Protecting files from automake in $dir"
798
# recursively git 'r done
802
} # end of recursive_protect
805
#############################
806
# RESTORE_CLOBBERED FUNCION #
807
#############################
808
restore_clobbered ( ) {
810
# The automake (and autoreconf by extension) -f/--force-missing
811
# option may overwrite COPYING and INSTALL even if they do exist.
812
# Here we restore the files if necessary.
817
if test -f COPYING.$$.protect_from_automake.backup ; then
818
if test -f COPYING ; then
819
# compare entire content, restore if needed
820
if test "x`cat COPYING`" != "x`cat COPYING.$$.protect_from_automake.backup`" ; then
821
if test "x$spacer" = "xno" ; then
826
$VERBOSE_ECHO "Restoring COPYING from backup (automake -f likely clobbered it)"
827
$VERBOSE_ECHO "rm -f COPYING"
829
$VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
830
mv COPYING.$$.protect_from_automake.backup COPYING
832
elif test -f COPYING.$$.protect_from_automake.backup ; then
833
$VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
834
mv COPYING.$$.protect_from_automake.backup COPYING
838
$VERBOSE_ECHO "rm -f COPYING.$$.protect_from_automake.backup"
839
rm -f COPYING.$$.protect_from_automake.backup
840
fi # -f COPYING.$$.protect_from_automake.backup
843
if test -f INSTALL.$$.protect_from_automake.backup ; then
844
if test -f INSTALL ; then
845
# compare entire content, restore if needed
846
if test "x`cat INSTALL`" != "x`cat INSTALL.$$.protect_from_automake.backup`" ; then
847
if test "x$spacer" = "xno" ; then
852
$VERBOSE_ECHO "Restoring INSTALL from backup (automake -f likely clobbered it)"
853
$VERBOSE_ECHO "rm -f INSTALL"
855
$VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
856
mv INSTALL.$$.protect_from_automake.backup INSTALL
858
elif test -f INSTALL.$$.protect_from_automake.backup ; then
859
$VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
860
mv INSTALL.$$.protect_from_automake.backup INSTALL
864
$VERBOSE_ECHO "rm -f INSTALL.$$.protect_from_automake.backup"
865
rm -f INSTALL.$$.protect_from_automake.backup
866
fi # -f INSTALL.$$.protect_from_automake.backup
868
CONFIGURE="`locate_configure_template`"
869
if [ "x$CONFIGURE" = "x" ] ; then
873
_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/'`"
874
if test ! -d "$_aux_dir" ; then
878
for file in config.guess config.sub ltmain.sh ; do
879
if test -f "${_aux_dir}/${file}" ; then
880
$VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\""
881
rm -f "${_aux_dir}/${file}.backup"
884
} # end of restore_clobbered
887
##############################
888
# RECURSIVE_RESTORE FUNCTION #
889
##############################
890
recursive_restore ( ) {
892
# restore COPYING and INSTALL from backup if they were clobbered
893
# for each directory recursively.
898
# find configure template
899
_configure="`locate_configure_template`"
900
if [ "x$_configure" = "x" ] ; then
905
_det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
907
for dir in $_det_config_subdirs ; do
908
if test -d "`pwd`/$dir" ; then
909
CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
914
if [ ! "x$CHECK_DIRS" = "x" ] ; then
915
$VERBOSE_ECHO "Recursively scanning the following directories:"
916
$VERBOSE_ECHO " $CHECK_DIRS"
917
for dir in $CHECK_DIRS ; do
918
$VERBOSE_ECHO "Checking files for automake damage in $dir"
922
# recursively git 'r undone
926
} # end of recursive_restore
929
#######################
930
# INITIALIZE FUNCTION #
931
#######################
934
# this routine performs a variety of directory-specific
935
# initializations. some are sanity checks, some are preventive,
936
# and some are necessary setup detection.
938
# this function sets:
943
##################################
944
# check for a configure template #
945
##################################
946
CONFIGURE="`locate_configure_template`"
947
if [ "x$CONFIGURE" = "x" ] ; then
949
$ECHO "A configure.ac or configure.in file could not be located implying"
950
$ECHO "that the GNU Build System is at least not used in this directory. In"
951
$ECHO "any case, there is nothing to do here without one of those files."
953
$ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
957
#####################
958
# detect an aux dir #
959
#####################
960
_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/'`"
961
if test ! -d "$_aux_dir" ; then
964
$VERBOSE_ECHO "Detected auxillary directory: $_aux_dir"
967
################################
968
# detect a recursive configure #
969
################################
971
_det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
972
for dir in $_det_config_subdirs ; do
973
if test -d "`pwd`/$dir" ; then
974
$VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir"
975
CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir"
979
##########################################
980
# make sure certain required files exist #
981
##########################################
982
for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do
983
if test ! -f $file ; then
984
$VERBOSE_ECHO "Touching ${file} since it does not exist"
989
##################################################
990
# make sure certain generated files do not exist #
991
##################################################
992
for file in config.guess config.sub ltmain.sh ; do
993
if test -f "${_aux_dir}/${file}" ; then
994
$VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\""
995
mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup"
999
############################
1000
# search alternate m4 dirs #
1001
############################
1004
if [ -d $dir ] ; then
1005
$VERBOSE_ECHO "Found extra aclocal search directory: $dir"
1006
SEARCH_DIRS="$SEARCH_DIRS -I $dir"
1010
######################################
1011
# remove any previous build products #
1012
######################################
1013
if test -d autom4te.cache ; then
1014
$VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
1015
$VERBOSE_ECHO "rm -rf autom4te.cache"
1016
rm -rf autom4te.cache
1018
# tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it
1019
# if test -f aclocal.m4 ; then
1020
# $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it"
1021
# $VERBOSE_ECHO "rm -f aclocal.m4"
1025
} # end of initialize()
1035
# Before running autoreconf or manual steps, some prep detection work
1036
# is necessary or useful. Only needs to occur once per directory, but
1037
# does need to traverse the entire subconfigure hierarchy to protect
1038
# files from being clobbered even by autoreconf.
1041
# start from where we started
1044
# get ready to process
1048
############################################
1049
# prepare build via autoreconf or manually #
1050
############################################
1051
reconfigure_manually=no
1052
if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then
1054
$ECHO $ECHO_N "Automatically preparing build ... $ECHO_C"
1056
$VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS"
1057
autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`"
1059
$VERBOSE_ECHO "$autoreconf_output"
1061
if [ ! $ret = 0 ] ; then
1062
if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
1063
if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then
1065
$ECHO "Warning: autoreconf failed but due to what is usually a common libtool"
1066
$ECHO "misconfiguration issue. This problem is encountered on systems that"
1067
$ECHO "have installed libtoolize under a different name without providing a"
1068
$ECHO "symbolic link or without setting the LIBTOOLIZE environment variable."
1070
$ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE"
1074
export RUN_RECURSIVE
1077
$VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
1078
sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
1083
$ECHO "Warning: $AUTORECONF failed"
1085
if test -f ltmain.sh ; then
1086
$ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should"
1089
$ECHO "Attempting to run the preparation steps individually"
1090
reconfigure_manually=yes
1093
reconfigure_manually=yes
1097
############################
1098
# LIBTOOL_FAILURE FUNCTION #
1099
############################
1100
libtool_failure ( ) {
1102
# libtool is rather error-prone in comparison to the other
1103
# autotools and this routine attempts to compensate for some
1104
# common failures. the output after a libtoolize failure is
1105
# parsed for an error related to AC_PROG_LIBTOOL and if found, we
1106
# attempt to inject a project-provided libtool.m4 file.
1108
_autoconf_output="$1"
1110
if [ "x$RUN_RECURSIVE" = "xno" ] ; then
1111
# we already tried the libtool.m4, don't try again
1115
if test -f "$LIBTOOL_M4" ; then
1116
found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`"
1117
if test ! "x$found_libtool" = "x" ; then
1118
if test -f acinclude.m4 ; then
1119
rm -f acinclude.m4.$$.backup
1120
$VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup"
1121
cat acinclude.m4 > acinclude.m4.$$.backup
1123
$VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4"
1124
chmod u+w acinclude.m4
1125
cat "$LIBTOOL_M4" >> acinclude.m4
1127
# don't keep doing this
1129
export RUN_RECURSIVE
1133
$ECHO "Restarting the preparation steps with libtool macros in acinclude.m4"
1134
$VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
1135
sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
1142
###########################
1143
# MANUAL_AUTOGEN FUNCTION #
1144
###########################
1145
manual_autogen ( ) {
1147
##################################################
1148
# Manual preparation steps taken are as follows: #
1150
# libtoolize --automake -c -f #
1153
# automake -a -c -f #
1154
##################################################
1159
$VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
1160
aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
1162
$VERBOSE_ECHO "$aclocal_output"
1163
if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi
1169
for feature in AC_PROG_LIBTOOL LT_INIT ; do
1170
$VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
1171
found="`grep \"^$feature.*\" $CONFIGURE`"
1172
if [ ! "x$found" = "x" ] ; then
1177
if [ "x$need_libtoolize" = "xyes" ] ; then
1178
if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then
1179
$VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS"
1180
libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`"
1182
$VERBOSE_ECHO "$libtoolize_output"
1184
if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
1186
if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
1187
$VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS"
1188
libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`"
1190
$VERBOSE_ECHO "$libtoolize_output"
1192
if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
1199
# re-run again as instructed by libtoolize
1200
$VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
1201
aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
1203
$VERBOSE_ECHO "$aclocal_output"
1205
# libtoolize might put ltmain.sh in the wrong place
1206
if test -f ltmain.sh ; then
1207
if test ! -f "${_aux_dir}/ltmain.sh" ; then
1209
$ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory"
1211
$ECHO "Fortunately, the problem can be worked around by simply copying the"
1212
$ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you."
1214
$VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\""
1215
cp -p ltmain.sh "${_aux_dir}/ltmain.sh"
1216
$ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
1219
fi # need_libtoolize
1225
$VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS"
1226
autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`"
1228
$VERBOSE_ECHO "$autoconf_output"
1230
if [ ! $ret = 0 ] ; then
1231
# retry without the -f and check for usage of macros that are too new
1232
ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE"
1233
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"
1234
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"
1237
ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`"
1238
ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`"
1240
if [ $ac_major -lt 2 ] ; then
1241
macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
1243
if [ $ac_minor -lt 54 ] ; then
1244
macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
1245
elif [ $ac_minor -lt 55 ] ; then
1246
macros_to_search="$ac2_59_macros $ac2_55_macros"
1247
elif [ $ac_minor -lt 59 ] ; then
1248
macros_to_search="$ac2_59_macros"
1252
configure_ac_macros=__none__
1253
for feature in $macros_to_search ; do
1254
$VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
1255
found="`grep \"^$feature.*\" $CONFIGURE`"
1256
if [ ! "x$found" = "x" ] ; then
1257
if [ "x$configure_ac_macros" = "x__none__" ] ; then
1258
configure_ac_macros="$feature"
1260
configure_ac_macros="$feature $configure_ac_macros"
1264
if [ ! "x$configure_ac_macros" = "x__none__" ] ; then
1266
$ECHO "Warning: Unsupported macros were found in $CONFIGURE"
1268
$ECHO "The `echo $CONFIGURE | basename` file was scanned in order to determine if any"
1269
$ECHO "unsupported macros are used that exceed the minimum version"
1270
$ECHO "settings specified within this file. As such, the following macros"
1271
$ECHO "should be removed from configure.ac or the version numbers in this"
1272
$ECHO "file should be increased:"
1274
$ECHO "$configure_ac_macros"
1276
$ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C"
1283
$VERBOSE_ECHO "$AUTOCONF"
1284
autoconf_output="`$AUTOCONF 2>&1`"
1286
$VERBOSE_ECHO "$autoconf_output"
1288
if [ ! $ret = 0 ] ; then
1289
# test if libtool is busted
1290
libtool_failure "$autoconf_output"
1292
# let the user know what went wrong
1296
$ECHO "ERROR: $AUTOCONF failed"
1299
# autoconf sans -f and possibly sans unsupported options succeed so warn verbosely
1301
$ECHO "Warning: autoconf seems to have succeeded by removing the following options:"
1302
$ECHO " AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\""
1304
$ECHO "Removing those options should not be necessary and indicate some other"
1305
$ECHO "problem with the build system. The build preparation is highly suspect"
1306
$ECHO "and may result in configuration or compilation errors. Consider"
1307
if [ "x$VERBOSE_ECHO" = "x:" ] ; then
1308
$ECHO "rerunning the build preparation with verbose output enabled."
1309
$ECHO " $AUTOGEN_SH --verbose"
1311
$ECHO "reviewing the minimum GNU Autotools version settings contained in"
1312
$ECHO "this script along with the macros being used in your `echo $CONFIGURE | basename` file."
1315
$ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
1316
fi # autoconf ret = 0
1317
fi # autoconf ret = 0
1323
for feature in AM_INIT_AUTOMAKE ; do
1324
$VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
1325
found="`grep \"^$feature.*\" $CONFIGURE`"
1326
if [ ! "x$found" = "x" ] ; then
1332
if [ "x$need_automake" = "xyes" ] ; then
1333
$VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS"
1334
automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`"
1336
$VERBOSE_ECHO "$automake_output"
1338
if [ ! $ret = 0 ] ; then
1344
$VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS"
1345
# retry without the -f
1346
automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`"
1348
$VERBOSE_ECHO "$automake_output"
1350
if [ ! $ret = 0 ] ; then
1351
# test if libtool is busted
1352
libtool_failure "$automake_output"
1354
# let the user know what went wrong
1358
$ECHO "ERROR: $AUTOMAKE failed"
1361
fi # automake ret = 0
1363
} # end of manual_autogen
1366
#####################################
1367
# RECURSIVE_MANUAL_AUTOGEN FUNCTION #
1368
#####################################
1369
recursive_manual_autogen ( ) {
1371
# run the build preparation steps manually for this directory
1374
# for projects using recursive configure, run the build
1375
# preparation steps for the subdirectories.
1376
if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then
1377
$VERBOSE_ECHO "Recursively configuring the following directories:"
1378
$VERBOSE_ECHO " $CONFIG_SUBDIRS"
1379
for dir in $CONFIG_SUBDIRS ; do
1380
$VERBOSE_ECHO "Processing recursive configure in $dir"
1384
# new directory, prepare
1387
# run manual steps for the subdir and any others below
1388
recursive_manual_autogen
1394
################################
1395
# run manual preparation steps #
1396
################################
1397
if [ "x$reconfigure_manually" = "xyes" ] ; then
1399
$ECHO $ECHO_N "Preparing build ... $ECHO_C"
1401
recursive_manual_autogen
1405
#########################
1406
# restore and summarize #
1407
#########################
1410
# restore COPYING and INSTALL from backup if necessary
1413
# make sure we end up with a configure script
1414
config_ac="`locate_configure_template`"
1415
config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`"
1416
if [ "x$config" = "x" ] ; then
1417
$VERBOSE_ECHO "Could not locate the configure template (from `pwd`)"
1423
if test "x$config" = "x" -o ! -f "$config" ; then
1424
$ECHO "WARNING: The $PROJECT build system should now be prepared but there"
1425
$ECHO "does not seem to be a resulting configure file. This is unexpected"
1426
$ECHO "and likely the result of an error. You should run $NAME_OF_AUTOGEN"
1427
$ECHO "with the --verbose option to get more details on a potential"
1428
$ECHO "misconfiguration."
1430
$ECHO "The $PROJECT build system is now prepared. To build here, run:"
1439
# sh-basic-offset: 4
1441
# indent-tabs-mode: t
1443
# ex: shiftwidth=4 tabstop=8