Blame autogen.sh

Packit a8f112
#!/bin/sh
Packit a8f112
#                        a u t o g e n . s h
Packit a8f112
#
Packit a8f112
# Copyright (c) 2005-2009 United States Government as represented by
Packit a8f112
# the U.S. Army Research Laboratory.
Packit a8f112
#
Packit a8f112
# Redistribution and use in source and binary forms, with or without
Packit a8f112
# modification, are permitted provided that the following conditions
Packit a8f112
# are met:
Packit a8f112
#
Packit a8f112
# 1. Redistributions of source code must retain the above copyright
Packit a8f112
# notice, this list of conditions and the following disclaimer.
Packit a8f112
#
Packit a8f112
# 2. Redistributions in binary form must reproduce the above
Packit a8f112
# copyright notice, this list of conditions and the following
Packit a8f112
# disclaimer in the documentation and/or other materials provided
Packit a8f112
# with the distribution.
Packit a8f112
#
Packit a8f112
# 3. The name of the author may not be used to endorse or promote
Packit a8f112
# products derived from this software without specific prior written
Packit a8f112
# permission.
Packit a8f112
#
Packit a8f112
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
Packit a8f112
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Packit a8f112
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit a8f112
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
Packit a8f112
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit a8f112
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Packit a8f112
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Packit a8f112
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
Packit a8f112
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit a8f112
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit a8f112
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit a8f112
#
Packit a8f112
###
Packit a8f112
#
Packit a8f112
# Script for automatically preparing the sources for compilation by
Packit a8f112
# performing the myriad of necessary steps.  The script attempts to
Packit a8f112
# detect proper version support, and outputs warnings about particular
Packit a8f112
# systems that have autotool peculiarities.
Packit a8f112
#
Packit a8f112
# Basically, if everything is set up and installed correctly, the
Packit a8f112
# script will validate that minimum versions of the GNU Build System
Packit a8f112
# tools are installed, account for several common configuration
Packit a8f112
# issues, and then simply run autoreconf for you.
Packit a8f112
#
Packit a8f112
# If autoreconf fails, which can happen for many valid configurations,
Packit a8f112
# this script proceeds to run manual preparation steps effectively
Packit a8f112
# providing a POSIX shell script (mostly complete) reimplementation of
Packit a8f112
# autoreconf.
Packit a8f112
#
Packit a8f112
# The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER
Packit a8f112
# environment variables and corresponding _OPTIONS variables (e.g.
Packit a8f112
# AUTORECONF_OPTIONS) may be used to override the default automatic
Packit a8f112
# detection behaviors.  Similarly the _VERSION variables will override
Packit a8f112
# the minimum required version numbers.
Packit a8f112
#
Packit a8f112
# Examples:
Packit a8f112
#
Packit a8f112
#   To obtain help on usage:
Packit a8f112
#     ./autogen.sh --help
Packit a8f112
#
Packit a8f112
#   To obtain verbose output:
Packit a8f112
#     ./autogen.sh --verbose
Packit a8f112
#
Packit a8f112
#   To skip autoreconf and prepare manually:
Packit a8f112
#     AUTORECONF=false ./autogen.sh
Packit a8f112
#
Packit a8f112
#   To verbosely try running with an older (unsupported) autoconf:
Packit a8f112
#     AUTOCONF_VERSION=2.50 ./autogen.sh --verbose
Packit a8f112
#
Packit a8f112
# Author:
Packit a8f112
#   Christopher Sean Morrison <morrison@brlcad.org>
Packit a8f112
#
Packit a8f112
# Patches:
Packit a8f112
#   Sebastian Pipping <sebastian@pipping.org>
Packit a8f112
#
Packit a8f112
######################################################################
Packit a8f112
Packit a8f112
# set to minimum acceptable version of autoconf
Packit a8f112
if [ "x$AUTOCONF_VERSION" = "x" ] ; then
Packit a8f112
    AUTOCONF_VERSION=2.52
Packit a8f112
fi
Packit a8f112
# set to minimum acceptable version of automake
Packit a8f112
if [ "x$AUTOMAKE_VERSION" = "x" ] ; then
Packit a8f112
    AUTOMAKE_VERSION=1.6.0
