autogen.sh 28 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#! /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.
13

14

15
16
17
########################################################################
## Utility functions
########################################################################
18

19
20
21
22
recreate_tmp() {
    rm -rf .tmp
    mkdir .tmp 2>&1 >/dev/null
}
23

24
25
26
27
warn() {
    echo "===> WARNING: $@"
}

28
29
30
31
error() {
    echo "===> ERROR:   $@"
}

32
echo_n() {
33
    # "echo -n" isn't portable, must portably implement with printf
34
35
    printf "%s" "$*"
}
36

37
38
39
40
# Assume Program's install-dir is <install-dir>/bin/<prog>.
# Given program name as the 1st argument,
# the install-dir is returned is returned in 2nd argument.
# e.g., ProgHomeDir libtoolize libtooldir.
41
42
43
44
ProgHomeDir() {
    prog=$1
    progpath="`which $prog`"
    progbindir="`dirname $progpath`"
45
    proghome=`(cd $progbindir/.. && pwd)`
46
47
    eval $2=$proghome
}
48

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
########################################################################
## 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

64
65
66
67
########################################################################
# This used to be an optionally installed hook to help with git-svn
# versions of the old SVN repo.  Now that we are using git, this is our
# mechanism that replaces relative svn:externals paths, such as for
68
69
70
# "confdb" and "mpl". The basic plan is to delete the destdir and then
# copy all of the files, warts and all, from the source directory to the
# destination directory.
71
72
73
74
75
76
77
78
79
80
81
82
echo
echo "####################################"
echo "## Replicating confdb (and similar)"
echo "####################################"
echo

sync_external () {
    srcdir=$1
    destdir=$2

    echo "syncing '$srcdir' --> '$destdir'"

83
84
85
86
    # deletion prevents creating 'confdb/confdb' situation, also cleans
    # stray files that may have crept in somehow
    rm -rf "$destdir"
    cp -pPR "$srcdir" "$destdir"
87
88
89
90
91
92
93
94
95
96
}

confdb_dirs=
confdb_dirs="${confdb_dirs} src/mpi/romio/confdb"
confdb_dirs="${confdb_dirs} src/mpl/confdb"
confdb_dirs="${confdb_dirs} src/pm/hydra/confdb"
confdb_dirs="${confdb_dirs} src/pm/hydra/mpl/confdb"
confdb_dirs="${confdb_dirs} test/mpi/confdb"
confdb_dirs="${confdb_dirs} src/armci/m4"

97
98
# hydra's copy of mpl
sync_external src/mpl src/pm/hydra/mpl
99

100
101
102
103
# all the confdb directories, by various names
for destdir in $confdb_dirs ; do
    sync_external confdb "$destdir"
done
104

105
106
107
108
# a couple of other random files
if [ -f maint/version.m4 ] ; then
    cp -pPR maint/version.m4 src/pm/hydra/version.m4
    cp -pPR maint/version.m4 src/mpi/romio/version.m4
109
110
fi

111
# Now sanity check that some of the above sync was successful
112
113
114
115
116
117
118
119
120
121
f="aclocal_cc.m4"
for d in $confdb_dirs ; do
    if [ -f "$d/$f" ] ; then :
    else
        error "expected to find '$f' in '$d'"
        exit 1
    fi
done

########################################################################
122
echo
123
echo "####################################"
124
echo "## Checking user environment"
125
echo "####################################"
126
127
128
129
130
echo

########################################################################
## Checks to make sure we are running from the correct location
########################################################################
131

132
echo_n "Verifying the location of autogen.sh... "
133
if [ ! -d maint -o ! -s maint/version.m4 ] ; then
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    echo "must execute at top level directory for now"
    exit 1
fi
echo "done"


########################################################################
## Initialize variables to default values (possibly from the environment)
########################################################################

# Default choices
do_bindings=yes
do_geterrmsgs=yes
do_getparms=yes
do_f77=yes
do_f77tof90=yes
do_build_configure=yes
do_genstates=yes
do_smpdversion=yes
153
154
do_atdir_check=no
do_atver_check=yes
155
do_subcfg_m4=yes
156

157
158
export do_build_configure

159
160
161
# Allow MAKE to be set from the environment
MAKE=${MAKE-make}

162
# external packages that require autogen.sh to be run for each of them
163
externals="src/pm/hydra src/mpi/romio src/armci src/pm/mpd src/openpa"
164
# amdirs are the directories that make use of autoreconf
165
amdirs=". src/mpl src/util/logging/rlog"
166

