-
-#################################
-# PROTECT_FROM_CLOBBER FUNCTION #
-#################################
-protect_from_clobber ( ) {
- PFC_INIT=1
-
- # protect COPYING & INSTALL from overwrite by automake. the
- # automake force option will (inappropriately) ignore the existing
- # contents of a COPYING and/or INSTALL files (depending on the
- # version) instead of just forcing *missing* files like it does
- # for AUTHORS, NEWS, and README. this is broken but extremely
- # prevalent behavior, so we protect against it by keeping a backup
- # of the file that can later be restored.
-
- if test -f COPYING ; then
- if test -f COPYING.$$.protect_from_automake.backup ; then
- $VERBOSE_ECHO "Already backed up COPYING in `pwd`"
- else
- $VERBOSE_ECHO "Backing up COPYING in `pwd`"
- $VERBOSE_ECHO "cp -p COPYING COPYING.$$.protect_from_automake.backup"
- cp -p COPYING COPYING.$$.protect_from_automake.backup
- fi
- fi
- if test -f INSTALL ; then
- if test -f INSTALL.$$.protect_from_automake.backup ; then
- $VERBOSE_ECHO "Already backed up INSTALL in `pwd`"
- else
- $VERBOSE_ECHO "Backing up INSTALL in `pwd`"
- $VERBOSE_ECHO "cp -p INSTALL INSTALL.$$.protect_from_automake.backup"
- cp -p INSTALL INSTALL.$$.protect_from_automake.backup
- fi
- fi
-}
-
-
-##############################
-# RECURSIVE_PROTECT FUNCTION #
-##############################
-recursive_protect ( ) {
-
- # for projects using recursive configure, run the build
- # preparation steps for the subdirectories. this function assumes
- # START_PATH was set to pwd before recursion begins so that
- # relative paths work.
-
- # git 'r done, protect COPYING and INSTALL from being clobbered
- protect_from_clobber
-
- if test -d autom4te.cache ; then
- $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
- $VERBOSE_ECHO "rm -rf autom4te.cache"
- rm -rf autom4te.cache
- fi
-
- # find configure template
- _configure="`locate_configure_template`"
- if [ "x$_configure" = "x" ] ; then
- return
- fi
- # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure"
-
- # look for subdirs
- # $VERBOSE_ECHO "Looking for subdirs in `pwd`"
- _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
- CHECK_DIRS=""
- for dir in $_det_config_subdirs ; do
- if test -d "`pwd`/$dir" ; then
- CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
- fi
- done
-
- # process subdirs
- if [ ! "x$CHECK_DIRS" = "x" ] ; then
- $VERBOSE_ECHO "Recursively scanning the following directories:"
- $VERBOSE_ECHO " $CHECK_DIRS"
- for dir in $CHECK_DIRS ; do
- $VERBOSE_ECHO "Protecting files from automake in $dir"
- cd "$START_PATH"
- eval "cd $dir"
-
- # recursively git 'r done
- recursive_protect
- done
- fi
-} # end of recursive_protect
-
-
-#############################
-# RESTORE_CLOBBERED FUNCION #
-#############################
-restore_clobbered ( ) {
-
- # The automake (and autoreconf by extension) -f/--force-missing
- # option may overwrite COPYING and INSTALL even if they do exist.
- # Here we restore the files if necessary.
-
- spacer=no
-
- # COPYING
- if test -f COPYING.$$.protect_from_automake.backup ; then
- if test -f COPYING ; then
- # compare entire content, restore if needed
- if test "x`cat COPYING`" != "x`cat COPYING.$$.protect_from_automake.backup`" ; then
- if test "x$spacer" = "xno" ; then
- $VERBOSE_ECHO
- spacer=yes
- fi
- # restore the backup
- $VERBOSE_ECHO "Restoring COPYING from backup (automake -f likely clobbered it)"
- $VERBOSE_ECHO "rm -f COPYING"
- rm -f COPYING
- $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
- mv COPYING.$$.protect_from_automake.backup COPYING
- fi # check contents
- elif test -f COPYING.$$.protect_from_automake.backup ; then
- $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
- mv COPYING.$$.protect_from_automake.backup COPYING
- fi # -f COPYING
-
- # just in case
- $VERBOSE_ECHO "rm -f COPYING.$$.protect_from_automake.backup"
- rm -f COPYING.$$.protect_from_automake.backup
- fi # -f COPYING.$$.protect_from_automake.backup
-
- # INSTALL
- if test -f INSTALL.$$.protect_from_automake.backup ; then
- if test -f INSTALL ; then
- # compare entire content, restore if needed
- if test "x`cat INSTALL`" != "x`cat INSTALL.$$.protect_from_automake.backup`" ; then
- if test "x$spacer" = "xno" ; then
- $VERBOSE_ECHO
- spacer=yes
- fi
- # restore the backup
- $VERBOSE_ECHO "Restoring INSTALL from backup (automake -f likely clobbered it)"
- $VERBOSE_ECHO "rm -f INSTALL"
- rm -f INSTALL
- $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
- mv INSTALL.$$.protect_from_automake.backup INSTALL
- fi # check contents
- elif test -f INSTALL.$$.protect_from_automake.backup ; then
- $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
- mv INSTALL.$$.protect_from_automake.backup INSTALL
- fi # -f INSTALL
-
- # just in case
- $VERBOSE_ECHO "rm -f INSTALL.$$.protect_from_automake.backup"
- rm -f INSTALL.$$.protect_from_automake.backup
- fi # -f INSTALL.$$.protect_from_automake.backup
-
- CONFIGURE="`locate_configure_template`"
- if [ "x$CONFIGURE" = "x" ] ; then
- return
- fi
-
- _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/'`"
- if test ! -d "$_aux_dir" ; then
- _aux_dir=.
- fi
-
- for file in config.guess config.sub ltmain.sh ; do
- if test -f "${_aux_dir}/${file}" ; then
- $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\""
- rm -f "${_aux_dir}/${file}.backup"
- fi
- done
-} # end of restore_clobbered
-
-
-##############################
-# RECURSIVE_RESTORE FUNCTION #
-##############################
-recursive_restore ( ) {
-
- # restore COPYING and INSTALL from backup if they were clobbered
- # for each directory recursively.
-
- # git 'r undone
- restore_clobbered
-
- # find configure template
- _configure="`locate_configure_template`"
- if [ "x$_configure" = "x" ] ; then
- return
- fi
-
- # look for subdirs
- _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
- CHECK_DIRS=""
- for dir in $_det_config_subdirs ; do
- if test -d "`pwd`/$dir" ; then
- CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
- fi
- done
-
- # process subdirs
- if [ ! "x$CHECK_DIRS" = "x" ] ; then
- $VERBOSE_ECHO "Recursively scanning the following directories:"
- $VERBOSE_ECHO " $CHECK_DIRS"
- for dir in $CHECK_DIRS ; do
- $VERBOSE_ECHO "Checking files for automake damage in $dir"
- cd "$START_PATH"
- eval "cd $dir"
-
- # recursively git 'r undone
- recursive_restore
- done
- fi
-} # end of recursive_restore
-
-
-#######################
-# INITIALIZE FUNCTION #
-#######################
-initialize ( ) {
-
- # this routine performs a variety of directory-specific
- # initializations. some are sanity checks, some are preventive,
- # and some are necessary setup detection.
- #
- # this function sets:
- # CONFIGURE
- # SEARCH_DIRS
- # CONFIG_SUBDIRS
-
- ##################################
- # check for a configure template #
- ##################################
- CONFIGURE="`locate_configure_template`"
- if [ "x$CONFIGURE" = "x" ] ; then
- $ECHO
- $ECHO "A configure.ac or configure.in file could not be located implying"
- $ECHO "that the GNU Build System is at least not used in this directory. In"
- $ECHO "any case, there is nothing to do here without one of those files."
- $ECHO
- $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
- exit 1
- fi
-
- #####################
- # detect an aux dir #
- #####################
- _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/'`"
- if test ! -d "$_aux_dir" ; then
- _aux_dir=.