Packit a8f112
fi
Packit a8f112
# set to minimum acceptable version of libtool
Packit a8f112
if [ "x$LIBTOOL_VERSION" = "x" ] ; then
Packit a8f112
    LIBTOOL_VERSION=1.4.2
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
##################
Packit a8f112
# ident function #
Packit a8f112
##################
Packit a8f112
ident ( ) {
Packit a8f112
    # extract copyright from header
Packit a8f112
    __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`"
Packit a8f112
    if [ "x$__copyright" = "x" ] ; then
Packit a8f112
	__copyright="`date +%Y`"
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    # extract version from CVS Id string
Packit a8f112
    __id="$Id: autogen.sh 33925 2009-03-01 23:27:06Z brlcad $"
Packit a8f112
    __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`"
Packit a8f112
    if [ "x$__version" = "x" ] ; then
Packit a8f112
	__version=""
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    echo "autogen.sh build preparation script by Christopher Sean Morrison"
Packit a8f112
    echo "  + config.guess download patch by Sebastian Pipping (2008-12-03)"
Packit a8f112
    echo "revised 3-clause BSD-style license, copyright (c) $__copyright"
Packit a8f112
    echo "script version $__version, ISO/IEC 9945 POSIX shell script"
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
##################
Packit a8f112
# USAGE FUNCTION #
Packit a8f112
##################
Packit a8f112
usage ( ) {
Packit a8f112
    echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [-d|--download] [--version]"
Packit a8f112
    echo "    --help      Help on $NAME_OF_AUTOGEN usage"
Packit a8f112
    echo "    --verbose   Verbose progress output"
Packit a8f112
    echo "    --quiet     Quiet suppressed progress output"
Packit a8f112
    echo "    --download  Download the latest config.guess from gnulib"
Packit a8f112
    echo "    --version   Only perform GNU Build System version checks"
Packit a8f112
    echo
Packit a8f112
    echo "Description: This script will validate that minimum versions of the"
Packit a8f112
    echo "GNU Build System tools are installed and then run autoreconf for you."
Packit a8f112
    echo "Should autoreconf fail, manual preparation steps will be run"
Packit a8f112
    echo "potentially accounting for several common preparation issues.  The"
Packit a8f112
Packit a8f112
    echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER,"
Packit a8f112
    echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS"
Packit a8f112
    echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the"
Packit a8f112
    echo "default automatic detection behavior."
Packit a8f112
    echo
Packit a8f112
Packit a8f112
    ident
Packit a8f112
Packit a8f112
    return 0
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
##########################
Packit a8f112
# VERSION_ERROR FUNCTION #
Packit a8f112
##########################
Packit a8f112
version_error ( ) {
Packit a8f112
    if [ "x$1" = "x" ] ; then
Packit a8f112
	echo "INTERNAL ERROR: version_error was not provided a version"
Packit a8f112
	exit 1
Packit a8f112
    fi
Packit a8f112
    if [ "x$2" = "x" ] ; then
Packit a8f112
	echo "INTERNAL ERROR: version_error was not provided an application name"
Packit a8f112
	exit 1
Packit a8f112
    fi
Packit a8f112
    $ECHO
Packit a8f112
    $ECHO "ERROR:  To prepare the ${PROJECT} build system from scratch,"
Packit a8f112
    $ECHO "        at least version $1 of $2 must be installed."
Packit a8f112
    $ECHO
Packit a8f112
    $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will"
Packit a8f112
    $ECHO "run configure or make.  Either the GNU Autotools will need to be installed"
Packit a8f112
    $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source"
Packit a8f112
    $ECHO "code on another system and then transferred to here. -- Cheers!"
Packit a8f112
    $ECHO
Packit a8f112
}
Packit a8f112
Packit a8f112
##########################
Packit a8f112
# VERSION_CHECK FUNCTION #
Packit a8f112
##########################
Packit a8f112
version_check ( ) {
Packit a8f112
    if [ "x$1" = "x" ] ; then
Packit a8f112
	echo "INTERNAL ERROR: version_check was not provided a minimum version"
Packit a8f112
	exit 1
Packit a8f112
    fi
Packit a8f112
    _min="$1"
Packit a8f112
    if [ "x$2" = "x" ] ; then
Packit a8f112
	echo "INTERNAL ERROR: version check was not provided a comparison version"
Packit a8f112
	exit 1
Packit a8f112
    fi
Packit a8f112
    _cur="$2"
Packit a8f112
Packit a8f112
    # needed to handle versions like 1.10 and 1.4-p6
Packit a8f112
    _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
Packit a8f112
    _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
Packit a8f112
Packit a8f112
    _min_major="`echo $_min | cut -d. -f1`"
Packit a8f112
    _min_minor="`echo $_min | cut -d. -f2`"
Packit a8f112
    _min_patch="`echo $_min | cut -d. -f3`"
Packit a8f112
Packit a8f112
    _cur_major="`echo $_cur | cut -d. -f1`"
Packit a8f112
    _cur_minor="`echo $_cur | cut -d. -f2`"
Packit a8f112
    _cur_patch="`echo $_cur | cut -d. -f3`"
Packit a8f112
Packit a8f112
    if [ "x$_min_major" = "x" ] ; then
Packit a8f112
	_min_major=0
Packit a8f112
    fi
Packit a8f112
    if [ "x$_min_minor" = "x" ] ; then
Packit a8f112
	_min_minor=0
Packit a8f112
    fi
Packit a8f112
    if [ "x$_min_patch" = "x" ] ; then
Packit a8f112
	_min_patch=0
Packit a8f112
    fi
Packit a8f112
    if [ "x$_cur_minor" = "x" ] ; then
Packit a8f112
	_cur_major=0
Packit a8f112
    fi
Packit a8f112
    if [ "x$_cur_minor" = "x" ] ; then
Packit a8f112
	_cur_minor=0
Packit a8f112
    fi
Packit a8f112
    if [ "x$_cur_patch" = "x" ] ; then
Packit a8f112
	_cur_patch=0
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}"
Packit a8f112
Packit a8f112
    if [ $_min_major -lt $_cur_major ] ; then
Packit a8f112
	return 0
Packit a8f112
    elif [ $_min_major -eq $_cur_major ] ; then
Packit a8f112
	if [ $_min_minor -lt $_cur_minor ] ; then
Packit a8f112
	    return 0
Packit a8f112
	elif [ $_min_minor -eq $_cur_minor ] ; then
Packit a8f112
	    if [ $_min_patch -lt $_cur_patch ] ; then
Packit a8f112
		return 0
Packit a8f112
	    elif [ $_min_patch -eq $_cur_patch ] ; then
Packit a8f112
		return 0
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
    fi
Packit a8f112
    return 1
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
######################################
Packit a8f112
# LOCATE_CONFIGURE_TEMPLATE FUNCTION #
Packit a8f112
######################################
Packit a8f112
locate_configure_template ( ) {
Packit a8f112
    _pwd="`pwd`"
Packit a8f112
    if test -f "./configure.ac" ; then
Packit a8f112
	echo "./configure.ac"
Packit a8f112
    elif test -f "./configure.in" ; then
Packit a8f112
	echo "./configure.in"
Packit a8f112
    elif test -f "$_pwd/configure.ac" ; then
Packit a8f112
	echo "$_pwd/configure.ac"
Packit a8f112
    elif test -f "$_pwd/configure.in" ; then
Packit a8f112
	echo "$_pwd/configure.in"
Packit a8f112
    elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then
Packit a8f112
	echo "$PATH_TO_AUTOGEN/configure.ac"
Packit a8f112
    elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then
Packit a8f112
	echo "$PATH_TO_AUTOGEN/configure.in"
Packit a8f112
    fi
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
##################
Packit a8f112
# argument check #
Packit a8f112
##################
Packit a8f112
ARGS="$*"
Packit a8f112
PATH_TO_AUTOGEN="`dirname $0`"
Packit a8f112
NAME_OF_AUTOGEN="`basename $0`"
Packit a8f112
AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN"
Packit a8f112
Packit a8f112
LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4"
Packit a8f112
Packit a8f112
if [ "x$HELP" = "x" ] ; then
Packit a8f112
    HELP=no
Packit a8f112
fi
Packit a8f112
if [ "x$QUIET" = "x" ] ; then
Packit a8f112
    QUIET=no
Packit a8f112
fi
Packit a8f112
if [ "x$VERBOSE" = "x" ] ; then
Packit a8f112
    VERBOSE=no
Packit a8f112
fi
Packit a8f112
if [ "x$VERSION_ONLY" = "x" ] ; then
Packit a8f112
    VERSION_ONLY=no
Packit a8f112
fi
Packit a8f112
if [ "x$DOWNLOAD" = "x" ] ; then
Packit a8f112
    DOWNLOAD=no
Packit a8f112
fi
Packit a8f112
if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then
Packit a8f112
    AUTORECONF_OPTIONS="-i -f"
Packit a8f112
fi
Packit a8f112
if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then
Packit a8f112
    AUTOCONF_OPTIONS="-f"
Packit a8f112
fi
Packit a8f112
if [ "x$AUTOMAKE_OPTIONS" = "x" ] ; then
Packit a8f112
    AUTOMAKE_OPTIONS="-a -c -f"
Packit a8f112
fi
Packit a8f112
ALT_AUTOMAKE_OPTIONS="-a -c"
Packit a8f112
if [ "x$LIBTOOLIZE_OPTIONS" = "x" ] ; then
Packit a8f112
    LIBTOOLIZE_OPTIONS="--automake -c -f"
Packit a8f112
fi
Packit a8f112
ALT_LIBTOOLIZE_OPTIONS="--automake --copy --force"
Packit a8f112
if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then
Packit a8f112
    ACLOCAL_OPTIONS=""
Packit a8f112
fi
Packit a8f112
if [ "x$AUTOHEADER_OPTIONS" = "x" ] ; then
Packit a8f112
    AUTOHEADER_OPTIONS=""
Packit a8f112
fi
Packit a8f112
if [ "x$CONFIG_GUESS_URL" = "x" ] ; then
Packit a8f112
    CONFIG_GUESS_URL="http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/config.guess;hb=HEAD"
Packit a8f112
fi
Packit a8f112
for arg in $ARGS ; do
Packit a8f112
    case "x$arg" in
Packit a8f112
	x--help) HELP=yes ;;
Packit a8f112
	x-[hH]) HELP=yes ;;
Packit a8f112
	x--quiet) QUIET=yes ;;
Packit a8f112
	x-[qQ]) QUIET=yes ;;
Packit a8f112
	x--verbose) VERBOSE=yes ;;
Packit a8f112
	x-[dD]) DOWNLOAD=yes ;;
Packit a8f112
	x--download) DOWNLOAD=yes ;;
Packit a8f112
	x-[vV]) VERBOSE=yes ;;
Packit a8f112
	x--version) VERSION_ONLY=yes ;;
Packit a8f112
	*)
Packit a8f112
	    echo "Unknown option: $arg"
Packit a8f112
	    echo
Packit a8f112
	    usage
Packit a8f112
	    exit 1
Packit a8f112
	    ;;
Packit a8f112
    esac
Packit a8f112
done
Packit a8f112
Packit a8f112
Packit a8f112
#####################
Packit a8f112
# environment check #
Packit a8f112
#####################
Packit a8f112
Packit a8f112
# sanity check before recursions potentially begin
Packit a8f112
if [ ! -f "$AUTOGEN_SH" ] ; then
Packit a8f112
    echo "INTERNAL ERROR: $AUTOGEN_SH does not exist"
Packit a8f112
    if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then
Packit a8f112
	echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH"
Packit a8f112
    fi
Packit a8f112
    exit 1
Packit a8f112
fi
Packit a8f112
Packit a8f112
# force locale setting to C so things like date output as expected
Packit a8f112
LC_ALL=C
Packit a8f112
Packit a8f112
# commands that this script expects
Packit a8f112
for __cmd in echo head tail pwd ; do
Packit a8f112
    echo "test" | $__cmd > /dev/null 2>&1
Packit a8f112
    if [ $? != 0 ] ; then
Packit a8f112
	echo "INTERNAL ERROR: '${__cmd}' command is required"
Packit a8f112
	exit 2
Packit a8f112
    fi
Packit a8f112
done
Packit a8f112
echo "test" | grep "test" > /dev/null 2>&1
Packit a8f112
if test ! x$? = x0 ; then
Packit a8f112
    echo "INTERNAL ERROR: grep command is required"
Packit a8f112
    exit 1
Packit a8f112
fi
Packit a8f112
echo "test" | sed "s/test/test/" > /dev/null 2>&1
Packit a8f112
if test ! x$? = x0 ; then
Packit a8f112
    echo "INTERNAL ERROR: sed command is required"
Packit a8f112
    exit 1
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
# determine the behavior of echo
Packit a8f112
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
Packit a8f112
    *c*,-n*) ECHO_N= ECHO_C='
Packit a8f112
' ECHO_T='	' ;;
Packit a8f112
    *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
Packit a8f112
    *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
Packit a8f112
esac
Packit a8f112
Packit a8f112
# determine the behavior of head
Packit a8f112
case "x`echo 'head' | head -n 1 2>&1`" in
Packit a8f112
    *xhead*) HEAD_N="n " ;;
Packit a8f112
    *) HEAD_N="" ;;
Packit a8f112
esac
Packit a8f112
Packit a8f112
# determine the behavior of tail
Packit a8f112
case "x`echo 'tail' | tail -n 1 2>&1`" in
Packit a8f112
    *xtail*) TAIL_N="n " ;;
Packit a8f112
    *) TAIL_N="" ;;
