Blame test/mpi/maint/updatefiles

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