-
-############################################
-# prepare build via autoreconf or manually #
-############################################
-reconfigure_manually=no
-if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then
- $ECHO
- $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C"
-
- $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS"
- autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$autoreconf_output"
-
- if [ ! $ret = 0 ] ; then
- if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
- if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then
- $ECHO
- $ECHO "Warning: autoreconf failed but due to what is usually a common libtool"
- $ECHO "misconfiguration issue. This problem is encountered on systems that"
- $ECHO "have installed libtoolize under a different name without providing a"
- $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable."
- $ECHO
- $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE"
-
- export LIBTOOLIZE
- RUN_RECURSIVE=no
- export RUN_RECURSIVE
- untrap_abnormal
-
- $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
- sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
- exit $?
- fi
- fi
-
- $ECHO "Warning: $AUTORECONF failed"
-
- if test -f ltmain.sh ; then
- $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should"
- fi
-
- $ECHO "Attempting to run the preparation steps individually"
- reconfigure_manually=yes
- else
- if [ "x$DOWNLOAD" = "xyes" ] ; then
- if libtoolize_needed ; then
- download_gnulib_config_guess
- fi
- fi
- fi
-else
- reconfigure_manually=yes
-fi
-
-
-############################
-# LIBTOOL_FAILURE FUNCTION #
-############################
-libtool_failure ( ) {
-
- # libtool is rather error-prone in comparison to the other
- # autotools and this routine attempts to compensate for some
- # common failures. the output after a libtoolize failure is
- # parsed for an error related to AC_PROG_LIBTOOL and if found, we
- # attempt to inject a project-provided libtool.m4 file.
-
- _autoconf_output="$1"
-
- if [ "x$RUN_RECURSIVE" = "xno" ] ; then
- # we already tried the libtool.m4, don't try again
- return 1
- fi
-
- if test -f "$LIBTOOL_M4" ; then
- found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`"
- if test ! "x$found_libtool" = "x" ; then
- if test -f acinclude.m4 ; then
- rm -f acinclude.m4.$$.backup
- $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup"
- cat acinclude.m4 > acinclude.m4.$$.backup
- fi
- $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4"
- chmod u+w acinclude.m4
- cat "$LIBTOOL_M4" >> acinclude.m4
-
- # don't keep doing this
- RUN_RECURSIVE=no
- export RUN_RECURSIVE
- untrap_abnormal
-
- $ECHO
- $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4"
- $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
- sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
- exit $?
- fi
- fi
-}
-
-
-###########################
-# MANUAL_AUTOGEN FUNCTION #
-###########################
-manual_autogen ( ) {
-
- ##################################################
- # Manual preparation steps taken are as follows: #
- # aclocal [-I m4] #
- # libtoolize --automake -c -f #
- # aclocal [-I m4] #
- # autoconf -f #
- # autoheader #
- # automake -a -c -f #
- ##################################################
-
- ###########
- # aclocal #
- ###########
- $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
- aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$aclocal_output"
- if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi
-
- ##############
- # libtoolize #
- ##############
- if libtoolize_needed ; then
- if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then
- $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS"
- libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$libtoolize_output"
-
- if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
- else
- if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
- $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS"
- libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$libtoolize_output"
-
- if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
- fi
- fi
-
- ###########
- # aclocal #
- ###########
- # re-run again as instructed by libtoolize
- $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
- aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$aclocal_output"
-
- # libtoolize might put ltmain.sh in the wrong place
- if test -f ltmain.sh ; then
- if test ! -f "${_aux_dir}/ltmain.sh" ; then
- $ECHO
- $ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory"
- $ECHO
- $ECHO "Fortunately, the problem can be worked around by simply copying the"
- $ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you."
- $ECHO
- $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\""
- cp -p ltmain.sh "${_aux_dir}/ltmain.sh"
- $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
- fi
- fi # ltmain.sh
-
- if [ "x$DOWNLOAD" = "xyes" ] ; then
- download_gnulib_config_guess
- fi
- fi # libtoolize_needed
-
- ############
- # autoconf #
- ############
- $VERBOSE_ECHO
- $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS"
- autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$autoconf_output"
-
- if [ ! $ret = 0 ] ; then
- # retry without the -f and check for usage of macros that are too new
- ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE"
- 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"
- 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"
-
- macros_to_search=""
- ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`"
- ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`"
-
- if [ $ac_major -lt 2 ] ; then
- macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
- else
- if [ $ac_minor -lt 54 ] ; then
- macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
- elif [ $ac_minor -lt 55 ] ; then
- macros_to_search="$ac2_59_macros $ac2_55_macros"
- elif [ $ac_minor -lt 59 ] ; then
- macros_to_search="$ac2_59_macros"
- fi
- fi
-
- configure_ac_macros=__none__
- for feature in $macros_to_search ; do
- $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
- found="`grep \"^$feature.*\" $CONFIGURE`"
- if [ ! "x$found" = "x" ] ; then
- if [ "x$configure_ac_macros" = "x__none__" ] ; then
- configure_ac_macros="$feature"
- else
- configure_ac_macros="$feature $configure_ac_macros"
- fi
- fi
- done
- if [ ! "x$configure_ac_macros" = "x__none__" ] ; then
- $ECHO
- $ECHO "Warning: Unsupported macros were found in $CONFIGURE"
- $ECHO
- $ECHO "The `basename \"$CONFIGURE\"` file was scanned in order to determine if any"
- $ECHO "unsupported macros are used that exceed the minimum version"
- $ECHO "settings specified within this file. As such, the following macros"
- $ECHO "should be removed from configure.ac or the version numbers in this"
- $ECHO "file should be increased:"
- $ECHO
- $ECHO "$configure_ac_macros"
- $ECHO
- $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C"
- fi
-
- ###################
- # autoconf, retry #
- ###################
- $VERBOSE_ECHO
- $VERBOSE_ECHO "$AUTOCONF"
- autoconf_output="`$AUTOCONF 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$autoconf_output"
-
- if [ ! $ret = 0 ] ; then
- # test if libtool is busted
- libtool_failure "$autoconf_output"
-
- # let the user know what went wrong
- cat <<EOF
-$autoconf_output
-EOF
- $ECHO "ERROR: $AUTOCONF failed"
- exit 2
- else
- # autoconf sans -f and possibly sans unsupported options succeed so warn verbosely
- $ECHO
- $ECHO "Warning: autoconf seems to have succeeded by removing the following options:"
- $ECHO " AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\""
- $ECHO
- $ECHO "Removing those options should not be necessary and indicate some other"
- $ECHO "problem with the build system. The build preparation is highly suspect"
- $ECHO "and may result in configuration or compilation errors. Consider"
- if [ "x$VERBOSE_ECHO" = "x:" ] ; then
- $ECHO "rerunning the build preparation with verbose output enabled."
- $ECHO " $AUTOGEN_SH --verbose"
- else
- $ECHO "reviewing the minimum GNU Autotools version settings contained in"
- $ECHO "this script along with the macros being used in your `basename \"$CONFIGURE\"` file."
- fi
- $ECHO
- $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
- fi # autoconf ret = 0
- fi # autoconf ret = 0
-
- ##############
- # autoheader #
- ##############
- need_autoheader=no
- for feature in AM_CONFIG_HEADER AC_CONFIG_HEADER ; do
- $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
- found="`grep \"^$feature.*\" $CONFIGURE`"
- if [ ! "x$found" = "x" ] ; then
- need_autoheader=yes
- break
- fi
- done
- if [ "x$need_autoheader" = "xyes" ] ; then
- $VERBOSE_ECHO "$AUTOHEADER $AUTOHEADER_OPTIONS"
- autoheader_output="`$AUTOHEADER $AUTOHEADER_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$autoheader_output"
- if [ ! $ret = 0 ] ; then $ECHO "ERROR: $AUTOHEADER failed" && exit 2 ; fi
- fi # need_autoheader
-
- ############
- # automake #
- ############
- need_automake=no
- for feature in AM_INIT_AUTOMAKE ; do
- $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
- found="`grep \"^$feature.*\" $CONFIGURE`"
- if [ ! "x$found" = "x" ] ; then
- need_automake=yes
- break
- fi
- done
-
- if [ "x$need_automake" = "xyes" ] ; then
- $VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS"
- automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$automake_output"
-
- if [ ! $ret = 0 ] ; then
-
- ###################
- # automake, retry #
- ###################
- $VERBOSE_ECHO
- $VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS"
- # retry without the -f
- automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`"
- ret=$?
- $VERBOSE_ECHO "$automake_output"
-
- if [ ! $ret = 0 ] ; then
- # test if libtool is busted
- libtool_failure "$automake_output"
-
- # let the user know what went wrong
- cat <<EOF
-$automake_output
-EOF
- $ECHO "ERROR: $AUTOMAKE failed"
- exit 2
- fi # automake retry
- fi # automake ret = 0
- fi # need_automake
-} # end of manual_autogen
-
-
-#####################################
-# RECURSIVE_MANUAL_AUTOGEN FUNCTION #
-#####################################
-recursive_manual_autogen ( ) {
-
- # run the build preparation steps manually for this directory
- manual_autogen
-
- # for projects using recursive configure, run the build
- # preparation steps for the subdirectories.
- if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then
- $VERBOSE_ECHO "Recursively configuring the following directories:"
- $VERBOSE_ECHO " $CONFIG_SUBDIRS"
- for dir in $CONFIG_SUBDIRS ; do
- $VERBOSE_ECHO "Processing recursive configure in $dir"
- cd "$START_PATH"
- cd "$dir"
-
- # new directory, prepare
- initialize
-
- # run manual steps for the subdir and any others below
- recursive_manual_autogen
- done
- fi
-}
-
-
-################################
-# run manual preparation steps #
-################################
-if [ "x$reconfigure_manually" = "xyes" ] ; then
- $ECHO
- $ECHO $ECHO_N "Preparing build ... $ECHO_C"
-
- recursive_manual_autogen
-fi
-
-
-#########################
-# restore and summarize #
-#########################
-cd "$START_PATH"
-
-# restore COPYING and INSTALL from backup if necessary
-recursive_restore
-
-# make sure we end up with a configure script
-config_ac="`locate_configure_template`"
-config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`"
-if [ "x$config" = "x" ] ; then
- $VERBOSE_ECHO "Could not locate the configure template (from `pwd`)"
-fi
-
-# summarize
-$ECHO "done"
-$ECHO
-if test "x$config" = "x" -o ! -f "$config" ; then
- $ECHO "WARNING: The $PROJECT build system should now be prepared but there"
- $ECHO "does not seem to be a resulting configure file. This is unexpected"
- $ECHO "and likely the result of an error. You should run $NAME_OF_AUTOGEN"
- $ECHO "with the --verbose option to get more details on a potential"
- $ECHO "misconfiguration."
-else
- $ECHO "The $PROJECT build system is now prepared. To build here, run:"
- $ECHO " $config"
- $ECHO " make"
-fi
-
-
-# Local Variables:
-# mode: sh
-# tab-width: 8
-# sh-basic-offset: 4
-# sh-indentation: 4
-# indent-tabs-mode: t
-# End:
-# ex: shiftwidth=4 tabstop=8