Packit a8f112
esac
Packit a8f112
Packit a8f112
VERBOSE_ECHO=:
Packit a8f112
ECHO=:
Packit a8f112
if [ "x$QUIET" = "xyes" ] ; then
Packit a8f112
    if [ "x$VERBOSE" = "xyes" ] ; then
Packit a8f112
	echo "Verbose output quelled by quiet option.  Further output disabled."
Packit a8f112
    fi
Packit a8f112
else
Packit a8f112
    ECHO=echo
Packit a8f112
    if [ "x$VERBOSE" = "xyes" ] ; then
Packit a8f112
	echo "Verbose output enabled"
Packit a8f112
	VERBOSE_ECHO=echo
Packit a8f112
    fi
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
# allow a recursive run to disable further recursions
Packit a8f112
if [ "x$RUN_RECURSIVE" = "x" ] ; then
Packit a8f112
    RUN_RECURSIVE=yes
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
################################################
Packit a8f112
# check for help arg and bypass version checks #
Packit a8f112
################################################
Packit a8f112
if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then
Packit a8f112
    HELP=yes
Packit a8f112
fi
Packit a8f112
if [ "x$HELP" = "xyes" ] ; then
Packit a8f112
    usage
Packit a8f112
    $ECHO "---"
Packit a8f112
    $ECHO "Help was requested.  No preparation or configuration will be performed."
Packit a8f112
    exit 0
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
#######################
Packit a8f112
# set up signal traps #
Packit a8f112
#######################
Packit a8f112
untrap_abnormal ( ) {
Packit a8f112
    for sig in 1 2 13 15; do
Packit a8f112
	trap - $sig
Packit a8f112
    done
Packit a8f112
}
Packit a8f112
Packit a8f112
# do this cleanup whenever we exit.
Packit a8f112
trap '
Packit a8f112
    # start from the root
Packit a8f112
    if test -d "$START_PATH" ; then
Packit a8f112
	cd "$START_PATH"
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    # restore/delete backup files
Packit a8f112
    if test "x$PFC_INIT" = "x1" ; then
Packit a8f112
	recursive_restore
Packit a8f112
    fi
Packit a8f112
' 0
Packit a8f112
Packit a8f112
# trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15)
Packit a8f112
for sig in 1 2 13 15; do
Packit a8f112
    trap '
Packit a8f112
	$ECHO ""
Packit a8f112
	$ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'"
Packit a8f112
Packit a8f112
	# start from the root
Packit a8f112
	if test -d "$START_PATH" ; then
Packit a8f112
	    cd "$START_PATH"
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	# clean up on abnormal exit
Packit a8f112
	$VERBOSE_ECHO "rm -rf autom4te.cache"
Packit a8f112
	rm -rf autom4te.cache
Packit a8f112
Packit a8f112
	if test -f "acinclude.m4.$$.backup" ; then
Packit a8f112
	    $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4"
Packit a8f112
	    chmod u+w acinclude.m4
Packit a8f112
	    cat acinclude.m4.$$.backup > acinclude.m4
Packit a8f112
Packit a8f112
	    $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup"
Packit a8f112
	    rm -f acinclude.m4.$$.backup
Packit a8f112
        fi
Packit a8f112
Packit a8f112
	{ (exit 1); exit 1; }
Packit a8f112
' $sig
Packit a8f112
done
Packit a8f112
Packit a8f112
Packit a8f112
#############################
Packit a8f112
# look for a configure file #
Packit a8f112
#############################
Packit a8f112
if [ "x$CONFIGURE" = "x" ] ; then
Packit a8f112
    CONFIGURE="`locate_configure_template`"
Packit a8f112
    if [ ! "x$CONFIGURE" = "x" ] ; then
Packit a8f112
	$VERBOSE_ECHO "Found a configure template: $CONFIGURE"
Packit a8f112
    fi
Packit a8f112
else
Packit a8f112
    $ECHO "Using CONFIGURE environment variable override: $CONFIGURE"
Packit a8f112
fi
Packit a8f112
if [ "x$CONFIGURE" = "x" ] ; then
Packit a8f112
    if [ "x$VERSION_ONLY" = "xyes" ] ; then
Packit a8f112
	CONFIGURE=/dev/null
Packit a8f112
    else
Packit a8f112
	$ECHO
Packit a8f112
	$ECHO "A configure.ac or configure.in file could not be located implying"
Packit a8f112
	$ECHO "that the GNU Build System is at least not used in this directory.  In"
Packit a8f112
	$ECHO "any case, there is nothing to do here without one of those files."
Packit a8f112
	$ECHO
Packit a8f112
	$ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
Packit a8f112
	exit 1
Packit a8f112
    fi
Packit a8f112
fi
Packit a8f112
Packit a8f112
####################
Packit a8f112
# get project name #
Packit a8f112
####################
Packit a8f112
if [ "x$PROJECT" = "x" ] ; then
Packit a8f112
    PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ 	]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
Packit a8f112
    if [ "x$PROJECT" = "xAC_INIT" ] ; then
Packit a8f112
	# projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead
Packit a8f112
	PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ 	]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
Packit a8f112
    fi
Packit a8f112
    if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then
Packit a8f112
	PROJECT="project"
Packit a8f112
    fi
Packit a8f112
    if [ "x$PROJECT" = "x" ] ; then
Packit a8f112
	PROJECT="project"
Packit a8f112
    fi
Packit a8f112
else
Packit a8f112
    $ECHO "Using PROJECT environment variable override: $PROJECT"
Packit a8f112
fi
Packit a8f112
$ECHO "Preparing the $PROJECT build system...please wait"
Packit a8f112
$ECHO
Packit a8f112
Packit a8f112
Packit a8f112
########################
Packit a8f112
# check for autoreconf #
Packit a8f112
########################
Packit a8f112
HAVE_AUTORECONF=no
Packit a8f112
if [ "x$AUTORECONF" = "x" ] ; then
Packit a8f112
    for AUTORECONF in autoreconf ; do
Packit a8f112
	$VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version"
Packit a8f112
	$AUTORECONF --version > /dev/null 2>&1
Packit a8f112
	if [ $? = 0 ] ; then
Packit a8f112
	    HAVE_AUTORECONF=yes
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
else
Packit a8f112
    HAVE_AUTORECONF=yes
Packit a8f112
    $ECHO "Using AUTORECONF environment variable override: $AUTORECONF"
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
##########################
Packit a8f112
# autoconf version check #
Packit a8f112
##########################
Packit a8f112
_acfound=no
Packit a8f112
if [ "x$AUTOCONF" = "x" ] ; then
Packit a8f112
    for AUTOCONF in autoconf ; do
Packit a8f112
	$VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version"
Packit a8f112
	$AUTOCONF --version > /dev/null 2>&1
Packit a8f112
	if [ $? = 0 ] ; then
Packit a8f112
	    _acfound=yes
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
else
Packit a8f112
    _acfound=yes
Packit a8f112
    $ECHO "Using AUTOCONF environment variable override: $AUTOCONF"
Packit a8f112
fi
Packit a8f112
Packit a8f112
_report_error=no
Packit a8f112
if [ ! "x$_acfound" = "xyes" ] ; then
Packit a8f112
    $ECHO "ERROR:  Unable to locate GNU Autoconf."
Packit a8f112
    _report_error=yes
Packit a8f112
else
Packit a8f112
    _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
Packit a8f112
    if [ "x$_version" = "x" ] ; then
Packit a8f112
	_version="0.0.0"
Packit a8f112
    fi
Packit a8f112
    $ECHO "Found GNU Autoconf version $_version"
Packit a8f112
    version_check "$AUTOCONF_VERSION" "$_version"
Packit a8f112
    if [ $? -ne 0 ] ; then
Packit a8f112
	_report_error=yes
Packit a8f112
    fi
Packit a8f112
fi
Packit a8f112
if [ "x$_report_error" = "xyes" ] ; then
Packit a8f112
    version_error "$AUTOCONF_VERSION" "GNU Autoconf"
Packit a8f112
    exit 1
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
##########################
Packit a8f112
# automake version check #
Packit a8f112
##########################
Packit a8f112
_amfound=no
Packit a8f112
if [ "x$AUTOMAKE" = "x" ] ; then
Packit a8f112
    for AUTOMAKE in automake ; do
Packit a8f112
	$VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version"
Packit a8f112
	$AUTOMAKE --version > /dev/null 2>&1
Packit a8f112
	if [ $? = 0 ] ; then
Packit a8f112
	    _amfound=yes
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
else
Packit a8f112
    _amfound=yes
Packit a8f112
    $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE"
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
_report_error=no
Packit a8f112
if [ ! "x$_amfound" = "xyes" ] ; then
Packit a8f112
    $ECHO
Packit a8f112
    $ECHO "ERROR: Unable to locate GNU Automake."
Packit a8f112
    _report_error=yes
Packit a8f112
else
Packit a8f112
    _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