167
autoreconf_args="-if"
168
export autoreconf_args
169
170
171
172
173
174
175

########################################################################
## Read the command-line arguments
########################################################################

# List of steps that we will consider (We do not include depend
# because the values for depend are not just yes/no)
176
AllSteps="geterrmsgs bindings f77 f77tof90 build_configure genstates smpdversion getparms"
177
stepsCleared=no
178

179
180
for arg in "$@" ; do
    case $arg in 
181
182
183
	-echo)
	    set -x
	    ;;
184
	
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
	-atdircheck=*)
	    val=`echo X$arg | sed -e 's/^X-atdircheck=//'`
            case $val in
		yes|YES|true|TRUE|1) do_atdir_check=yes ;;
		no|NO|false|FALSE|0) do_atdir_check=no ;;
		*) warn "unknown option: $arg."
            esac
            ;;

	-atvercheck=*)
            val=`echo X$arg | sed -e 's/^X-atvercheck=//'`
            case $val in
		yes|YES|true|TRUE|1) do_atver_check=yes ;;
		no|NO|false|FALSE|0) do_atver_check=no ;;
		*) warn "unknown option: $arg."
            esac
            ;;

	-do=*|--do=*)
	    opt=`echo A$arg | sed -e 's/^A--*do=//'`
	    case $opt in 
		build-configure|configure) opt=build_configure ;;
	    esac
	    var=do_$opt

	    # Check that this opt is known
	    eval oldval=\$"$var"
	    if [ -z "$oldval" ] ; then
		echo "-do=$opt is unrecognized"
		exit 1
	    else
		if [ $stepsCleared = no ] ; then
		    for step in $AllSteps ; do
			var=do_$step
			eval $var=no
		    done
		    stepsCleared=yes
		fi
		var=do_$opt
		eval $var=yes
	    fi
	    ;;

228
229
        -verbose-autoreconf|--verbose-autoreconf)
            autoreconf_args="-vif"
230
            export autoreconf_args
231
232
            ;;

233
234
235
236
237
238
239
	-with-genstates|--with-genstates)
	    do_genstates=yes
	    ;;

	-without-genstates|--without-genstates)
	    do_genstates=no
	    ;;
240
 
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
	-with-errmsgs|--with-errmsgs)
	    do_geterrmsgs=yes
	    ;;

	-without-errmsgs|--without-errmsgs)
	    do_geterrmsgs=no
	    ;;

	-with-bindings|--with-bindings)
	    do_bindings=yes
	    ;;

	-without-bindings|--without-bindings)
	    do_bindings=no
	    ;;

	-with-f77|--with-f77)
	    do_f77=yes
	    ;;

	-without-f77|--without-f77)
	    do_f77=no
	    ;;

	-with-autotools=*|--with-autotools=*)
	    autotoolsdir=`echo "A$arg" | sed -e 's/.*=//'`
	    ;;

	-help|--help|-usage|--usage)
	    cat <<EOF
271
   ./autogen.sh [ --with-autotools=dir ] \\
272
273
                [ -atdircheck=[yes|no] ] \\
                [ -atvercheck=[yes|no] ] \\
274
                [ --verbose-autoreconf ] \\
275
                [ --do=stepname ] [ -distrib ]
276
    Update the files in the MPICH build tree.  This file builds the 
277
278
    configure files, creates the Makefile.in files, extracts the error
    messages.
279

280
281
    You can use --with-autotools=dir to specify a directory that
    contains alternate autotools.
282

283
284
    -atdircheck=[yes|no] specifies the enforcement of all autotools
    should be installed in the same directory.
285

286
287
    -atvercheck=[yes|no] specifies if the check for the version of 
    autotools should be carried out.
288

289
290
291
292
    -distrib creates a distribution version of the Makefile.in files (no
    targets for updating the Makefile.in from Makefile.sm or rebuilding the
    autotools targets).  This does not create the configure files because
    some of those depend on rules in the Makefile.in in that directory.  
293
    Thus, to build all of the files for a distribution, run autogen.sh
294
    twice, as in 
295
         autogen.sh && autogen.sh -distrib
296

297
298
299
    Use --do=stepname to update only a single step.  For example, 
    --do=build_configure only updates the configure scripts.  The available
    steps are:
300
EOF
301
302
303
304
305
306
307
	    for step in $AllSteps ; do
		echo "        $step"
	    done
	    exit 1
	    ;;

	*)
308
309
	    echo "unknown argument $arg"
	    exit 1
310
311
	    ;;

312
313
    esac
done
314

315
316
317
318
319
########################################################################
## Check for the location of autotools
########################################################################

if [ -z "$autotoolsdir" ] ; then
320
    autotoolsdir=$MPICH_AUTOTOOLS_DIR
321
fi
322
323
324
325
326
327

if [ -n "$autotoolsdir" ] ; then
    if [ -x $autotoolsdir/autoconf -a -x $autotoolsdir/autoheader ] ; then
        autoconf=$autotoolsdir/autoconf
        autoheader=$autotoolsdir/autoheader
        autoreconf=$autotoolsdir/autoreconf
328
        automake=$autotoolsdir/automake
329
        autom4te=$autotoolsdir/autom4te
330
        aclocal=$autotoolsdir/aclocal
331
332
333
334
335
        if [ -x "$autotoolsdir/glibtoolize" ] ; then
            libtoolize=$autotoolsdir/glibtoolize
        else
            libtoolize=$autotoolsdir/libtoolize
        fi
336

337
338
	AUTOCONF=$autoconf
	AUTOHEADER=$autoheader
339
        AUTORECONF=$autoreconf
340
        AUTOMAKE=$automake
341
	AUTOM4TE=$autom4te
342
343
344
        ACLOCAL=$aclocal
        LIBTOOLIZE=$libtoolize

345
346
	export AUTOCONF
	export AUTOHEADER
347
        export AUTORECONF
348
        export AUTOM4TE
349
350
351
        export AUTOMAKE
        export ACLOCAL
        export LIBTOOLIZE
352
    else
353
        echo "could not find executable autoconf and autoheader in $autotoolsdir"
354
355
356
357
358
	exit 1
    fi
else
    autoconf=${AUTOCONF:-autoconf}
    autoheader=${AUTOHEADER:-autoheader}
359
    autoreconf=${AUTORECONF:-autoreconf}
360
    autom4te=${AUTOM4TE:-autom4te}
361
362
    automake=${AUTOMAKE:-automake}
    aclocal=${ACLOCAL:-aclocal}
363
    if test -z "${LIBTOOLIZE+set}" && ( glibtoolize --version ) >/dev/null 2>&1 ; then
364
365
366
367
        libtoolize=glibtoolize
    else
        libtoolize=${LIBTOOLIZE:-libtoolize}
    fi
368
fi
369

Anthony Chan's avatar
Anthony Chan committed
370
371
372
ProgHomeDir $autoconf   autoconfdir
ProgHomeDir $automake   automakedir
ProgHomeDir $libtoolize libtooldir
373
374
375
376

echo_n "Checking if autotools are in the same location... "
if [ "$autoconfdir" = "$automakedir" -a "$autoconfdir" = "$libtooldir" ] ; then
    same_atdir=yes
377
    echo "yes, all in $autoconfdir"
378
379
else
    same_atdir=no
380
381
382
383
384
    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.
385
386
    warn "Autotools are in different locations. In rare occasion,"
    warn "resulting configure or makefile may fail in some unexpected ways."
387
fi
388

389
390
391
392
393
########################################################################
## 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
########################################################################
394

395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# 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 <libtool's m4 dir> 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
456

457
458
459
460
########################################################################
## Verify autoconf version
########################################################################

461
echo_n "Checking for autoconf version... "
462
463
recreate_tmp
ver=2.67
464
# petsc.mcs.anl.gov's /usr/bin/autoreconf is version 2.65 which returns OK
465
# if configure.ac has AC_PREREQ() withOUT AC_INIT.
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
#
# ~/> 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
481
cat > .tmp/configure.ac<<EOF
482
AC_INIT
483
AC_PREREQ($ver)
484
AC_OUTPUT
485
EOF
486
if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then
487
    echo ">= $ver"
488
else
489
    echo "bad autoconf installation"
490
    cat <<EOF
491
492
You either do not have autoconf in your path or it is too old (version
$ver or higher required). You may be able to use
493

494
     autoconf --version
495
496
497
498

Unfortunately, there is no standard format for the version output and
it changes between autotools versions.  In addition, some versions of
autoconf choose among many versions and provide incorrect output).
499
EOF
500
501
502
503
504
505
506
507
    exit 1
fi


