Blame test/mpi/maint/updatefiles

Packit 0848f5
#! /bin/sh
Packit 0848f5
# 
Packit 0848f5
# (C) 2006 by Argonne National Laboratory.
Packit 0848f5
#     See COPYRIGHT in top-level directory.
Packit 0848f5
#
Packit 0848f5
# Update all of the derived files
Packit 0848f5
# For best performance, execute this in the top-level directory.
Packit 0848f5
# There are some experimental features to allow it to be executed in
Packit 0848f5
# subdirectories
Packit 0848f5
#
Packit 0848f5
# Eventually, we want to allow this script to be executed anywhere in the
Packit 0848f5
# mpich tree.  This is not yet implemented.
Packit 0848f5
error_summary=""
Packit 0848f5
acVersion=unknown
Packit 0848f5
Packit 0848f5
# finalStatus records whether there have been problems in updatefiles
Packit 0848f5
# 1 = warning, 3 = fatal, 2 = reserved for future use, 
Packit 0848f5
# 0 = no problems detected.
Packit 0848f5
finalStatus=0
Packit 0848f5
at_top=no
Packit 0848f5
if [ -d maint -a -s maint/f77tof90.in ] ; then
Packit 0848f5
    at_top=yes
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# Default choices
Packit 0848f5
do_f77tof90=yes
Packit 0848f5
do_build_configure=yes
Packit 0848f5
do_makefiles=yes
Packit 0848f5
Packit 0848f5
# Allow MAKE to be set from the environment
Packit 0848f5
MAKE=${MAKE-make}
Packit 0848f5
Packit 0848f5
# List of steps that we will consider
Packit 0848f5
# (We do not include depend because the values for depend are not just yes/no)
Packit 0848f5
AllSteps="f77tof90 build_configure makefiles"
Packit 0848f5
stepsCleared=no
Packit 0848f5
Packit 0848f5
# Options for some steps
Packit 0848f5
autoconfdir=""
Packit 0848f5
# Extract the arguments intended for updatefiles.
Packit 0848f5
temp_args=""
Packit 0848f5
for arg in "$@" ; do
Packit 0848f5
    case $arg in 
Packit 0848f5
    -echo)
Packit 0848f5
	set -x
Packit 0848f5
	;;
Packit 0848f5
Packit 0848f5
    -do=*)
Packit 0848f5
    opt=`echo A$arg | sed -e 's/A-do=//'`
Packit 0848f5
    # Handle some synonyms
Packit 0848f5
    case $opt in 
Packit 0848f5
	build-configure|configure) opt=build_configure ;;
Packit 0848f5
	makefile|Makefile|Makefiles) opt=makefiles;;
Packit 0848f5
    esac
Packit 0848f5
    var=do_$opt
Packit 0848f5
    # Check that this opt is known
Packit 0848f5
    eval oldval=\$"$var"
Packit 0848f5
    if [ -z "$oldval" ] ; then
Packit 0848f5
	echo "-do=$opt is unrecognized"
Packit 0848f5
	exit 1
Packit 0848f5
    else 
Packit 0848f5
        if [ $stepsCleared = no ] ; then
Packit 0848f5
	    for step in $AllSteps ; do
Packit 0848f5
	        var=do_$step
Packit 0848f5
	        eval $var=no
Packit 0848f5
	    done
Packit 0848f5
	    stepsCleared=yes
Packit 0848f5
        fi
Packit 0848f5
        var=do_$opt
Packit 0848f5
        eval $var=yes
Packit 0848f5
    fi
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -with-autoconf=*|--with-autoconf=*)
Packit 0848f5
    # Select a location for a different autoconf
Packit 0848f5
    autoconfdir=`echo "A$arg" | sed -e 's/.*=//'`
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -distrib)
Packit 0848f5
    do_build_configure=no
Packit 0848f5
    temp_args="$temp_args $arg"
Packit 0848f5
    ;;
Packit 0848f5
Packit 0848f5
    -help|--help|-usage|--usage)
Packit 0848f5
    cat <
Packit 0848f5
    updatefiles [ --with-autoconf=dir ] [ -do=stepname ]
Packit 0848f5
Packit 0848f5
    Update the files in the MPICH build tree.  This file builds the 
Packit 0848f5
    configure files, creates the Makefile.in files (using the autotools),
Packit 0848f5
    and extracts the error messages.
Packit 0848f5
Packit 0848f5
    You can use --with-autoconf=dir to specify a directory that contains
Packit 0848f5
    an alternate autoconf (and especially autoreconf).
Packit 0848f5
Packit 0848f5
    Use -do=stepname to update only a single step.  For example, 
Packit 0848f5
    -do=build_configure only updates the configure scripts.  The available
Packit 0848f5
    steps are
Packit 0848f5
    $AllSteps
Packit 0848f5
EOF
Packit 0848f5
    exit