Packit a8f112
    if [ "x$_version" = "x" ] ; then
Packit a8f112
	_version="0.0.0"
Packit a8f112
    fi
Packit a8f112
    $ECHO "Found GNU Automake version $_version"
Packit a8f112
    version_check "$AUTOMAKE_VERSION" "$_version"
Packit a8f112
    if [ $? -ne 0 ] ; then
Packit a8f112
	_report_error=yes
Packit a8f112
    fi
Packit a8f112
fi
Packit a8f112
if [ "x$_report_error" = "xyes" ] ; then
Packit a8f112
    version_error "$AUTOMAKE_VERSION" "GNU Automake"
Packit a8f112
    exit 1
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
########################
Packit a8f112
# check for libtoolize #
Packit a8f112
########################
Packit a8f112
HAVE_LIBTOOLIZE=yes
Packit a8f112
HAVE_ALT_LIBTOOLIZE=no
Packit a8f112
_ltfound=no
Packit a8f112
if [ "x$LIBTOOLIZE" = "x" ] ; then
Packit a8f112
    LIBTOOLIZE=libtoolize
Packit a8f112
    $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version"
Packit a8f112
    $LIBTOOLIZE --version > /dev/null 2>&1
Packit a8f112
    if [ ! $? = 0 ] ; then
Packit a8f112
	HAVE_LIBTOOLIZE=no
Packit a8f112
	$ECHO
Packit a8f112
	if [ "x$HAVE_AUTORECONF" = "xno" ] ; then
Packit a8f112
	    $ECHO "Warning:  libtoolize does not appear to be available."
Packit a8f112
	else
Packit a8f112
	    $ECHO "Warning:  libtoolize does not appear to be available.  This means that"
Packit a8f112
	    $ECHO "the automatic build preparation via autoreconf will probably not work."
Packit a8f112
	    $ECHO "Preparing the build by running each step individually, however, should"
Packit a8f112
	    $ECHO "work and will be done automatically for you if autoreconf fails."
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	# look for some alternates
Packit a8f112
	for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do
Packit a8f112
	    $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version"
Packit a8f112
	    _glibtoolize="`$tool --version > /dev/null 2>&1`"
Packit a8f112
	    if [ $? = 0 ] ; then
Packit a8f112
		$VERBOSE_ECHO "Found $tool --version"
Packit a8f112
		_glti="`which $tool`"
Packit a8f112
		if [ "x$_glti" = "x" ] ; then
Packit a8f112
		    $VERBOSE_ECHO "Cannot find $tool with which"
Packit a8f112
		    continue;
Packit a8f112
		fi
Packit a8f112
		if test ! -f "$_glti" ; then
Packit a8f112
		    $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file"
Packit a8f112
		    continue;
Packit a8f112
		fi
Packit a8f112
		_gltidir="`dirname $_glti`"
Packit a8f112
		if [ "x$_gltidir" = "x" ] ; then
Packit a8f112
		    $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti"
Packit a8f112
		    continue;
Packit a8f112
		fi
Packit a8f112
		if test ! -d "$_gltidir" ; then
Packit a8f112
		    $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory"
Packit a8f112
		    continue;
Packit a8f112
		fi
Packit a8f112
		HAVE_ALT_LIBTOOLIZE=yes
Packit a8f112
		LIBTOOLIZE="$tool"
Packit a8f112
		$ECHO
Packit a8f112
		$ECHO "Fortunately, $tool was found which means that your system may simply"
Packit a8f112
		$ECHO "have a non-standard or incomplete GNU Autotools install.  If you have"
Packit a8f112
		$ECHO "sufficient system access, it may be possible to quell this warning by"
Packit a8f112
		$ECHO "running:"
Packit a8f112
		$ECHO
Packit a8f112
		sudo -V > /dev/null 2>&1
Packit a8f112
		if [ $? = 0 ] ; then
Packit a8f112
		    $ECHO "   sudo ln -s $_glti $_gltidir/libtoolize"
Packit a8f112
		    $ECHO
Packit a8f112
		else
Packit a8f112
		    $ECHO "   ln -s $_glti $_gltidir/libtoolize"
Packit a8f112
		    $ECHO
Packit a8f112
		    $ECHO "Run that as root or with proper permissions to the $_gltidir directory"
Packit a8f112
		    $ECHO
Packit a8f112
		fi
Packit a8f112
		_ltfound=yes
Packit a8f112
		break
Packit a8f112
	    fi
Packit a8f112
	done
Packit a8f112
    else
Packit a8f112
	_ltfound=yes
Packit a8f112
    fi
Packit a8f112
else
Packit a8f112
    _ltfound=yes
Packit a8f112
    $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE"
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
############################
Packit a8f112
# libtoolize version check #
Packit a8f112
############################
Packit a8f112
_report_error=no
Packit a8f112
if [ ! "x$_ltfound" = "xyes" ] ; then
Packit a8f112
    $ECHO
Packit a8f112
    $ECHO "ERROR: Unable to locate GNU Libtool."
Packit a8f112
    _report_error=yes
Packit a8f112
else
Packit a8f112
    _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
Packit a8f112
    if [ "x$_version" = "x" ] ; then
Packit a8f112
	_version="0.0.0"
Packit a8f112
    fi
Packit a8f112
    $ECHO "Found GNU Libtool version $_version"
Packit a8f112
    version_check "$LIBTOOL_VERSION" "$_version"
Packit a8f112
    if [ $? -ne 0 ] ; then
Packit a8f112
	_report_error=yes
Packit a8f112
    fi
Packit a8f112
fi
Packit a8f112
if [ "x$_report_error" = "xyes" ] ; then
Packit a8f112
    version_error "$LIBTOOL_VERSION" "GNU Libtool"
Packit a8f112
    exit 1
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
#####################
Packit a8f112
# check for aclocal #
Packit a8f112
#####################
Packit a8f112
if [ "x$ACLOCAL" = "x" ] ; then
Packit a8f112
    for ACLOCAL in aclocal ; do
Packit a8f112
	$VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version"
Packit a8f112
	$ACLOCAL --version > /dev/null 2>&1
Packit a8f112
	if [ $? = 0 ] ; then
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
else
Packit a8f112
    $ECHO "Using ACLOCAL environment variable override: $ACLOCAL"
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
########################
Packit a8f112
# check for autoheader #
Packit a8f112
########################
Packit a8f112
if [ "x$AUTOHEADER" = "x" ] ; then
Packit a8f112
    for AUTOHEADER in autoheader ; do
Packit a8f112
	$VERBOSE_ECHO "Checking autoheader version: $AUTOHEADER --version"
Packit a8f112
	$AUTOHEADER --version > /dev/null 2>&1
Packit a8f112
	if [ $? = 0 ] ; then
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
else
Packit a8f112
    $ECHO "Using AUTOHEADER environment variable override: $AUTOHEADER"
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
#########################
Packit a8f112
# check if version only #
Packit a8f112
#########################
Packit a8f112
$VERBOSE_ECHO "Checking whether to only output version information"
Packit a8f112
if [ "x$VERSION_ONLY" = "xyes" ] ; then
Packit a8f112
    $ECHO
Packit a8f112
    ident
Packit a8f112
    $ECHO "---"
Packit a8f112
    $ECHO "Version requested.  No preparation or configuration will be performed."