########################################################################
## Verify automake version
########################################################################

508
echo_n "Checking for automake version... "
509
recreate_tmp
510
ver=1.12.3
511
cat > .tmp/configure.ac<<EOF
512
513
514
AC_INIT(testver,1.0)
AC_CONFIG_AUX_DIR([m4])
AC_CONFIG_MACRO_DIR([m4])
515
m4_ifdef([AM_INIT_AUTOMAKE],,[m4_fatal([AM_INIT_AUTOMAKE not defined])])
516
AM_INIT_AUTOMAKE([$ver foreign])
517
AC_MSG_RESULT([A message])
518
AC_OUTPUT([Makefile])
519
520
521
522
EOF
cat <<EOF >.tmp/Makefile.am
ACLOCAL_AMFLAGS = -I m4
EOF
523
if [ ! -d .tmp/m4 ] ; then mkdir .tmp/m4 >/dev/null 2>&1 ; fi
524
if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then
525
    echo ">= $ver"
526
else
527
528
529
530
531
532
533
534
535
536
537
538
    echo "bad automake installation"
    cat <<EOF
You either do not have automake in your path or it is too old (version
$ver or higher required). You may be able to use

     automake --version

Unfortunately, there is no standard format for the version output and
it changes between autotools versions.  In addition, some versions of
autoconf choose among many versions and provide incorrect output).
EOF
    exit 1
539
fi
540

541
542
543
544
545

########################################################################
## Verify libtool version
########################################################################

546
echo_n "Checking for libtool version... "
547
recreate_tmp
548
ver=2.4
549
550
551
552
cat <<EOF >.tmp/configure.ac
AC_INIT(testver,1.0)
AC_CONFIG_AUX_DIR([m4])
AC_CONFIG_MACRO_DIR([m4])
553
m4_ifdef([LT_PREREQ],,[m4_fatal([LT_PREREQ not defined])])
554
LT_PREREQ($ver)
555
LT_INIT()
556
557
558
559
560
AC_MSG_RESULT([A message])
EOF
cat <<EOF >.tmp/Makefile.am
ACLOCAL_AMFLAGS = -I m4
EOF
561
if [ ! -d .tmp/m4 ] ; then mkdir .tmp/m4 >/dev/null 2>&1 ; fi
562
if (cd .tmp && $autoreconf $autoreconf_args >/dev/null 2>&1 ) ; then
563
    echo ">= $ver"
564
else
565
566
567
568
569
570
571
572
573
574
575
576
    echo "bad libtool installation"
    cat <<EOF
You either do not have libtool in your path or it is too old
(version $ver or higher required). You may be able to use

     libtool --version

Unfortunately, there is no standard format for the version output and
it changes between autotools versions.  In addition, some versions of
autoconf choose among many versions and provide incorrect output).
EOF
    exit 1
577
578
fi

579

580
581
582
583
########################################################################
## Checking for UNIX find
########################################################################

584
echo_n "Checking for UNIX find... "
585
find . -name 'configure.ac' > /dev/null 2>&1
586
587
588
589
590
591
592
593
594
if [ $? = 0 ] ; then
    echo "done"
else
    echo "not found (error)"
    exit 1
fi


########################################################################
595
## Checking if xargs rm -rf works
596
597
########################################################################

598
599
600
echo_n "Checking if xargs rm -rf works... "
if [ -d "`find . -name __random_dir__`" ] ; then
    error "found a directory named __random_dir__"
601
602
    exit 1
else
603
604
    mkdir __random_dir__
    find . -name __random_dir__ | xargs rm -rf > /dev/null 2>&1
605
    if [ $? = 0 ] ; then
606
	echo "yes"
607
    else
608
609
	echo "no (error)"
	rm -rf __random_dir__
610
611
612
613
614
615
616
617
618
619
620
621
622
	exit 1
    fi
fi



echo
echo
echo "###########################################################"
echo "## Autogenerating required files"
echo "###########################################################"
echo

623
624
625
626
627
628
629
630
631
632
633
634
635
636
########################################################################
## 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

637
638
639
640
########################################################################
## Building the README
########################################################################

641
echo_n "Updating the README... "
642
. ./maint/Version
643
if [ -f README.vin ] ; then
644
    sed -e "s/%VERSION%/${MPICH_VERSION}/g" README.vin > README
645
646
647
    echo "done"
else
    echo "error"
648
    error "README.vin file not present, unable to update README version number (perhaps we are running in a release tarball source tree?)"