Packit 0848f5
    ;;
Packit 0848f5
    *)
Packit 0848f5
    temp_args="$temp_args $arg"
Packit 0848f5
    ;;
Packit 0848f5
    esac
Packit 0848f5
done
Packit 0848f5
# Reset the arguments.  Note that this doesn't handle arguments that contain
Packit 0848f5
# blanks.  I hope that we don't need those.
Packit 0848f5
set -- $temp_args
Packit 0848f5
#
Packit 0848f5
#
Packit 0848f5
if [ $at_top = "no" ] ; then
Packit 0848f5
    echo "Must execute at top level directory for now"
Packit 0848f5
    exit 1
Packit 0848f5
fi
Packit 0848f5
# Determine the autoconf to use.  If --with-autoconf was set, use 
Packit 0848f5
# autoconf and autoheader from that directory
Packit 0848f5
# This may also be needed for tools in the maint directory
Packit 0848f5
if [ -n "$autoconfdir" ] ; then
Packit 0848f5
    if [ -x $autoconfdir/autoreconf ] ; then
Packit 0848f5
        autoreconf=$autoconfdir/autoreconf
Packit 0848f5
        AUTORECONF=$autoreconf
Packit 0848f5
        export AUTORECONF
Packit 0848f5
    else
Packit 0848f5
        echo "Could not find executable autoreconf in $autoconfdir"
Packit 0848f5
	exit 1
Packit 0848f5
    fi
Packit 0848f5
else
Packit 0848f5
    autoreconf=${AUTORECONF:-autoreconf}
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# Check that you have a working autoconf.  Autoconf 2.57 is not compatible with
Packit 0848f5
# previous versions of autoconf (!!), even 2.52 (!!!).  
Packit 0848f5
acVersion=ok
Packit 0848f5
if [ -d .tmp ] ; then rm -rf .tmp ; fi
Packit 0848f5
if [ -s .tmp ] ; then rm -f .tmp ; fi
Packit 0848f5
if [ ! -d .tmp ] ; then
Packit 0848f5
    mkdir .tmp 2>&1 >/dev/null
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
# we require autoconf version 2.67 or greater
Packit 0848f5
# acSubversion is the version number minus 2.  (we assume autoconf 2.xx)
Packit 0848f5
# -1 is used for unknown
Packit 0848f5
acSubversion=-1
Packit 0848f5
acIncDirFlag=-I
Packit 0848f5
for ver in 70 69 68 67 ; do
Packit 0848f5
    rm -f .tmp/configure.ac .tmp/configure
Packit 0848f5
    cat >.tmp/configure.ac <
Packit 0848f5
AC_PREREQ(2.$ver)
Packit 0848f5
EOF
Packit 0848f5
    if (cd .tmp && $autoconf >/dev/null 2>&1 ) ; then
Packit 0848f5
	acSubversion=$ver
Packit 0848f5
	break
Packit 0848f5
    fi
Packit 0848f5
done
Packit 0848f5
rm -f .tmp/configure.ac .tmp/configure
Packit 0848f5
if [ "$acSubversion" -gt 0 ] ; then
Packit 0848f5
    acVersion="2.$acSubversion"
Packit 0848f5
    echo "You have autoconf version $acVersion."
Packit 0848f5
else
Packit 0848f5
    cat <
Packit 0848f5
You either do not have autoconf in your path or updatefiles was unable to 
Packit 0848f5
determine which version of autoconf you have.  You may be able to use
Packit 0848f5
     autoconf --version
Packit 0848f5
to see the version of autoconf (unfortunately, there is no standard 
Packit 0848f5
format for the version output and it changes between autoconf versions.
Packit 0848f5
In addition, some versions of autoconf choose among many versions and
Packit 0848f5
provide incorrect output).
Packit 0848f5
EOF
Packit 0848f5
	error_summary="$error_summary \
Packit 0848f5
No autoconf in path or unable to determine the version of autoconf."
Packit 0848f5
        acVersion="Unknown"
Packit 0848f5
fi
Packit 0848f5
rm -rf .tmp
Packit 0848f5
Packit 0848f5
#
Packit 0848f5
# Build scripts such as f77tof90 if necessary
Packit 0848f5
run_configure=no
Packit 0848f5
Packit 0848f5
# Later versions of autoconf put the autoconf version into the autom4te*.cache
Packit 0848f5
# name.
Packit 0848f5
# Later versions of autoconf (2.57+?) will silently ignore the command to 
Packit 0848f5
# rebuild the configure if it thinks that nothing has changed.  However,
Packit 0848f5
# it does not accurately decide this (e.g., if aclocal.m4 includes files 
Packit 0848f5
# that have changed, autoconf will ignore that and not regenerate the 
Packit 0848f5
# configure file).  The information that autoconf uses is saved in the
Packit 0848f5
# autom4te*.cache file; since this cache is not accurate, we delete it.
Packit 0848f5
if [ ! -x maint/configure ] ; then
Packit 0848f5
    (cd maint && $autoconf && rm -rf autom4te*.cache )