Packit a8f112
    exit 0
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
#################################
Packit a8f112
# PROTECT_FROM_CLOBBER FUNCTION #
Packit a8f112
#################################
Packit a8f112
protect_from_clobber ( ) {
Packit a8f112
    PFC_INIT=1
Packit a8f112
Packit a8f112
    # protect COPYING & INSTALL from overwrite by automake.  the
Packit a8f112
    # automake force option will (inappropriately) ignore the existing
Packit a8f112
    # contents of a COPYING and/or INSTALL files (depending on the
Packit a8f112
    # version) instead of just forcing *missing* files like it does
Packit a8f112
    # for AUTHORS, NEWS, and README. this is broken but extremely
Packit a8f112
    # prevalent behavior, so we protect against it by keeping a backup
Packit a8f112
    # of the file that can later be restored.
Packit a8f112
Packit a8f112
    for file in COPYING INSTALL ; do
Packit a8f112
	if test -f ${file} ; then
Packit a8f112
	    if test -f ${file}.$$.protect_from_automake.backup ; then
Packit a8f112
		$VERBOSE_ECHO "Already backed up ${file} in `pwd`"
Packit a8f112
	    else
Packit a8f112
		$VERBOSE_ECHO "Backing up ${file} in `pwd`"
Packit a8f112
		$VERBOSE_ECHO "cp -p ${file} ${file}.$$.protect_from_automake.backup"
Packit a8f112
		cp -p ${file} ${file}.$$.protect_from_automake.backup
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
##############################
Packit a8f112
# RECURSIVE_PROTECT FUNCTION #
Packit a8f112
##############################
Packit a8f112
recursive_protect ( ) {
Packit a8f112
Packit a8f112
    # for projects using recursive configure, run the build
Packit a8f112
    # preparation steps for the subdirectories.  this function assumes
Packit a8f112
    # START_PATH was set to pwd before recursion begins so that
Packit a8f112
    # relative paths work.
Packit a8f112
Packit a8f112
    # git 'r done, protect COPYING and INSTALL from being clobbered
Packit a8f112
    protect_from_clobber
Packit a8f112
Packit a8f112
    if test -d autom4te.cache ; then
Packit a8f112
	$VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
Packit a8f112
	$VERBOSE_ECHO "rm -rf autom4te.cache"
Packit a8f112
	rm -rf autom4te.cache
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    # find configure template
Packit a8f112
    _configure="`locate_configure_template`"
Packit a8f112
    if [ "x$_configure" = "x" ] ; then
Packit a8f112
	return
Packit a8f112
    fi
Packit a8f112
    # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure"
Packit a8f112
Packit a8f112
    # look for subdirs
Packit a8f112
    # $VERBOSE_ECHO "Looking for subdirs in `pwd`"
Packit a8f112
    _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ 	]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
Packit a8f112
    CHECK_DIRS=""
Packit a8f112
    for dir in $_det_config_subdirs ; do
Packit a8f112
	if test -d "`pwd`/$dir" ; then
Packit a8f112
	    CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    # process subdirs
Packit a8f112
    if [ ! "x$CHECK_DIRS" = "x" ] ; then
Packit a8f112
	$VERBOSE_ECHO "Recursively scanning the following directories:"
Packit a8f112
	$VERBOSE_ECHO "  $CHECK_DIRS"
Packit a8f112
	for dir in $CHECK_DIRS ; do
Packit a8f112
	    $VERBOSE_ECHO "Protecting files from automake in $dir"
Packit a8f112
	    cd "$START_PATH"
Packit a8f112
	    eval "cd $dir"
Packit a8f112
Packit a8f112
	    # recursively git 'r done
Packit a8f112
	    recursive_protect
Packit a8f112
	done
Packit a8f112
    fi
Packit a8f112
} # end of recursive_protect
Packit a8f112
Packit a8f112
Packit a8f112
#############################
Packit a8f112
# RESTORE_CLOBBERED FUNCION #
Packit a8f112
#############################
Packit a8f112
restore_clobbered ( ) {
Packit a8f112
Packit a8f112
    # The automake (and autoreconf by extension) -f/--force-missing
Packit a8f112
    # option may overwrite COPYING and INSTALL even if they do exist.
Packit a8f112
    # Here we restore the files if necessary.
Packit a8f112
Packit a8f112
    spacer=no
Packit a8f112
Packit a8f112
    for file in COPYING INSTALL ; do
Packit a8f112
	if test -f ${file}.$$.protect_from_automake.backup ; then
Packit a8f112
	    if test -f ${file} ; then
Packit a8f112
	    # compare entire content, restore if needed
Packit a8f112
	    if test "x`cat ${file}`" != "x`cat ${file}.$$.protect_from_automake.backup`" ; then
Packit a8f112
		if test "x$spacer" = "xno" ; then
Packit a8f112
		    $VERBOSE_ECHO
Packit a8f112
		    spacer=yes
Packit a8f112
		fi
Packit a8f112
		# restore the backup
Packit a8f112
		$VERBOSE_ECHO "Restoring ${file} from backup (automake -f likely clobbered it)"
Packit a8f112
		$VERBOSE_ECHO "rm -f ${file}"
Packit a8f112
		rm -f ${file}
Packit a8f112
		$VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}"
Packit a8f112
		mv ${file}.$$.protect_from_automake.backup ${file}
Packit a8f112
	    fi # check contents
Packit a8f112
	    elif test -f ${file}.$$.protect_from_automake.backup ; then
Packit a8f112
		$VERBOSE_ECHO "mv ${file}.$$.protect_from_automake.backup ${file}"
Packit a8f112
		mv ${file}.$$.protect_from_automake.backup ${file}
Packit a8f112
	    fi # -f ${file}
Packit a8f112
	
Packit a8f112
	    # just in case
Packit a8f112
	    $VERBOSE_ECHO "rm -f ${file}.$$.protect_from_automake.backup"
Packit a8f112
	    rm -f ${file}.$$.protect_from_automake.backup
Packit a8f112
	fi # -f ${file}.$$.protect_from_automake.backup
Packit a8f112
    done
Packit a8f112
Packit a8f112
    CONFIGURE="`locate_configure_template`"
Packit a8f112
    if [ "x$CONFIGURE" = "x" ] ; then
Packit a8f112
	return
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    _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/'`"
Packit a8f112
    if test ! -d "$_aux_dir" ; then
Packit a8f112
	_aux_dir=.
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    for file in config.guess config.sub ltmain.sh ; do
Packit a8f112
	if test -f "${_aux_dir}/${file}" ; then
Packit a8f112
	    $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\""
Packit a8f112
	    rm -f "${_aux_dir}/${file}.backup"
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
} # end of restore_clobbered
Packit a8f112
Packit a8f112
Packit a8f112
##############################
Packit a8f112
# RECURSIVE_RESTORE FUNCTION #
Packit a8f112
##############################
Packit a8f112
recursive_restore ( ) {
Packit a8f112
Packit a8f112
    # restore COPYING and INSTALL from backup if they were clobbered
Packit a8f112
    # for each directory recursively.
Packit a8f112
Packit a8f112
    # git 'r undone
Packit a8f112
    restore_clobbered
Packit a8f112
Packit a8f112
    # find configure template
Packit a8f112
    _configure="`locate_configure_template`"
Packit a8f112
    if [ "x$_configure" = "x" ] ; then
Packit a8f112
	return
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    # look for subdirs
Packit a8f112
    _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ 	]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
Packit a8f112
    CHECK_DIRS=""
Packit a8f112
    for dir in $_det_config_subdirs ; do
Packit a8f112
	if test -d "`pwd`/$dir" ; then
Packit a8f112
	    CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    # process subdirs
Packit a8f112
    if [ ! "x$CHECK_DIRS" = "x" ] ; then
Packit a8f112
	$VERBOSE_ECHO "Recursively scanning the following directories:"
Packit a8f112
	$VERBOSE_ECHO "  $CHECK_DIRS"
Packit a8f112
	for dir in $CHECK_DIRS ; do
Packit a8f112
	    $VERBOSE_ECHO "Checking files for automake damage in $dir"
Packit a8f112
	    cd "$START_PATH"
Packit a8f112
	    eval "cd $dir"
Packit a8f112
Packit a8f112
	    # recursively git 'r undone
Packit a8f112
	    recursive_restore
Packit a8f112
	done
Packit a8f112
    fi
Packit a8f112
} # end of recursive_restore
Packit a8f112
Packit a8f112
Packit a8f112
#######################
Packit a8f112
# INITIALIZE FUNCTION #
Packit a8f112
#######################
Packit a8f112
initialize ( ) {
Packit a8f112
Packit a8f112
    # this routine performs a variety of directory-specific
Packit a8f112
    # initializations.  some are sanity checks, some are preventive,
Packit a8f112
    # and some are necessary setup detection.
Packit a8f112
    #
Packit a8f112
    # this function sets:
Packit a8f112
    #   CONFIGURE
Packit a8f112
    #   SEARCH_DIRS
Packit a8f112
    #   CONFIG_SUBDIRS
Packit a8f112
Packit a8f112
    ##################################
Packit a8f112
    # check for a configure template #
Packit a8f112
    ##################################
Packit a8f112
    CONFIGURE="`locate_configure_template`"
Packit a8f112
    if [ "x$CONFIGURE" = "x" ] ; then
Packit a8f112
	$ECHO
Packit a8f112
	$ECHO "A configure.ac or configure.in file could not be located implying"
Packit a8f112
	$ECHO "that the GNU Build System is at least not used in this directory.  In"
Packit a8f112
	$ECHO "any case, there is nothing to do here without one of those files."
Packit a8f112
	$ECHO
Packit a8f112
	$ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
Packit a8f112
	exit 1
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    #####################
Packit a8f112
    # detect an aux dir #
Packit a8f112
    #####################
Packit a8f112
    _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/'`"
Packit a8f112
    if test ! -d "$_aux_dir" ; then
Packit a8f112
	_aux_dir=.
Packit a8f112
    else
Packit a8f112
	$VERBOSE_ECHO "Detected auxillary directory: $_aux_dir"
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    ################################
Packit a8f112
    # detect a recursive configure #
Packit a8f112
    ################################
Packit a8f112
    CONFIG_SUBDIRS=""
Packit a8f112
    _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ 	]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
Packit a8f112
    for dir in $_det_config_subdirs ; do
Packit a8f112
	if test -d "`pwd`/$dir" ; then
Packit a8f112
	    $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir"
Packit a8f112
	    CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir"
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    ###########################################################
Packit a8f112
    # make sure certain required files exist for GNU projects #
