1#! /bin/sh
2#
3# (C) 2006 by Argonne National Laboratory.
4#     See COPYRIGHT in top-level directory.
5#
6# Update all of the derived files
7# For best performance, execute this in the top-level directory.
8# There are some experimental features to allow it to be executed in
9# subdirectories
10#
11# Eventually, we want to allow this script to be executed anywhere in the
12# mpich tree.  This is not yet implemented.
13
14
15########################################################################
16## Utility functions
17########################################################################
18
19recreate_tmp() {
20    rm -rf .tmp
21    mkdir .tmp 2>&1 >/dev/null
22}
23
24warn() {
25    echo "===> WARNING: $@"
26}
27
28error() {
29    echo "===> ERROR:   $@"
30}
31
32echo_n() {
33    # "echo -n" isn't portable, must portably implement with printf
34    printf "%s" "$*"
35}
36
37# Assume Program's install-dir is <install-dir>/bin/<prog>.
38# Given program name as the 1st argument,
39# the install-dir is returned is returned in 2nd argument.
40# e.g., ProgHomeDir libtoolize libtooldir.
41ProgHomeDir() {
42    prog=$1
43    progpath="`which $prog`"
44    progbindir="`dirname $progpath`"
45    proghome=`(cd $progbindir/.. && pwd)`
46    eval $2=$proghome
47}
48
49########################################################################
50## Run any local pre-update hooks
51########################################################################
52if test -d maint/hooks/pre ; then
53    for hook in `ls maint/hooks/pre/* 2>/dev/null` ; do
54        if test -x "$hook" ; then
55            echo_n "executing pre-update hook '$hook'... "
56            ./$hook
57            echo done
58        else
59            warn "unable to execute pre-update hook: '$hook'"
60        fi
61    done
62fi
63
64echo
65echo "##################################"
66echo "## Checking user environment"
67echo "##################################"
68echo
69
70########################################################################
71## Checks to make sure we are running from the correct location
72########################################################################
73
74echo_n "Verifying the location of autogen.sh... "
75if [ ! -d maint -o ! -s maint/version.m4 ] ; then
76    echo "must execute at top level directory for now"
77    exit 1
78fi
79echo "done"
80
81
82########################################################################
83## Version checks for svn in developer builds
84########################################################################
85
86# Sanity check that any relative path svn:externals are present.  An
87# SVN version >=1.5 is needed to understand the relative path
88# externals format.  Such externals are used in particular for mpl in
89# hydra and all non-root confdbs.
90#
91# Check for a particular file, not just the directory because several
92# autotools steps (such as libtoolize) will create the aux/macro dir.
93echo_n "Checking for svn checkout errors... "
94svn_externals_sanity_file="src/pm/hydra/version.m4"
95# Note that -e is not an available option for test in the Bourne shell, though
96# some systems that pretend that ksh is the same as sh will accept it.
97if test "!" -f $svn_externals_sanity_file ; then
98    cat <<EOT
99
100ERROR: The file '$svn_externals_sanity_file'
101is not present, indicating that you do not have a complete source tree.
102This is usually caused by checking out MPICH2 with an SVN client version
103less than v1.6.  Please check your SVN client version (with
104"svn --version") and use a newer version if necessary to obtain MPICH2.
105
106If you do have a modern SVN client and believe that you have reached
107this error case for some other reason, please file a ticket at:
108
109  https://trac.mcs.anl.gov/projects/mpich2/newticket
110
111EOT
112    exit 1
113fi
114echo "done"
115
116
117########################################################################
118## Initialize variables to default values (possibly from the environment)
119########################################################################
120
121# Default choices
122do_bindings=yes
123do_geterrmsgs=yes
124do_getparms=yes
125do_f77=yes
126do_f77tof90=yes
127do_build_configure=yes
128do_genstates=yes
129do_smpdversion=yes
130do_atdir_check=no
131do_atver_check=yes
132do_subcfg_m4=yes
133
134export do_build_configure
135
136# Allow MAKE to be set from the environment
137MAKE=${MAKE-make}
138
139# external packages that require autogen.sh to be run for each of them
140externals="src/mpe2 src/pm/hydra src/mpi/romio src/armci src/pm/mpd src/openpa"
141# amdirs are the directories that make use of autoreconf
142amdirs=". src/mpl src/util/logging/rlog"
143
144autoreconf_args="-if"
145export autoreconf_args
146
147########################################################################
148## Read the command-line arguments
149########################################################################
150
151# List of steps that we will consider (We do not include depend
152# because the values for depend are not just yes/no)
153AllSteps="geterrmsgs bindings f77 f77tof90 build_configure genstates smpdversion getparms"
154stepsCleared=no
155
156for arg in "$@" ; do
157    case $arg in
158	-echo)
159	    set -x
160	    ;;
161
162	-atdircheck=*)
163	    val=`echo X$arg | sed -e 's/^X-atdircheck=//'`
164            case $val in
165		yes|YES|true|TRUE|1) do_atdir_check=yes ;;
166		no|NO|false|FALSE|0) do_atdir_check=no ;;
167		*) warn "unknown option: $arg."
168            esac
169            ;;
170
171	-atvercheck=*)
172            val=`echo X$arg | sed -e 's/^X-atvercheck=//'`
173            case $val in
174		yes|YES|true|TRUE|1) do_atver_check=yes ;;
175		no|NO|false|FALSE|0) do_atver_check=no ;;
176		*) warn "unknown option: $arg."
177            esac
178            ;;
179
180	-do=*|--do=*)
181	    opt=`echo A$arg | sed -e 's/^A--*do=//'`
182	    case $opt in
183		build-configure|configure) opt=build_configure ;;
184	    esac
185	    var=do_$opt
186
187	    # Check that this opt is known
188	    eval oldval=\$"$var"
189	    if [ -z "$oldval" ] ; then
190		echo "-do=$opt is unrecognized"
191		exit 1
192	    else
193		if [ $stepsCleared = no ] ; then
194		    for step in $AllSteps ; do
195			var=do_$step
196			eval $var=no
197		    done
198		    stepsCleared=yes
199		fi
200		var=do_$opt
201		eval $var=yes
202	    fi
203	    ;;
204
205        -verbose-autoreconf|--verbose-autoreconf)
206            autoreconf_args="-vif"
207            export autoreconf_args
208            ;;
209
210	-with-genstates|--with-genstates)
211	    do_genstates=yes
212	    ;;
213
214	-without-genstates|--without-genstates)
215	    do_genstates=no
216	    ;;
217
218	-with-errmsgs|--with-errmsgs)
219	    do_geterrmsgs=yes
220	    ;;
221
222	-without-errmsgs|--without-errmsgs)
223	    do_geterrmsgs=no
224	    ;;
225
226	-with-bindings|--with-bindings)
227	    do_bindings=yes
228	    ;;
229
230	-without-bindings|--without-bindings)
231	    do_bindings=no
232	    ;;
233
234	-with-f77|--with-f77)
235	    do_f77=yes
236	    ;;
237
238	-without-f77|--without-f77)
239	    do_f77=no
240	    ;;
241
242	-with-autotools=*|--with-autotools=*)
243	    autotoolsdir=`echo "A$arg" | sed -e 's/.*=//'`
244	    ;;
245
246	-help|--help|-usage|--usage)
247	    cat <<EOF
248   ./autogen.sh [ --with-autotools=dir ] \\
249                [ -atdircheck=[yes|no] ] \\
250                [ -atvercheck=[yes|no] ] \\
251                [ --verbose-autoreconf ] \\
252                [ --do=stepname ] [ -distrib ]
253    Update the files in the MPICH2 build tree.  This file builds the 
254    configure files, creates the Makefile.in files, extracts the error
255    messages.
256
257    You can use --with-autotools=dir to specify a directory that
258    contains alternate autotools.
259
260    -atdircheck=[yes|no] specifies the enforcement of all autotools
261    should be installed in the same directory.
262
263    -atvercheck=[yes|no] specifies if the check for the version of 
264    autotools should be carried out.
265
266    -distrib creates a distribution version of the Makefile.in files (no
267    targets for updating the Makefile.in from Makefile.sm or rebuilding the
268    autotools targets).  This does not create the configure files because
269    some of those depend on rules in the Makefile.in in that directory.  
270    Thus, to build all of the files for a distribution, run autogen.sh
271    twice, as in 
272         autogen.sh && autogen.sh -distrib
273
274    Use --do=stepname to update only a single step.  For example, 
275    --do=build_configure only updates the configure scripts.  The available
276    steps are:
277EOF
278	    for step in $AllSteps ; do
279		echo "        $step"
280	    done
281	    exit 1
282	    ;;
283
284	*)
285	    echo "unknown argument $arg"
286	    exit 1
287	    ;;
288
289    esac
290done
291
292########################################################################
293## Check for the location of autotools
294########################################################################
295
296if [ -z "$autotoolsdir" ] ; then
297    autotoolsdir=$MPICH2_AUTOTOOLS_DIR
298fi
299
300if [ -n "$autotoolsdir" ] ; then
301    if [ -x $autotoolsdir/autoconf -a -x $autotoolsdir/autoheader ] ; then
302        autoconf=$autotoolsdir/autoconf
303        autoheader=$autotoolsdir/autoheader
304        autoreconf=$autotoolsdir/autoreconf
305        automake=$autotoolsdir/automake
306        autom4te=$autotoolsdir/autom4te
307        aclocal=$autotoolsdir/aclocal
308        if [ -x "$autotoolsdir/glibtoolize" ] ; then
309            libtoolize=$autotoolsdir/glibtoolize
310        else
311            libtoolize=$autotoolsdir/libtoolize
312        fi
313
314	AUTOCONF=$autoconf
315	AUTOHEADER=$autoheader
316        AUTORECONF=$autoreconf
317        AUTOMAKE=$automake
318	AUTOM4TE=$autom4te
319        ACLOCAL=$aclocal
320        LIBTOOLIZE=$libtoolize
321
322	export AUTOCONF
323	export AUTOHEADER
324        export AUTORECONF
325        export AUTOM4TE
326        export AUTOMAKE
327        export ACLOCAL
328        export LIBTOOLIZE
329    else
330        echo "could not find executable autoconf and autoheader in $autotoolsdir"
331	exit 1
332    fi
333else
334    autoconf=${AUTOCONF:-autoconf}
335    autoheader=${AUTOHEADER:-autoheader}
336    autoreconf=${AUTORECONF:-autoreconf}
337    autom4te=${AUTOM4TE:-autom4te}
338    automake=${AUTOMAKE:-automake}
339    aclocal=${ACLOCAL:-aclocal}
340    if test -z "${LIBTOOLIZE+set}" && ( glibtoolize --version ) >/dev/null 2>&1 ; then
341        libtoolize=glibtoolize
342    else
343        libtoolize=${LIBTOOLIZE:-libtoolize}
344    fi
345fi
346
347ProgHomeDir $autoconf   autoconfdir
348ProgHomeDir $automake   automakedir
349ProgHomeDir $libtoolize libtooldir
350
351echo_n "Checking if autotools are in the same location... "
352if [ "$autoconfdir" = "$automakedir" -a "$autoconfdir" = "$libtooldir" ] ; then
353    same_atdir=yes
354    echo "yes, all in $autoconfdir"
355else
356    same_atdir=no
357    echo "no"
358    echo "	autoconf is in $autoconfdir"
359    echo "	automake is in $automakedir"
360    echo "	libtool  is in $libtooldir"
361    # Emit a big warning message if $same_atdir = no.
362    warn "Autotools are in different locations. In rare occasion,"
363    warn "resulting configure or makefile may fail in some unexpected ways."
364fi
365
366########################################################################
367## Check if autoreconf can be patched to work
368## when autotools are not in the same location.
369## This test needs to be done before individual tests of autotools
370########################################################################
371
372# If autotools are not in the same location, override autoreconf appropriately.
373if [ "$same_atdir" != "yes" ] ; then
374    if [ -z "$libtooldir" ] ; then
375        ProgHomeDir $libtoolize libtooldir
376    fi
377    libtoolm4dir="$libtooldir/share/aclocal"
378    echo_n "Checking if $autoreconf accepts -I $libtoolm4dir... "
379    new_autoreconf_works=no
380    if [ -d "$libtoolm4dir" -a -f "$libtoolm4dir/libtool.m4" ] ; then
381        recreate_tmp
382        cat >.tmp/configure.ac <<_EOF
383AC_INIT(foo,1.0)
384AC_PROG_LIBTOOL
385AC_OUTPUT
386_EOF
387        AUTORECONF="$autoreconf -I $libtoolm4dir"
388        if (cd .tmp && $AUTORECONF -ivf >/dev/null 2>&1) ; then
389            new_autoreconf_works=yes
390        fi
391        rm -rf .tmp
392    fi
393    echo "$new_autoreconf_works"
394    # If autoreconf accepts -I <libtool's m4 dir> correctly, use -I.
395    # If not, run libtoolize before autoreconf (i.e. for autoconf <= 2.63)
396    # This test is more general than checking the autoconf version.
397    if [ "$new_autoreconf_works" != "yes" ] ; then
398        echo_n "Checking if $autoreconf works after an additional $libtoolize step... "
399        new_autoreconf_works=no
400        recreate_tmp
401        # Need AC_CONFIG_
402        cat >.tmp/configure.ac <<_EOF
403AC_INIT(foo,1.0)
404AC_CONFIG_AUX_DIR([m4])
405AC_CONFIG_MACRO_DIR([m4])
406AC_PROG_LIBTOOL
407AC_OUTPUT
408_EOF
409        cat >.tmp/Makefile.am <<_EOF
410ACLOCAL_AMFLAGS = -I m4
411_EOF
412        AUTORECONF="eval $libtoolize && $autoreconf"
413        if (cd .tmp && $AUTORECONF -ivf >u.txt 2>&1) ; then
414            new_autoreconf_works=yes
415        fi
416        rm -rf .tmp
417        echo "$new_autoreconf_works"
418    fi
419    if [ "$new_autoreconf_works" = "yes" ] ; then
420        export AUTORECONF
421        autoreconf="$AUTORECONF"
422    else
423        # Since all autoreconf workarounds do not work, we need
424        # to require all autotools to be in the same directory.
425        do_atdir_check=yes
426        error "Since none of the autoreconf workaround works"
427        error "and autotools are not in the same directory, aborting..."
428        error "Updating autotools or putting all autotools in the same location"
429        error "may resolve the issue."
430        exit 1
431    fi
432fi
433
434########################################################################
435## Verify autoconf version
436########################################################################
437
438echo_n "Checking for autoconf version... "
439recreate_tmp
440ver=2.67
441# petsc.mcs.anl.gov's /usr/bin/autoreconf is version 2.65 which returns OK
442# if configure.ac has AC_PREREQ() withOUT AC_INIT.
443#
444# ~/> hostname
445# petsc
446# ~> /usr/bin/autoconf --version
447# autoconf (GNU Autoconf) 2.65
448# ....
449# ~/> cat configure.ac
450# AC_PREREQ(2.68)
451# ~/> /usr/bin/autoconf ; echo "rc=$?"
452# configure.ac:1: error: Autoconf version 2.68 or higher is required
453# configure.ac:1: the top level
454# autom4te: /usr/bin/m4 failed with exit status: 63
455# rc=63
456# ~/> /usr/bin/autoreconf ; echo "rc=$?"
457# rc=0
458cat > .tmp/configure.ac<<EOF
459AC_INIT
460AC_PREREQ($ver)
461AC_OUTPUT
462EOF
463if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then
464    echo ">= $ver"
465else
466    echo "bad autoconf installation"
467    cat <<EOF
468You either do not have autoconf in your path or it is too old (version
469$ver or higher required). You may be able to use
470
471     autoconf --version
472
473Unfortunately, there is no standard format for the version output and
474it changes between autotools versions.  In addition, some versions of
475autoconf choose among many versions and provide incorrect output).
476EOF
477    exit 1
478fi
479
480
481########################################################################
482## Verify automake version
483########################################################################
484
485echo_n "Checking for automake version... "
486recreate_tmp
487ver=1.12.3
488cat > .tmp/configure.ac<<EOF
489AC_INIT(testver,1.0)
490AC_CONFIG_AUX_DIR([m4])
491AC_CONFIG_MACRO_DIR([m4])
492m4_ifdef([AM_INIT_AUTOMAKE],,[m4_fatal([AM_INIT_AUTOMAKE not defined])])
493AM_INIT_AUTOMAKE([$ver foreign])
494AC_MSG_RESULT([A message])
495AC_OUTPUT([Makefile])
496EOF
497cat <<EOF >.tmp/Makefile.am
498ACLOCAL_AMFLAGS = -I m4
499EOF
500if [ ! -d .tmp/m4 ] ; then mkdir .tmp/m4 >/dev/null 2>&1 ; fi
501if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then
502    echo ">= $ver"
503else
504    echo "bad automake installation"
505    cat <<EOF
506You either do not have automake in your path or it is too old (version
507$ver or higher required). You may be able to use
508
509     automake --version
510
511Unfortunately, there is no standard format for the version output and
512it changes between autotools versions.  In addition, some versions of
513autoconf choose among many versions and provide incorrect output).
514EOF
515    exit 1
516fi
517
518
519########################################################################
520## Verify libtool version
521########################################################################
522
523echo_n "Checking for libtool version... "
524recreate_tmp
525ver=2.4
526cat <<EOF >.tmp/configure.ac
527AC_INIT(testver,1.0)
528AC_CONFIG_AUX_DIR([m4])
529AC_CONFIG_MACRO_DIR([m4])
530m4_ifdef([LT_PREREQ],,[m4_fatal([LT_PREREQ not defined])])
531LT_PREREQ($ver)
532LT_INIT()
533AC_MSG_RESULT([A message])
534EOF
535cat <<EOF >.tmp/Makefile.am
536ACLOCAL_AMFLAGS = -I m4
537EOF
538if [ ! -d .tmp/m4 ] ; then mkdir .tmp/m4 >/dev/null 2>&1 ; fi
539if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then
540    echo ">= $ver"
541else
542    echo "bad libtool installation"
543    cat <<EOF
544You either do not have libtool in your path or it is too old
545(version $ver or higher required). You may be able to use
546
547     libtool --version
548
549Unfortunately, there is no standard format for the version output and
550it changes between autotools versions.  In addition, some versions of
551autoconf choose among many versions and provide incorrect output).
552EOF
553    exit 1
554fi
555
556
557########################################################################
558## Checking for UNIX find
559########################################################################
560
561echo_n "Checking for UNIX find... "
562find . -name 'configure.ac' > /dev/null 2>&1
563if [ $? = 0 ] ; then
564    echo "done"
565else
566    echo "not found (error)"
567    exit 1
568fi
569
570
571########################################################################
572## Checking if xargs rm -rf works
573########################################################################
574
575echo_n "Checking if xargs rm -rf works... "
576if [ -d "`find . -name __random_dir__`" ] ; then
577    error "found a directory named __random_dir__"
578    exit 1
579else
580    mkdir __random_dir__
581    find . -name __random_dir__ | xargs rm -rf > /dev/null 2>&1
582    if [ $? = 0 ] ; then
583	echo "yes"
584    else
585	echo "no (error)"
586	rm -rf __random_dir__
587	exit 1
588    fi
589fi
590
591
592
593echo
594echo
595echo "###########################################################"
596echo "## Autogenerating required files"
597echo "###########################################################"
598echo
599
600########################################################################
601## Building maint/Version
602########################################################################
603
604# build a substitute maint/Version script now that we store the single copy of
605# this information in an m4 file for autoconf's benefit
606echo_n "Generating a helper maint/Version... "
607if $autom4te -l M4sugar maint/Version.base.m4 > maint/Version ; then
608    echo "done"
609else
610    echo "error"
611    error "unable to correctly generate maint/Version shell helper"
612fi
613
614########################################################################
615## Building the README
616########################################################################
617
618echo_n "Updating the README... "
619. ./maint/Version
620if [ -f README.vin ] ; then
621    sed -e "s/%VERSION%/${MPICH2_VERSION}/g" README.vin > README
622    echo "done"
623else
624    echo "error"
625    error "README.vin file not present, unable to update README version number (perhaps we are running in a release tarball source tree?)"
626fi
627
628
629########################################################################
630## Update SMPD version
631########################################################################
632
633if [ "$do_smpdversion" = yes ] ; then
634    echo_n "Creating src/pm/smpd/smpd_version.h... "
635    smpdVersion=${MPICH2_VERSION}
636    cat >src/pm/smpd/smpd_version.h <<EOF
637/* -*- Mode: C; c-basic-offset:4 ; -*- */
638/*  
639 *  (C) 2005 by Argonne National Laboratory.
640 *      See COPYRIGHT in top-level directory.
641 */
642#define SMPD_VERSION "$smpdVersion"
643EOF
644    echo "done"
645fi
646
647########################################################################
648## Building subsys_include.m4
649########################################################################
650if [ "X$do_subcfg_m4" = Xyes ] ; then
651    echo_n "Creating subsys_include.m4... "
652    ./maint/gen_subcfg_m4
653    echo "done"
654fi
655
656########################################################################
657## Building non-C interfaces
658########################################################################
659
660# Create the bindings if necessary
661if [ $do_bindings = "yes" ] ; then
662    build_f77=no
663    build_f90=no
664    build_cxx=no
665    if [ $do_f77 = "yes" ] ; then
666        if [ ! -s src/binding/f77/abortf.c ] ; then
667	    build_f77=yes
668        elif find src/binding/f77 -name 'buildiface' -newer 'src/binding/f77/abortf.c' >/dev/null 2>&1 ; then
669	    build_f77=yes
670        fi
671        if [ ! -s src/binding/f90/mpi_base.f90 ] ; then
672 	    build_f90=yes
673        elif find src/binding/f90 -name 'buildiface' -newer 'src/binding/f90/mpi_base.f90' >/dev/null 2>&1 ; then
674	    build_f90=yes
675        fi
676
677    fi
678
679    if [ $build_f77 = "yes" ] ; then
680	echo_n "Building Fortran 77 interface... "
681	( cd src/binding/f77 && chmod a+x ./buildiface && ./buildiface )
682	echo "done"
683    fi
684    if [ $build_f90 = "yes" ] ; then
685	echo_n "Building Fortran 90 interface... "
686	# Remove any copy of mpi_base.f90 (this is used to handle the
687	# Double precision vs. Real*8 option
688	rm -f src/binding/f90/mpi_base.f90.orig
689	( cd src/binding/f90 && chmod a+x ./buildiface && ./buildiface )
690	( cd src/binding/f90 && ../f77/buildiface -infile=cf90t.h -deffile=cf90tdefs)
691	echo "done"
692    fi
693
694    if [ ! -s src/binding/cxx/mpicxx.h ] ; then
695	build_cxx=yes
696    elif find src/binding/cxx -name 'buildiface' -newer 'src/binding/cxx/mpicxx.h' >/dev/null 2>&1 ; then
697	build_cxx=yes
698    fi
699    if [ $build_cxx = "yes" ] ; then
700	echo_n "Building C++ interface... "
701	( cd src/binding/cxx && chmod a+x ./buildiface &&
702	  ./buildiface -nosep $otherarg )
703	echo "done"
704    fi
705fi
706
707
708########################################################################
709## Extract error messages
710########################################################################
711
712# Capture the error messages
713if [ $do_geterrmsgs = "yes" ] ; then
714    if [ -x maint/extracterrmsgs ] ; then
715        echo_n "Extracting error messages... "
716        rm -rf .tmp
717        rm -f .err
718	rm -f unusederr.txt
719        maint/extracterrmsgs -careful=unusederr.txt \
720	    -skip=src/util/multichannel/mpi.c `cat maint/errmsgdirs` > \
721	    .tmp 2>.err
722        # (error here is ok)
723	echo "done"
724
725        update_errdefs=yes
726        if [ -s .err ] ; then
727            cat .err
728            rm -f .err2
729            grep -v "Warning:" .err > .err2
730            if [ -s .err2 ] ; then
731                warn "Because of errors in extracting error messages, the file"
732                warn "src/mpi/errhan/defmsg.h was not updated."
733		error "Error message files in src/mpi/errhan were not updated."
734   	        rm -f .tmp .err .err2
735		exit 1
736            fi
737            rm -f .err .err2
738        else
739            # Incase it exists but has zero size
740            rm -f .err
741        fi
742	if [ -s unusederr.txt ] ; then
743	    warn "There are unused error message texts in src/mpi/errhan/errnames.txt"
744	    warn "See the file unusederr.txt for the complete list"
745        fi
746        if [ -s .tmp -a "$update_errdefs" = "yes" ] ; then
747            mv .tmp src/mpi/errhan/defmsg.h
748        fi
749        if [ ! -s src/mpi/errhan/defmsg.h ] ; then
750            echo_n "Creating a dummy defmsg.h file... "
751	    cat > src/mpi/errhan/defmsg.h <<EOF
752typedef struct { const unsigned int sentinal1; const char *short_name, *long_name; const unsigned int sentinal2; } msgpair;
753static const int generic_msgs_len = 0;
754static msgpair generic_err_msgs[] = { {0xacebad03, 0, "no error catalog", 0xcb0bfa11}, };
755static const int specific_msgs_len = 0;
756static msgpair specific_err_msgs[] = {  {0xacebad03,0,0,0xcb0bfa11}, };
757#if MPICH_ERROR_MSG_LEVEL > MPICH_ERROR_MSG_NONE
758#define MPIR_MAX_ERROR_CLASS_INDEX 54
759static int class_to_index[] = {
7600, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7610, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7620, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7630, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7640, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7650, 0, 0, 0 };
766#endif
767EOF
768	    echo "done"
769        fi
770    fi
771fi  # do_geterrmsgs
772
773
774########################################################################
775## Build required scripts
776########################################################################
777
778echo
779echo "------------------------------------"
780echo "Initiating building required scripts"
781# Build scripts such as genstates if necessary
782ran_maint_configure=no
783run_configure=no
784# The information that autoconf uses is saved in the autom4te*.cache
785# file; since this cache is not accurate, we delete it.
786if [ ! -x maint/configure ] ; then
787    (cd maint && $autoconf && rm -rf autom4te*.cache )
788elif find maint -name 'configure.ac' -newer 'maint/configure' >/dev/null 2>&1 ; then
789    # The above relies on the Unix find command
790    (cd maint && $autoconf && rm -rf autom4te*.cache)
791fi
792if [ ! -x maint/genstates ] ; then
793    run_configure=yes
794fi
795
796# The following relies on the Unix find command
797if [ -s maint/genstates ] ; then
798    if find maint -name 'genstates.in' -newer 'maint/genstates' >/dev/null 2>&1 ; then
799        run_configure=yes
800    fi
801else
802    run_configure=yes
803fi
804
805if [ "$run_configure" = "yes" ] ; then
806    (cd maint && ./configure)
807    ran_maint_configure=yes
808fi
809echo "Done building required scripts"
810echo "------------------------------------"
811echo
812
813# Run some of the simple codes
814echo_n "Creating the enumeration of logging states into src/include/mpiallstates.h... "
815if [ -x maint/extractstates -a $do_genstates = "yes" ] ; then
816    ./maint/extractstates
817fi
818echo "done"
819
820# new parameter code
821echo_n "Generating parameter handling code... "
822if test -x maint/genparams -a "$do_getparms" = "yes" ; then
823    if ./maint/genparams ; then
824        echo "done"
825    else
826        echo "failed"
827        error "unable to generate parameter handling code"
828        exit 1
829    fi
830else
831    echo "skipped"
832fi
833
834# Create and/or update the f90 tests
835if [ -x ./maint/f77tof90 -a $do_f77tof90 = "yes" ] ; then
836    echo_n "Create or update the Fortran 90 tests derived from the Fortran 77 tests... "
837    for dir in test/mpi/f77/* ; do
838        if [ ! -d $dir ] ; then continue ; fi
839	leafDir=`basename $dir`
840        if [ ! -d test/mpi/f90/$leafDir ] ; then
841	    mkdir test/mpi/f90/$leafDir
842        fi
843        maint/f77tof90 $dir test/mpi/f90/$leafDir Makefile.am Makefile.ap
844        echo "timestamp" > test/mpi/f90/$leafDir/Makefile.am-stamp
845    done
846    echo "done"
847fi
848
849echo
850echo
851echo "###########################################################"
852echo "## Generating configure files"
853echo "###########################################################"
854echo
855
856########################################################################
857## Running autotools on non-simplemake directories
858########################################################################
859
860if [ "$do_build_configure" = "yes" ] ; then
861    for external in $externals ; do
862       if [ -d "$external" -o -L "$external" ] ; then
863           echo "------------------------------------------------------------------------"
864           echo "running third-party initialization in $external"
865           (cd $external && ./autogen.sh) || exit 1
866       fi
867    done
868
869    for amdir in $amdirs ; do
870	if [ -d "$amdir" -o -L "$amdir" ] ; then
871	    echo "------------------------------------------------------------------------"
872	    echo "running $autoreconf in $amdir"
873            (cd $amdir && $autoreconf $autoreconf_args) || exit 1
874	fi
875    done
876fi
877