649
650
651
652
653
654
655
656
fi


########################################################################
## Update SMPD version
########################################################################

if [ "$do_smpdversion" = yes ] ; then
657
    echo_n "Creating src/pm/smpd/smpd_version.h... "
658
    smpdVersion=${MPICH_VERSION}
659
660
661
662
663
664
665
666
    cat >src/pm/smpd/smpd_version.h <<EOF
/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*  
 *  (C) 2005 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */
#define SMPD_VERSION "$smpdVersion"
EOF
667
    echo "done"
668
669
fi

670
671
672
673
674
675
676
677
########################################################################
## Building subsys_include.m4
########################################################################
if [ "X$do_subcfg_m4" = Xyes ] ; then
    echo_n "Creating subsys_include.m4... "
    ./maint/gen_subcfg_m4
    echo "done"
fi
678
679
680
681
682

########################################################################
## Building non-C interfaces
########################################################################

683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
# Create the bindings if necessary 
if [ $do_bindings = "yes" ] ; then
    build_f77=no
    build_f90=no
    build_cxx=no
    if [ $do_f77 = "yes" ] ; then
        if [ ! -s src/binding/f77/abortf.c ] ; then 
	    build_f77=yes
        elif find src/binding/f77 -name 'buildiface' -newer 'src/binding/f77/abortf.c' >/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
703
	echo_n "Building Fortran 77 interface... "
704
	( cd src/binding/f77 && chmod a+x ./buildiface && ./buildiface )
705
	echo "done"
706
707
    fi
    if [ $build_f90 = "yes" ] ; then
708
	echo_n "Building Fortran 90 interface... "
709
710
711
	# 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
712
713
	( cd src/binding/f90 && chmod a+x ./buildiface && ./buildiface )
	( cd src/binding/f90 && ../f77/buildiface -infile=cf90t.h -deffile=cf90tdefs)
714
	echo "done"
715
716
717
718
719
720
721
722
    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
723
	echo_n "Building C++ interface... "
724
725
	( cd src/binding/cxx && chmod a+x ./buildiface &&
	  ./buildiface -nosep $otherarg )
726
	echo "done"
727
728
    fi
fi
729
730
731
732
733
734


########################################################################
## Extract error messages
########################################################################

735
736
737
# Capture the error messages
if [ $do_geterrmsgs = "yes" ] ; then
    if [ -x maint/extracterrmsgs ] ; then
738
        echo_n "Extracting error messages... "
739
740
741
742
743
744
745
        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)
746
747
	echo "done"

748
749
750
751
752
753
        update_errdefs=yes
        if [ -s .err ] ; then 
            cat .err
            rm -f .err2
            grep -v "Warning:" .err > .err2
            if [ -s .err2 ] ; then
754
755
                warn "Because of errors in extracting error messages, the file"
                warn "src/mpi/errhan/defmsg.h was not updated."
756
757
758
		error "Error message files in src/mpi/errhan were not updated."
   	        rm -f .tmp .err .err2
		exit 1
759
760
761
762
763
764
765
            fi
            rm -f .err .err2
        else
            # Incase it exists but has zero size
            rm -f .err
        fi
	if [ -s unusederr.txt ] ; then
766
767
	    warn "There are unused error message texts in src/mpi/errhan/errnames.txt"
	    warn "See the file unusederr.txt for the complete list"
768
769
770
771
772
        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
773
            echo_n "Creating a dummy defmsg.h file... "
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
	    cat > src/mpi/errhan/defmsg.h <<EOF
typedef struct { const unsigned int sentinal1; const char *short_name, *long_name; const unsigned int sentinal2; } msgpair;
static const int generic_msgs_len = 0;
static msgpair generic_err_msgs[] = { {0xacebad03, 0, "no error catalog", 0xcb0bfa11}, };
static const int specific_msgs_len = 0;
static msgpair specific_err_msgs[] = {  {0xacebad03,0,0,0xcb0bfa11}, };
#if MPICH_ERROR_MSG_LEVEL > 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
791
	    echo "done"
792
793
794
        fi
    fi
fi  # do_geterrmsgs
795
796
797
798
799
800
801
802
803


########################################################################
## Build required scripts
########################################################################