Packit a8f112
    ###########################################################
Packit a8f112
    _marker_found=""
Packit a8f112
    _marker_found_message_intro='Detected non-GNU marker "'
Packit a8f112
    _marker_found_message_mid='" in '
Packit a8f112
    for marker in foreign cygnus ; do
Packit a8f112
	_marker_found_message=${_marker_found_message_intro}${marker}${_marker_found_message_mid}
Packit a8f112
	_marker_found="`grep 'AM_INIT_AUTOMAKE.*'${marker} $CONFIGURE`"
Packit a8f112
	if [ ! "x$_marker_found" = "x" ] ; then
Packit a8f112
	    $VERBOSE_ECHO "${_marker_found_message}`basename \"$CONFIGURE\"`"
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
	if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then
Packit a8f112
	    _marker_found="`grep 'AUTOMAKE_OPTIONS.*'${marker} Makefile.am`"
Packit a8f112
	    if [ ! "x$_marker_found" = "x" ] ; then
Packit a8f112
		$VERBOSE_ECHO "${_marker_found_message}Makefile.am"
Packit a8f112
		break
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
    if [ "x${_marker_found}" = "x" ] ; then
Packit a8f112
	_suggest_foreign=no
Packit a8f112
	for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do
Packit a8f112
	    if [ ! -f $file ] ; then
Packit a8f112
		$VERBOSE_ECHO "Touching ${file} since it does not exist"
Packit a8f112
		_suggest_foreign=yes
Packit a8f112
		touch $file
Packit a8f112
	    fi
Packit a8f112
	done
Packit a8f112
Packit a8f112
	if [ "x${_suggest_foreign}" = "xyes" ] ; then
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "Warning: Several files expected of projects that conform to the GNU"
Packit a8f112
	    $ECHO "coding standards were not found.  The files were automatically added"
Packit a8f112
	    $ECHO "for you since you do not have a 'foreign' declaration specified."
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "Considered adding 'foreign' to AM_INIT_AUTOMAKE in `basename \"$CONFIGURE\"`"
Packit a8f112
	    if test -f "`dirname \"$CONFIGURE\"/Makefile.am`" ; then
Packit a8f112
		$ECHO "or to AUTOMAKE_OPTIONS in your top-level Makefile.am file."
Packit a8f112
	    fi
Packit a8f112
	    $ECHO
Packit a8f112
	fi
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    ##################################################
Packit a8f112
    # make sure certain generated files do not exist #
Packit a8f112
    ##################################################
Packit a8f112
    for file in config.guess config.sub ltmain.sh ; do
Packit a8f112
	if test -f "${_aux_dir}/${file}" ; then
Packit a8f112
	    $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\""
Packit a8f112
	    mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup"
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    ############################
Packit a8f112
    # search alternate m4 dirs #
Packit a8f112
    ############################
Packit a8f112
    SEARCH_DIRS=""
Packit a8f112
    for dir in m4 ; do
Packit a8f112
	if [ -d $dir ] ; then
Packit a8f112
	    $VERBOSE_ECHO "Found extra aclocal search directory: $dir"
Packit a8f112
	    SEARCH_DIRS="$SEARCH_DIRS -I $dir"
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    ######################################
Packit a8f112
    # remove any previous build products #
Packit a8f112
    ######################################
Packit a8f112
    if test -d autom4te.cache ; then
Packit a8f112
	$VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
Packit a8f112
	$VERBOSE_ECHO "rm -rf autom4te.cache"
Packit a8f112
	rm -rf autom4te.cache
Packit a8f112
    fi
Packit a8f112
# tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it
Packit a8f112
#     if test -f aclocal.m4 ; then
Packit a8f112
# 	$VERBOSE_ECHO "Found an aclocal.m4 file, deleting it"
Packit a8f112
# 	$VERBOSE_ECHO "rm -f aclocal.m4"
Packit a8f112
# 	rm -f aclocal.m4
Packit a8f112
#     fi
Packit a8f112
Packit a8f112
} # end of initialize()
Packit a8f112
Packit a8f112
Packit a8f112
##############
Packit a8f112
# initialize #
Packit a8f112
##############
Packit a8f112
Packit a8f112
# stash path
Packit a8f112
START_PATH="`pwd`"
Packit a8f112
Packit a8f112
# Before running autoreconf or manual steps, some prep detection work
Packit a8f112
# is necessary or useful.  Only needs to occur once per directory, but
Packit a8f112
# does need to traverse the entire subconfigure hierarchy to protect
Packit a8f112
# files from being clobbered even by autoreconf.
Packit a8f112
recursive_protect
Packit a8f112
Packit a8f112
# start from where we started
Packit a8f112
cd "$START_PATH"
Packit a8f112
Packit a8f112
# get ready to process
Packit a8f112
initialize
Packit a8f112
Packit a8f112
Packit a8f112
#########################################
Packit a8f112
# DOWNLOAD_GNULIB_CONFIG_GUESS FUNCTION #
Packit a8f112
#########################################
Packit a8f112
Packit a8f112
# TODO - should make sure wget/curl exist and/or work before trying to
Packit a8f112
# use them.
Packit a8f112
Packit a8f112
download_gnulib_config_guess () {
Packit a8f112
    # abuse gitweb to download gnulib's latest config.guess via HTTP
Packit a8f112
    config_guess_temp="config.guess.$$.download"
Packit a8f112
    ret=1
Packit a8f112
    for __cmd in wget curl fetch ; do
Packit a8f112
	$VERBOSE_ECHO "Checking for command ${__cmd}"
Packit a8f112
	${__cmd} --version > /dev/null 2>&1
Packit a8f112
	ret=$?
Packit a8f112
	if [ ! $ret = 0 ] ; then
Packit a8f112
	    continue
Packit a8f112
        fi
Packit a8f112
Packit a8f112
	__cmd_version=`${__cmd} --version | head -n 1 | sed -e 's/^[^0-9]\+//' -e 's/ .*//'`
Packit a8f112
	$VERBOSE_ECHO "Found ${__cmd} ${__cmd_version}"
Packit a8f112
Packit a8f112
	opts=""
Packit a8f112
	case ${__cmd} in
Packit a8f112
	    wget)
Packit a8f112
		opts="-O" 
Packit a8f112
		;;
Packit a8f112
	    curl)
Packit a8f112
		opts="-o"
Packit a8f112
		;;
Packit a8f112
	    fetch)
Packit a8f112
		opts="-t 5 -f"
Packit a8f112
		;;
Packit a8f112
	esac
Packit a8f112
Packit a8f112
	$VERBOSE_ECHO "Running $__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\""
Packit a8f112
	eval "$__cmd \"${CONFIG_GUESS_URL}\" $opts \"${config_guess_temp}\"" > /dev/null 2>&1
Packit a8f112
	if [ $? = 0 ] ; then
Packit a8f112
	    mv -f "${config_guess_temp}" ${_aux_dir}/config.guess
Packit a8f112
	    ret=0
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    if [ ! $ret = 0 ] ; then
Packit a8f112
	$ECHO "Warning: config.guess download failed from: $CONFIG_GUESS_URL"
Packit a8f112
	rm -f "${config_guess_temp}"
