#! /bin/sh # # (C) 2006 by Argonne National Laboratory. # See COPYRIGHT in top-level directory. # # Update all of the derived files # For best performance, execute this in the top-level directory. # There are some experimental features to allow it to be executed in # subdirectories # # Eventually, we want to allow this script to be executed anywhere in the # mpich tree. This is not yet implemented. ######################################################################## ## Utility functions ######################################################################## recreate_tmp() { rm -rf .tmp mkdir .tmp 2>&1 >/dev/null } warn() { echo "===> WARNING: $@" } error() { echo "===> ERROR: $@" } echo_n() { # "echo -n" isn't portable, must portably implement with printf printf "%s" "$*" } # Assume Program's install-dir is /bin/. # Given program name as the 1st argument, # the install-dir is returned is returned in 2nd argument. # e.g., ProgHomeDir libtoolize libtooldir. ProgHomeDir() { prog=$1 progpath="`which $prog`" progbindir="`dirname $progpath`" proghome=`(cd $progbindir/.. && pwd)` eval $2=$proghome } ######################################################################## ## Run any local pre-update hooks ######################################################################## if test -d maint/hooks/pre ; then for hook in `ls maint/hooks/pre/* 2>/dev/null` ; do if test -x "$hook" ; then echo_n "executing pre-update hook '$hook'... " ./$hook echo done else warn "unable to execute pre-update hook: '$hook'" fi done fi echo echo "##################################" echo "## Checking user environment" echo "##################################" echo ######################################################################## ## Checks to make sure we are running from the correct location ######################################################################## echo_n "Verifying the location of autogen.sh... " if [ ! -d maint -o ! -s maint/version.m4 ] ; then echo "must execute at top level directory for now" exit 1 fi echo "done" ######################################################################## ## Version checks for svn in developer builds ######################################################################## # Sanity check that any relative path svn:externals are present. An # SVN version >=1.5 is needed to understand the relative path # externals format. Such externals are used in particular for mpl in # hydra and all non-root confdbs. # # Check for a particular file, not just the directory because several # autotools steps (such as libtoolize) will create the aux/macro dir. echo_n "Checking for svn checkout errors... " svn_externals_sanity_file="src/pm/hydra/version.m4" # Note that -e is not an available option for test in the Bourne shell, though # some systems that pretend that ksh is the same as sh will accept it. if test "!" -f $svn_externals_sanity_file ; then cat </dev/null 2>&1 ; then libtoolize=glibtoolize else libtoolize=${LIBTOOLIZE:-libtoolize} fi fi ProgHomeDir $autoconf autoconfdir ProgHomeDir $automake automakedir ProgHomeDir $libtoolize libtooldir echo_n "Checking if autotools are in the same location... " if [ "$autoconfdir" = "$automakedir" -a "$autoconfdir" = "$libtooldir" ] ; then same_atdir=yes echo "yes, all in $autoconfdir" else same_atdir=no echo "no" echo " autoconf is in $autoconfdir" echo " automake is in $automakedir" echo " libtool is in $libtooldir" # Emit a big warning message if $same_atdir = no. warn "Autotools are in different locations. In rare occasion," warn "resulting configure or makefile may fail in some unexpected ways." fi ######################################################################## ## Check if autoreconf can be patched to work ## when autotools are not in the same location. ## This test needs to be done before individual tests of autotools ######################################################################## # If autotools are not in the same location, override autoreconf appropriately. if [ "$same_atdir" != "yes" ] ; then if [ -z "$libtooldir" ] ; then ProgHomeDir $libtoolize libtooldir fi libtoolm4dir="$libtooldir/share/aclocal" echo_n "Checking if $autoreconf accepts -I $libtoolm4dir... " new_autoreconf_works=no if [ -d "$libtoolm4dir" -a -f "$libtoolm4dir/libtool.m4" ] ; then recreate_tmp cat >.tmp/configure.ac <<_EOF AC_INIT(foo,1.0) AC_PROG_LIBTOOL AC_OUTPUT _EOF AUTORECONF="$autoreconf -I $libtoolm4dir" if (cd .tmp && $AUTORECONF -ivf >/dev/null 2>&1) ; then new_autoreconf_works=yes fi rm -rf .tmp fi echo "$new_autoreconf_works" # If autoreconf accepts -I correctly, use -I. # If not, run libtoolize before autoreconf (i.e. for autoconf <= 2.63) # This test is more general than checking the autoconf version. if [ "$new_autoreconf_works" != "yes" ] ; then echo_n "Checking if $autoreconf works after an additional $libtoolize step... " new_autoreconf_works=no recreate_tmp # Need AC_CONFIG_ cat >.tmp/configure.ac <<_EOF AC_INIT(foo,1.0) AC_CONFIG_AUX_DIR([m4]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_LIBTOOL AC_OUTPUT _EOF cat >.tmp/Makefile.am <<_EOF ACLOCAL_AMFLAGS = -I m4 _EOF AUTORECONF="eval $libtoolize && $autoreconf" if (cd .tmp && $AUTORECONF -ivf >u.txt 2>&1) ; then new_autoreconf_works=yes fi rm -rf .tmp echo "$new_autoreconf_works" fi if [ "$new_autoreconf_works" = "yes" ] ; then export AUTORECONF autoreconf="$AUTORECONF" else # Since all autoreconf workarounds do not work, we need # to require all autotools to be in the same directory. do_atdir_check=yes error "Since none of the autoreconf workaround works" error "and autotools are not in the same directory, aborting..." error "Updating autotools or putting all autotools in the same location" error "may resolve the issue." exit 1 fi fi ######################################################################## ## Verify autoconf version ######################################################################## echo_n "Checking for autoconf version... " recreate_tmp ver=2.67 # petsc.mcs.anl.gov's /usr/bin/autoreconf is version 2.65 which returns OK # if configure.ac has AC_PREREQ() withOUT AC_INIT. # # ~/> hostname # petsc # ~> /usr/bin/autoconf --version # autoconf (GNU Autoconf) 2.65 # .... # ~/> cat configure.ac # AC_PREREQ(2.68) # ~/> /usr/bin/autoconf ; echo "rc=$?" # configure.ac:1: error: Autoconf version 2.68 or higher is required # configure.ac:1: the top level # autom4te: /usr/bin/m4 failed with exit status: 63 # rc=63 # ~/> /usr/bin/autoreconf ; echo "rc=$?" # rc=0 cat > .tmp/configure.ac</dev/null 2>&1 ) ; then echo ">= $ver" else echo "bad autoconf installation" cat < .tmp/configure.ac<.tmp/Makefile.am ACLOCAL_AMFLAGS = -I m4 EOF if [ ! -d .tmp/m4 ] ; then mkdir .tmp/m4 >/dev/null 2>&1 ; fi if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then echo ">= $ver" else echo "bad automake installation" cat <.tmp/configure.ac AC_INIT(testver,1.0) AC_CONFIG_AUX_DIR([m4]) AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([LT_PREREQ],,[m4_fatal([LT_PREREQ not defined])]) LT_PREREQ($ver) LT_INIT() AC_MSG_RESULT([A message]) EOF cat <.tmp/Makefile.am ACLOCAL_AMFLAGS = -I m4 EOF if [ ! -d .tmp/m4 ] ; then mkdir .tmp/m4 >/dev/null 2>&1 ; fi if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then echo ">= $ver" else echo "bad libtool installation" cat < /dev/null 2>&1 if [ $? = 0 ] ; then echo "done" else echo "not found (error)" exit 1 fi ######################################################################## ## Checking if xargs rm -rf works ######################################################################## echo_n "Checking if xargs rm -rf works... " if [ -d "`find . -name __random_dir__`" ] ; then error "found a directory named __random_dir__" exit 1 else mkdir __random_dir__ find . -name __random_dir__ | xargs rm -rf > /dev/null 2>&1 if [ $? = 0 ] ; then echo "yes" else echo "no (error)" rm -rf __random_dir__ exit 1 fi fi echo echo echo "###########################################################" echo "## Autogenerating required files" echo "###########################################################" echo ######################################################################## ## Building maint/Version ######################################################################## # build a substitute maint/Version script now that we store the single copy of # this information in an m4 file for autoconf's benefit echo_n "Generating a helper maint/Version... " if $autom4te -l M4sugar maint/Version.base.m4 > maint/Version ; then echo "done" else echo "error" error "unable to correctly generate maint/Version shell helper" fi ######################################################################## ## Building the README ######################################################################## echo_n "Updating the README... " . ./maint/Version if [ -f README.vin ] ; then sed -e "s/%VERSION%/${MPICH_VERSION}/g" README.vin > README echo "done" else echo "error" error "README.vin file not present, unable to update README version number (perhaps we are running in a release tarball source tree?)" fi ######################################################################## ## Update SMPD version ######################################################################## if [ "$do_smpdversion" = yes ] ; then echo_n "Creating src/pm/smpd/smpd_version.h... " smpdVersion=${MPICH2_VERSION} cat >src/pm/smpd/smpd_version.h </dev/null 2>&1 ; then build_f77=yes fi if [ ! -s src/binding/f90/mpi_base.f90 ] ; then build_f90=yes elif find src/binding/f90 -name 'buildiface' -newer 'src/binding/f90/mpi_base.f90' >/dev/null 2>&1 ; then build_f90=yes fi fi if [ $build_f77 = "yes" ] ; then echo_n "Building Fortran 77 interface... " ( cd src/binding/f77 && chmod a+x ./buildiface && ./buildiface ) echo "done" fi if [ $build_f90 = "yes" ] ; then echo_n "Building Fortran 90 interface... " # Remove any copy of mpi_base.f90 (this is used to handle the # Double precision vs. Real*8 option rm -f src/binding/f90/mpi_base.f90.orig ( cd src/binding/f90 && chmod a+x ./buildiface && ./buildiface ) ( cd src/binding/f90 && ../f77/buildiface -infile=cf90t.h -deffile=cf90tdefs) echo "done" fi if [ ! -s src/binding/cxx/mpicxx.h ] ; then build_cxx=yes elif find src/binding/cxx -name 'buildiface' -newer 'src/binding/cxx/mpicxx.h' >/dev/null 2>&1 ; then build_cxx=yes fi if [ $build_cxx = "yes" ] ; then echo_n "Building C++ interface... " ( cd src/binding/cxx && chmod a+x ./buildiface && ./buildiface -nosep $otherarg ) echo "done" fi fi ######################################################################## ## Extract error messages ######################################################################## # Capture the error messages if [ $do_geterrmsgs = "yes" ] ; then if [ -x maint/extracterrmsgs ] ; then echo_n "Extracting error messages... " rm -rf .tmp rm -f .err rm -f unusederr.txt maint/extracterrmsgs -careful=unusederr.txt \ -skip=src/util/multichannel/mpi.c `cat maint/errmsgdirs` > \ .tmp 2>.err # (error here is ok) echo "done" update_errdefs=yes if [ -s .err ] ; then cat .err rm -f .err2 grep -v "Warning:" .err > .err2 if [ -s .err2 ] ; then warn "Because of errors in extracting error messages, the file" warn "src/mpi/errhan/defmsg.h was not updated." error "Error message files in src/mpi/errhan were not updated." rm -f .tmp .err .err2 exit 1 fi rm -f .err .err2 else # Incase it exists but has zero size rm -f .err fi if [ -s unusederr.txt ] ; then warn "There are unused error message texts in src/mpi/errhan/errnames.txt" warn "See the file unusederr.txt for the complete list" fi if [ -s .tmp -a "$update_errdefs" = "yes" ] ; then mv .tmp src/mpi/errhan/defmsg.h fi if [ ! -s src/mpi/errhan/defmsg.h ] ; then echo_n "Creating a dummy defmsg.h file... " cat > src/mpi/errhan/defmsg.h < MPICH_ERROR_MSG_NONE #define MPIR_MAX_ERROR_CLASS_INDEX 54 static int class_to_index[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #endif EOF echo "done" fi fi fi # do_geterrmsgs ######################################################################## ## Build required scripts ######################################################################## echo echo "------------------------------------" echo "Initiating building required scripts" # Build scripts such as genstates if necessary ran_maint_configure=no run_configure=no # The information that autoconf uses is saved in the autom4te*.cache # file; since this cache is not accurate, we delete it. if [ ! -x maint/configure ] ; then (cd maint && $autoconf && rm -rf autom4te*.cache ) elif find maint -name 'configure.ac' -newer 'maint/configure' >/dev/null 2>&1 ; then # The above relies on the Unix find command (cd maint && $autoconf && rm -rf autom4te*.cache) fi if [ ! -x maint/genstates ] ; then run_configure=yes fi # The following relies on the Unix find command if [ -s maint/genstates ] ; then if find maint -name 'genstates.in' -newer 'maint/genstates' >/dev/null 2>&1 ; then run_configure=yes fi else run_configure=yes fi if [ "$run_configure" = "yes" ] ; then (cd maint && ./configure) ran_maint_configure=yes fi echo "Done building required scripts" echo "------------------------------------" echo # Run some of the simple codes echo_n "Creating the enumeration of logging states into src/include/mpiallstates.h... " if [ -x maint/extractstates -a $do_genstates = "yes" ] ; then ./maint/extractstates fi echo "done" # new parameter code echo_n "Generating parameter handling code... " if test -x maint/genparams -a "$do_getparms" = "yes" ; then if ./maint/genparams ; then echo "done" else echo "failed" error "unable to generate parameter handling code" exit 1 fi else echo "skipped" fi # Create and/or update the f90 tests if [ -x ./maint/f77tof90 -a $do_f77tof90 = "yes" ] ; then echo_n "Create or update the Fortran 90 tests derived from the Fortran 77 tests... " for dir in test/mpi/f77/* ; do if [ ! -d $dir ] ; then continue ; fi leafDir=`basename $dir` if [ ! -d test/mpi/f90/$leafDir ] ; then mkdir test/mpi/f90/$leafDir fi maint/f77tof90 $dir test/mpi/f90/$leafDir Makefile.am Makefile.ap echo "timestamp" > test/mpi/f90/$leafDir/Makefile.am-stamp done echo "done" fi echo echo echo "###########################################################" echo "## Generating configure files" echo "###########################################################" echo ######################################################################## ## Running autotools on non-simplemake directories ######################################################################## if [ "$do_build_configure" = "yes" ] ; then for external in $externals ; do if [ -d "$external" -o -L "$external" ] ; then echo "------------------------------------------------------------------------" echo "running third-party initialization in $external" (cd $external && ./autogen.sh) || exit 1 fi done for amdir in $amdirs ; do if [ -d "$amdir" -o -L "$amdir" ] ; then echo "------------------------------------------------------------------------" echo "running $autoreconf in $amdir" (cd $amdir && $autoreconf $autoreconf_args) || exit 1 fi done fi