echo
echo "------------------------------------"
echo "Initiating building required scripts"
804
805
# Build scripts such as genstates if necessary
ran_maint_configure=no
806
run_configure=no
807
808
# The information that autoconf uses is saved in the autom4te*.cache
# file; since this cache is not accurate, we delete it.
809
810
if [ ! -x maint/configure ] ; then
    (cd maint && $autoconf && rm -rf autom4te*.cache )
811
elif find maint -name 'configure.ac' -newer 'maint/configure' >/dev/null 2>&1 ; then
812
813
814
    # The above relies on the Unix find command
    (cd maint && $autoconf && rm -rf autom4te*.cache)
fi
815
if [ ! -x maint/genstates ] ; then
816
817
    run_configure=yes
fi
818

819
820
821
822
823
824
825
826
827
828
829
# 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)
830
    ran_maint_configure=yes
831
fi
832
833
834
echo "Done building required scripts"
echo "------------------------------------"
echo
835
836

# Run some of the simple codes
837
echo_n "Creating the enumeration of logging states into src/include/mpiallstates.h... "
838
if [ -x maint/extractstates -a $do_genstates = "yes" ] ; then
839
    ./maint/extractstates
840
fi
841
842
echo "done"

843
# new parameter code
844
echo_n "Generating parameter handling code... "
845
if test -x maint/genparams -a "$do_getparms" = "yes" ; then
846
847
848
849
850
851
852
    if ./maint/genparams ; then
        echo "done"
    else
        echo "failed"
        error "unable to generate parameter handling code"
        exit 1
    fi
853
854
else
    echo "skipped"
855
fi
856

857
858
# Create and/or update the f90 tests
if [ -x ./maint/f77tof90 -a $do_f77tof90 = "yes" ] ; then
859
    echo_n "Create or update the Fortran 90 tests derived from the Fortran 77 tests... "
860
861
862
863
864
865
    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
866
        maint/f77tof90 $dir test/mpi/f90/$leafDir Makefile.am Makefile.ap
867
        echo "timestamp" > test/mpi/f90/$leafDir/Makefile.am-stamp
868
    done
869
870
871
872
873
874
875
876
877
    for dir in test/mpi/errors/f77/* ; do
        if [ ! -d $dir ] ; then continue ; fi
	leafDir=`basename $dir`
        if [ ! -d test/mpi/errors/f90/$leafDir ] ; then
	    mkdir test/mpi/errors/f90/$leafDir
        fi
        maint/f77tof90 $dir test/mpi/errors/f90/$leafDir Makefile.am Makefile.ap
        echo "timestamp" > test/mpi/errors/f90/$leafDir/Makefile.am-stamp
    done
878
    echo "done"
879
fi
880
881
882
883

echo
echo
echo "###########################################################"
884
echo "## Generating configure files"
885
886
887
888
889
890
891
892
echo "###########################################################"
echo

########################################################################
## Running autotools on non-simplemake directories
########################################################################

if [ "$do_build_configure" = "yes" ] ; then
893
894
    for external in $externals ; do
       if [ -d "$external" -o -L "$external" ] ; then
895
896
           echo "------------------------------------------------------------------------"
           echo "running third-party initialization in $external"
897
898
899
900
           (cd $external && ./autogen.sh) || exit 1
       fi
    done

901
902
    for amdir in $amdirs ; do
	if [ -d "$amdir" -o -L "$amdir" ] ; then
903
	    echo "------------------------------------------------------------------------"
904
	    echo "running $autoreconf in $amdir"
905
            (cd $amdir && $autoreconf $autoreconf_args) || exit 1
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
            # Patching libtool.m4
            # This works with libtool versions 2.4 - 2.4.2.
            # Older versions are not supported to build mpich.
            # Newer versions should have this patch already included.
            # There is no need to patch if we're not going to use Fortran.
            if [ $do_bindings = "yes" ] ; then
                if [ -f $amdir/confdb/libtool.m4 ] ; then
                    echo_n "Patching libtool.m4 for compatibility with nagfor shared libraries... "
                    patch --forward -s -l $amdir/confdb/libtool.m4 maint/libtool.m4.patch
                    if [ $? -eq 0 ] ; then
                        echo "done"
                        # Remove possible leftovers, which don't imply a failure
                        rm -f $amdir/confdb/libtool.m4.orig
                        # Reset libtool.m4 timestamps to avoid confusing make
                        touch $amdir/confdb/libtool.m4 -r $amdir/confdb/ltversion.m4
                    else
                        echo "failed"
                    fi
                fi
            fi
926
927
	fi
    done
928
fi