Packit a8f112
    fi
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
##############################
Packit a8f112
# LIBTOOLIZE_NEEDED FUNCTION #
Packit a8f112
##############################
Packit a8f112
libtoolize_needed () {
Packit a8f112
    ret=1 # means no, don't need libtoolize
Packit a8f112
    for feature in AC_PROG_LIBTOOL AM_PROG_LIBTOOL LT_INIT ; do
Packit a8f112
	$VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
Packit a8f112
	found="`grep \"^$feature.*\" $CONFIGURE`"
Packit a8f112
	if [ ! "x$found" = "x" ] ; then
Packit a8f112
	    ret=0 # means yes, need to run libtoolize
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
    return ${ret}
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
Packit a8f112
############################################
Packit a8f112
# prepare build via autoreconf or manually #
Packit a8f112
############################################
Packit a8f112
reconfigure_manually=no
Packit a8f112
if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then
Packit a8f112
    $ECHO
Packit a8f112
    $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C"
Packit a8f112
Packit a8f112
    $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS"
Packit a8f112
    autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`"
Packit a8f112
    ret=$?
Packit a8f112
    $VERBOSE_ECHO "$autoreconf_output"
Packit a8f112
Packit a8f112
    if [ ! $ret = 0 ] ; then
Packit a8f112
	if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
Packit a8f112
	    if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then
Packit a8f112
		$ECHO
Packit a8f112
		$ECHO "Warning: autoreconf failed but due to what is usually a common libtool"
Packit a8f112
		$ECHO "misconfiguration issue.  This problem is encountered on systems that"
Packit a8f112
		$ECHO "have installed libtoolize under a different name without providing a"
Packit a8f112
		$ECHO "symbolic link or without setting the LIBTOOLIZE environment variable."
Packit a8f112
		$ECHO
Packit a8f112
		$ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE"
Packit a8f112
Packit a8f112
		export LIBTOOLIZE
Packit a8f112
		RUN_RECURSIVE=no
Packit a8f112
		export RUN_RECURSIVE
Packit a8f112
		untrap_abnormal
Packit a8f112
Packit a8f112
		$VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
Packit a8f112
		sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
Packit a8f112
		exit $?
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	$ECHO "Warning: $AUTORECONF failed"
Packit a8f112
Packit a8f112
	if test -f ltmain.sh ; then
Packit a8f112
	    $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should"
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	$ECHO "Attempting to run the preparation steps individually"
Packit a8f112
	reconfigure_manually=yes
Packit a8f112
    else
Packit a8f112
	if [ "x$DOWNLOAD" = "xyes" ] ; then
Packit a8f112
	    if libtoolize_needed ; then
Packit a8f112
		download_gnulib_config_guess
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
    fi
Packit a8f112
else
Packit a8f112
    reconfigure_manually=yes
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
############################
Packit a8f112
# LIBTOOL_FAILURE FUNCTION #
Packit a8f112
############################
Packit a8f112
libtool_failure ( ) {
Packit a8f112
Packit a8f112
    # libtool is rather error-prone in comparison to the other
Packit a8f112
    # autotools and this routine attempts to compensate for some
Packit a8f112
    # common failures.  the output after a libtoolize failure is
Packit a8f112
    # parsed for an error related to AC_PROG_LIBTOOL and if found, we
Packit a8f112
    # attempt to inject a project-provided libtool.m4 file.
Packit a8f112
Packit a8f112
    _autoconf_output="$1"
Packit a8f112
Packit a8f112
    if [ "x$RUN_RECURSIVE" = "xno" ] ; then
Packit a8f112
	# we already tried the libtool.m4, don't try again
Packit a8f112
	return 1
Packit a8f112
    fi
Packit a8f112
Packit a8f112
    if test -f "$LIBTOOL_M4" ; then
Packit a8f112
	found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`"
Packit a8f112
	if test ! "x$found_libtool" = "x" ; then
Packit a8f112
	    if test -f acinclude.m4 ; then
Packit a8f112
		rm -f acinclude.m4.$$.backup
Packit a8f112
		$VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup"
Packit a8f112
		cat acinclude.m4 > acinclude.m4.$$.backup
Packit a8f112
	    fi
Packit a8f112
	    $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4"
Packit a8f112
	    chmod u+w acinclude.m4
Packit a8f112
	    cat "$LIBTOOL_M4" >> acinclude.m4
Packit a8f112
Packit a8f112
	    # don't keep doing this
Packit a8f112
	    RUN_RECURSIVE=no
Packit a8f112
	    export RUN_RECURSIVE
Packit a8f112
	    untrap_abnormal
Packit a8f112
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4"
Packit a8f112
	    $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
Packit a8f112
	    sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
Packit a8f112
	    exit $?
Packit a8f112
	fi
Packit a8f112
    fi
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
###########################
Packit a8f112
# MANUAL_AUTOGEN FUNCTION #
Packit a8f112
###########################
Packit a8f112
manual_autogen ( ) {
Packit a8f112
Packit a8f112
    ##################################################
Packit a8f112
    # Manual preparation steps taken are as follows: #
Packit a8f112
    #   aclocal [-I m4]                              #
Packit a8f112
    #   libtoolize --automake -c -f                  #
Packit a8f112
    #   aclocal [-I m4]                              #
Packit a8f112
    #   autoconf -f                                  #
Packit a8f112
    #   autoheader                                   #
Packit a8f112
    #   automake -a -c -f                            #
Packit a8f112
    ##################################################
Packit a8f112
Packit a8f112
    ###########
Packit a8f112
    # aclocal #
Packit a8f112
    ###########
Packit a8f112
    $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
Packit a8f112
    aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
Packit a8f112
    ret=$?
Packit a8f112
    $VERBOSE_ECHO "$aclocal_output"
Packit a8f112
    if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi
Packit a8f112
Packit a8f112
    ##############
Packit a8f112
    # libtoolize #
Packit a8f112
    ##############
Packit a8f112
    if libtoolize_needed ; then
Packit a8f112
	if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then
Packit a8f112
	    $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS"
Packit a8f112
	    libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`"
Packit a8f112
	    ret=$?
Packit a8f112
	    $VERBOSE_ECHO "$libtoolize_output"
Packit a8f112
Packit a8f112
	    if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
Packit a8f112
	else
Packit a8f112
	    if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
Packit a8f112
		$VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS"
Packit a8f112
		libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`"
Packit a8f112
		ret=$?
Packit a8f112
		$VERBOSE_ECHO "$libtoolize_output"
Packit a8f112
Packit a8f112
		if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	###########
Packit a8f112
	# aclocal #
Packit a8f112
	###########
Packit a8f112
	# re-run again as instructed by libtoolize
Packit a8f112
	$VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
Packit a8f112
	aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
Packit a8f112
	ret=$?
Packit a8f112
	$VERBOSE_ECHO "$aclocal_output"
Packit a8f112
Packit a8f112
	# libtoolize might put ltmain.sh in the wrong place
Packit a8f112
	if test -f ltmain.sh ; then
Packit a8f112
	    if test ! -f "${_aux_dir}/ltmain.sh" ; then
Packit a8f112
		$ECHO
Packit a8f112
		$ECHO "Warning:  $LIBTOOLIZE is creating ltmain.sh in the wrong directory"
Packit a8f112
		$ECHO
Packit a8f112
		$ECHO "Fortunately, the problem can be worked around by simply copying the"
Packit a8f112
		$ECHO "file to the appropriate location (${_aux_dir}/).  This has been done for you."
Packit a8f112
		$ECHO
Packit a8f112
		$VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\""
Packit a8f112
		cp -p ltmain.sh "${_aux_dir}/ltmain.sh"
Packit a8f112
		$ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
Packit a8f112
	    fi
Packit a8f112
	fi # ltmain.sh
Packit a8f112
Packit a8f112
	if [ "x$DOWNLOAD" = "xyes" ] ; then
Packit a8f112
	    download_gnulib_config_guess
Packit a8f112
	fi
Packit a8f112
    fi # libtoolize_needed
Packit a8f112
Packit a8f112
    ############
Packit a8f112
    # autoconf #
Packit a8f112
    ############
Packit a8f112
    $VERBOSE_ECHO
Packit a8f112
    $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS"
Packit a8f112
    autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`"
Packit a8f112
    ret=$?
Packit a8f112
    $VERBOSE_ECHO "$autoconf_output"
Packit a8f112
Packit a8f112
    if [ ! $ret = 0 ] ; then
Packit a8f112
	# retry without the -f and check for usage of macros that are too new
Packit a8f112
	ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE"
Packit a8f112
	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"
Packit a8f112
	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"
Packit a8f112
Packit a8f112
	macros_to_search=""
Packit a8f112
	ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`"
Packit a8f112
	ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`"
Packit a8f112
Packit a8f112
	if [ $ac_major -lt 2 ] ; then
Packit a8f112
	    macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
Packit a8f112
	else
Packit a8f112
	    if [ $ac_minor -lt 54 ] ; then
Packit a8f112
		macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
Packit a8f112
	    elif [ $ac_minor -lt 55 ] ; then
Packit a8f112
		macros_to_search="$ac2_59_macros $ac2_55_macros"
Packit a8f112
	    elif [ $ac_minor -lt 59 ] ; then
Packit a8f112
		macros_to_search="$ac2_59_macros"
Packit a8f112
	    fi
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	configure_ac_macros=__none__
Packit a8f112
	for feature in $macros_to_search ; do
Packit a8f112
	    $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
Packit a8f112
	    found="`grep \"^$feature.*\" $CONFIGURE`"
Packit a8f112
	    if [ ! "x$found" = "x" ] ; then
Packit a8f112
		if [ "x$configure_ac_macros" = "x__none__" ] ; then
Packit a8f112
		    configure_ac_macros="$feature"
Packit a8f112
		else
Packit a8f112
		    configure_ac_macros="$feature $configure_ac_macros"
Packit a8f112
		fi
Packit a8f112
	    fi
Packit a8f112
	done
Packit a8f112
	if [ ! "x$configure_ac_macros" = "x__none__" ] ; then
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "Warning:  Unsupported macros were found in $CONFIGURE"
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "The `basename \"$CONFIGURE\"` file was scanned in order to determine if any"
Packit a8f112
	    $ECHO "unsupported macros are used that exceed the minimum version"
Packit a8f112
	    $ECHO "settings specified within this file.  As such, the following macros"
Packit a8f112
	    $ECHO "should be removed from configure.ac or the version numbers in this"
Packit a8f112
	    $ECHO "file should be increased:"
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "$configure_ac_macros"
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C"
Packit a8f112
	fi
Packit a8f112
Packit a8f112
	###################
Packit a8f112
	# autoconf, retry #
Packit a8f112
	###################
Packit a8f112
	$VERBOSE_ECHO
Packit a8f112
	$VERBOSE_ECHO "$AUTOCONF"
Packit a8f112
	autoconf_output="`$AUTOCONF 2>&1`"
Packit a8f112
	ret=$?
Packit a8f112
	$VERBOSE_ECHO "$autoconf_output"
Packit a8f112
Packit a8f112
	if [ ! $ret = 0 ] ; then
Packit a8f112
	    # test if libtool is busted
Packit a8f112
	    libtool_failure "$autoconf_output"
Packit a8f112
Packit a8f112
	    # let the user know what went wrong
Packit a8f112
	    cat <
Packit a8f112
$autoconf_output
Packit a8f112
EOF
Packit a8f112
	    $ECHO "ERROR: $AUTOCONF failed"
Packit a8f112
	    exit 2
Packit a8f112
	else
Packit a8f112
	    # autoconf sans -f and possibly sans unsupported options succeed so warn verbosely
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "Warning: autoconf seems to have succeeded by removing the following options:"
Packit a8f112
	    $ECHO "	AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\""
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO "Removing those options should not be necessary and indicate some other"
Packit a8f112
	    $ECHO "problem with the build system.  The build preparation is highly suspect"
Packit a8f112
	    $ECHO "and may result in configuration or compilation errors.  Consider"
Packit a8f112
	    if [ "x$VERBOSE_ECHO" = "x:" ] ; then
Packit a8f112
		$ECHO "rerunning the build preparation with verbose output enabled."
Packit a8f112
		$ECHO "	$AUTOGEN_SH --verbose"
Packit a8f112
	    else
Packit a8f112
		$ECHO "reviewing the minimum GNU Autotools version settings contained in"
Packit a8f112
		$ECHO "this script along with the macros being used in your `basename \"$CONFIGURE\"` file."
Packit a8f112
	    fi
Packit a8f112
	    $ECHO
Packit a8f112
	    $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
Packit a8f112
	fi # autoconf ret = 0
Packit a8f112
    fi # autoconf ret = 0
Packit a8f112
Packit a8f112
    ##############
Packit a8f112
    # autoheader #
Packit a8f112
    ##############
Packit a8f112
    need_autoheader=no
Packit a8f112
    for feature in AM_CONFIG_HEADER AC_CONFIG_HEADER ; do
Packit a8f112
	$VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
Packit a8f112
	found="`grep \"^$feature.*\" $CONFIGURE`"
Packit a8f112
	if [ ! "x$found" = "x" ] ; then
Packit a8f112
	    need_autoheader=yes
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
    if [ "x$need_autoheader" = "xyes" ] ; then
Packit a8f112
	$VERBOSE_ECHO "$AUTOHEADER $AUTOHEADER_OPTIONS"
Packit a8f112
	autoheader_output="`$AUTOHEADER $AUTOHEADER_OPTIONS 2>&1`"
Packit a8f112
	ret=$?
Packit a8f112
	$VERBOSE_ECHO "$autoheader_output"
Packit a8f112
	if [ ! $ret = 0 ] ; then $ECHO "ERROR: $AUTOHEADER failed" && exit 2 ; fi
Packit a8f112
    fi # need_autoheader
Packit a8f112
Packit a8f112
    ############
Packit a8f112
    # automake #
Packit a8f112
    ############
Packit a8f112
    need_automake=no
Packit a8f112
    for feature in AM_INIT_AUTOMAKE ; do
Packit a8f112
	$VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
Packit a8f112
	found="`grep \"^$feature.*\" $CONFIGURE`"
Packit a8f112
	if [ ! "x$found" = "x" ] ; then
Packit a8f112
	    need_automake=yes
Packit a8f112
	    break
Packit a8f112
	fi
Packit a8f112
    done
Packit a8f112
Packit a8f112
    if [ "x$need_automake" = "xyes" ] ; then
Packit a8f112
	$VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS"
Packit a8f112
	automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`"
Packit a8f112
	ret=$?
Packit a8f112
	$VERBOSE_ECHO "$automake_output"
Packit a8f112
Packit a8f112
	if [ ! $ret = 0 ] ; then
Packit a8f112
Packit a8f112
	    ###################
Packit a8f112
	    # automake, retry #
Packit a8f112
	    ###################
Packit a8f112
	    $VERBOSE_ECHO
Packit a8f112
	    $VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS"
Packit a8f112
	    # retry without the -f
Packit a8f112
	    automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`"
Packit a8f112
	    ret=$?
Packit a8f112
	    $VERBOSE_ECHO "$automake_output"
Packit a8f112
Packit a8f112
	    if [ ! $ret = 0 ] ; then
Packit a8f112
	 	# test if libtool is busted
Packit a8f112
		libtool_failure "$automake_output"
Packit a8f112
Packit a8f112
		# let the user know what went wrong
Packit a8f112
		cat <
Packit a8f112
$automake_output
Packit a8f112
EOF
Packit a8f112
		$ECHO "ERROR: $AUTOMAKE failed"
Packit a8f112
		exit 2
Packit a8f112
	    fi # automake retry
Packit a8f112
	fi # automake ret = 0
Packit a8f112
    fi # need_automake
Packit a8f112
} # end of manual_autogen
Packit a8f112
Packit a8f112
Packit a8f112
#####################################
Packit a8f112
# RECURSIVE_MANUAL_AUTOGEN FUNCTION #
Packit a8f112
#####################################
Packit a8f112
recursive_manual_autogen ( ) {
Packit a8f112
Packit a8f112
    # run the build preparation steps manually for this directory
Packit a8f112
    manual_autogen
Packit a8f112
Packit a8f112
    # for projects using recursive configure, run the build
Packit a8f112
    # preparation steps for the subdirectories.
Packit a8f112
    if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then
Packit a8f112
	$VERBOSE_ECHO "Recursively configuring the following directories:"
Packit a8f112
	$VERBOSE_ECHO "  $CONFIG_SUBDIRS"
Packit a8f112
	for dir in $CONFIG_SUBDIRS ; do
Packit a8f112
	    $VERBOSE_ECHO "Processing recursive configure in $dir"
Packit a8f112
	    cd "$START_PATH"
Packit a8f112
	    cd "$dir"
Packit a8f112
Packit a8f112
	    # new directory, prepare
Packit a8f112
	    initialize
Packit a8f112
Packit a8f112
	    # run manual steps for the subdir and any others below
Packit a8f112
	    recursive_manual_autogen
Packit a8f112
	done
Packit a8f112
    fi
Packit a8f112
}
Packit a8f112
Packit a8f112
Packit a8f112
################################
Packit a8f112
# run manual preparation steps #
Packit a8f112
################################
Packit a8f112
if [ "x$reconfigure_manually" = "xyes" ] ; then
Packit a8f112
    $ECHO
Packit a8f112
    $ECHO $ECHO_N "Preparing build ... $ECHO_C"
Packit a8f112
Packit a8f112
    recursive_manual_autogen
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
#########################
Packit a8f112
# restore and summarize #
Packit a8f112
#########################
Packit a8f112
cd "$START_PATH"
Packit a8f112
Packit a8f112
# restore COPYING and INSTALL from backup if necessary
Packit a8f112
recursive_restore
Packit a8f112
Packit a8f112
# make sure we end up with a configure script
Packit a8f112
config_ac="`locate_configure_template`"
Packit a8f112
config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`"
Packit a8f112
if [ "x$config" = "x" ] ; then
Packit a8f112
    $VERBOSE_ECHO "Could not locate the configure template (from `pwd`)"
Packit a8f112
fi
Packit a8f112
Packit a8f112
# summarize
Packit a8f112
$ECHO "done"
Packit a8f112
$ECHO
Packit a8f112
if test "x$config" = "x" -o ! -f "$config" ; then
Packit a8f112
    $ECHO "WARNING: The $PROJECT build system should now be prepared but there"
Packit a8f112
    $ECHO "does not seem to be a resulting configure file.  This is unexpected"
Packit a8f112
    $ECHO "and likely the result of an error.  You should run $NAME_OF_AUTOGEN"
Packit a8f112
    $ECHO "with the --verbose option to get more details on a potential"
Packit a8f112
    $ECHO "misconfiguration."
Packit a8f112
else
Packit a8f112
    $ECHO "The $PROJECT build system is now prepared.  To build here, run:"
Packit a8f112
    $ECHO "  $config"
Packit a8f112
    $ECHO "  make"
Packit a8f112
fi
Packit a8f112
Packit a8f112
Packit a8f112
# Local Variables:
Packit a8f112
# mode: sh
Packit a8f112
# tab-width: 8
Packit a8f112
# sh-basic-offset: 4
Packit a8f112
# sh-indentation: 4
Packit a8f112
# indent-tabs-mode: t
Packit a8f112
# End:
Packit a8f112
# ex: shiftwidth=4 tabstop=8