Packit 0848f5
elif find maint -name 'configure.ac' -newer 'maint/configure' >/dev/null 2>&1 ; then
Packit 0848f5
    # The above relies on the Unix find command
Packit 0848f5
    (cd maint && $autoconf && rm -rf autom4te*.cache)
Packit 0848f5
fi
Packit 0848f5
if [ ! -x maint/f77tof90 ] ; then
Packit 0848f5
    run_configure=yes
Packit 0848f5
fi
Packit 0848f5
#
Packit 0848f5
# The following relies on the Unix find command
Packit 0848f5
if [ -s maint/f77tof90 ] ; then
Packit 0848f5
    if find maint -name 'f77tof90.in' -newer 'maint/f77tof90' >/dev/null 2>&1 ; then
Packit 0848f5
        run_configure=yes
Packit 0848f5
    fi
Packit 0848f5
else
Packit 0848f5
    run_configure=yes
Packit 0848f5
fi
Packit 0848f5
if [ "$run_configure" = "yes" ] ; then
Packit 0848f5
    (cd maint && ./configure)
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
Packit 0848f5
# Create and/or update the f90 tests
Packit 0848f5
if [ -x maint/f77tof90 -a $do_f77tof90 = "yes" ] ; then
Packit 0848f5
    echo "Create or update the Fortran 90 tests derived from the Fortran 77 tests"
Packit 0848f5
    for dir in f77/* ; do
Packit 0848f5
        if [ ! -d $dir ] ; then continue ; fi
Packit 0848f5
	leafDir=`basename $dir`
Packit 0848f5
        if [ ! -d f90/$leafDir ] ; then
Packit 0848f5
	    mkdir f90/$leafDir
Packit 0848f5
        fi
Packit 0848f5
        maint/f77tof90 $dir f90/$leafDir Makefile.sm Makefile.ap
Packit 0848f5
    done
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
#
Packit 0848f5
# Create the Makefile.in files
Packit 0848f5
# Make sure that these files exist so that the gcc dependency creation
Packit 0848f5
# can work
Packit 0848f5
rm_prepost=no
Packit 0848f5
if [ ! -s src/include/mpidpre.h ] ; then
Packit 0848f5
    rm_prepost=yes
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
# Create the configure files and run autoheader
Packit 0848f5
# Eventually, make this a test for find available.  Perhaps
Packit 0848f5
# find . -name configure.ac > /dev/null 2>&1
Packit 0848f5
# The problem is that even though cygwin has find, the DOS find
Packit 0848f5
# is identified first.  We probably need a test for this case
Packit 0848f5
fixBackWhackCtrlMBug=no
Packit 0848f5
if [ $do_build_configure = yes ] ; then
Packit 0848f5
    # If we don't delete the autom4te.cache files, bugs in 
Packit 0848f5
    # autoconf may fail to correctly update configure
Packit 0848f5
    # Gah. Some xargs don't accept -r, other break if there is no
Packit 0848f5
    # input.  To avoid that, we do this in two steps: first the
Packit 0848f5
    # find, then the rm (if there are any files)
Packit 0848f5
    $autoreconf -vif $acIncDirFlag confdb
Packit 0848f5
    if [ ! -x configure ] ; then 
Packit 0848f5
        # Check for a few allowed exceptions
Packit 0848f5
        echo "Could not build configure from configure.ac in $dir"
Packit 0848f5
	echo "Aborting updatefiles!"
Packit 0848f5
	exit 1
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
Packit 0848f5
#
Packit 0848f5
# The following must be the last statements executed
Packit 0848f5
if [ -n "$error_summary" ] ; then
Packit 0848f5
    echo " "
Packit 0848f5
    echo "Problems encountered while running updatefiles."
Packit 0848f5
    echo "These may cause problems when configuring or building MPICH."
Packit 0848f5
    echo "$error_summary"
Packit 0848f5
fi
Packit 0848f5
case $finalStatus in 
Packit 0848f5
   0) # all is well
Packit 0848f5
	;;
Packit 0848f5
   1) # warnings
Packit 0848f5
 	;;
Packit 0848f5
   2) # reserved for future use
Packit 0848f5
	;;
Packit 0848f5
   3) # fatal, cannot continue
Packit 0848f5
	echo "updatefiles step failed!  Review the output and fix the problem"
Packit 0848f5
        echo "before continuing"
Packit 0848f5
        exit 1
Packit 0848f5
	;;	
Packit 0848f5
   *) # unknown
Packit 0848f5
	echo "Internal error in updatefiles; finalStatus=$finalStatus"
Packit 0848f5
	exit 1
Packit 0848f5
	;;
Packit 0848f5
esac
Packit 0848f5