File: Makefile.in

package info (click to toggle)
mpich 1.2.5.3-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 53,880 kB
  • ctags: 44,904
  • sloc: ansic: 260,029; cpp: 91,556; sh: 42,421; java: 33,448; makefile: 8,959; fortran: 4,601; tcl: 3,548; f90: 3,517; perl: 2,251; asm: 999; csh: 856
file content (751 lines) | stat: -rw-r--r-- 28,881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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
228
229
230
231
232
233
234
235
236
237
238
239
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# create Makefile from this file with configure script
##### User configurable options #####
ALL: mpi
LARCH       = @ARCH@
DEVICE      = @DEVICE@
COMM        = @COMM@
MPIR_HOME   = @MPIR_HOME@
INCLUDE_DIR = @INCLUDE_PATH@ -Impid/@DEVICE@ -Iinclude
PREFIX	    = @PREFIX@
MAKE        = @MAKE@
CPRP        = @CPRP@
RSHCOMMAND  = @RSHCOMMAND@
DEFAULT_MACHINE = @DEFAULT_MACHINE@
ROMIO       = @ROMIO@
BUILDCPP    = @buildcpp@
CPP_DIR     = @CPP_DIR@
NOF77	    = @NOF77@
NOMPE       = @NOMPE@
MPILIBNAME  = @MPILIBNAME@
FMPILIBNAME = f@MPILIBNAME@

AR          = @AR@
ARCMD       = @ARNAME@
RANLIB      = @RANLIB@
### End User configurable options ###

### Name of package and version (will be set with automake eventually) 
PACKAGE = mpich
VERSION = 1.2.4
### End of name of package and version

SHELL = /bin/sh

@VPATH@

MPIDIRS  = src/pt2pt src/env src/dmpi src/util src/context src/coll \
	   src/topol src/profile 
MPI2DIRS = src/misc2 src/external @MPI2OPTIONAL@
DIRS     = $(MPIDIRS) $(MPI2DIRS) mpid/$(DEVICE) \
	   examples examples/basic examples/test/pt2pt examples/test/coll \
	   examples/test/topol examples/test/context \
	   examples/test/env examples/test/profile examples/test \
	   examples/perftest src/infoexport
# 
# This is a list of the devices that are available
DEVICES  = mpid/ch2 \
	   mpid/ch_nx mpid/ch_p4 mpid/ch_p4mpd \
	   mpid/ch_mpl mpid/t3e mpid/ch_meiko mpid/ch_shmem \
	   mpid/globus mpid/globus2 mpid/ch_lfshmem \
	   mpid/ch_cenju3
# Change this in maint/maketar also
OTHERDEVICES  = mpid/ch_nx mpid/ch_p4 mpid/ch_p4mpd mpid/ch_mpl \
		mpid/ch_meiko mpid/ch_shmem mpid/ch_lfshmem mpid/t3e \
		mpid/globus mpid/ch_cenju3

# Installation directories
prefix           = @prefix@
exec_prefix      = @exec_prefix@
bindir           = @bindir@
includedir       = @includedir@
libdir           = @libdir@
# Build directories
libbuild_dir     = @libbuild_dir@
binbuild_dir     = @binbuild_dir@
includebuild_dir = @includebuild_dir@
top_srcdir       = @top_srcdir@
srcdir           = @srcdir@

# 
# Build the device FIRST in case the device include, used in mpiimpl.h, 
# needs to be built (e.g., ch_p4 device)
# We need MPI2DIRS for the Fortran interface, among other things
CODEDIRS = mpid/$(DEVICE) $(MPIDIRS) $(MPI2DIRS) 

#
# The order here was chosen to identify problems early in the build
# In particular, we try a linktest as soon as the libraries are available,
# with a second link test after the profiling libraries are built just to
# be sure that they still succeed.  There are "make clean"s around the 
# whole thing so that there is reduced danger of finding the "wrong" 
# object files .
#
# Notes on C++ interface:
# This is still incomplete.  In particular, there are a LOT of include
# files, including one name "config.h" in the C++ interface.  The
# C++ library is named libmpi++.a .
#	${top_srcdir}/makelinks
mpi: mkbuilddirs preinstall clean rmlib
	${MAKE} mpi-modules
	${MAKE} mpi-lib-test
	${MAKE} mpi-addons
	${MAKE} mpi-utils
	@echo '--->'
	@cat ${srcdir}/buildmsg
	@echo '---<'

# This target makes all of the code.  You can use this to avoid the "clean"
# step *when you are certain that it is ok*.  
# The ranlib in the romio step is there to ensure that ranlib with the
# appropriate options is used. (e.g., ranlib -c on MacOSX)
# The occasional "sleep 1" is used to work around a bug in make (!);
# this bug is related to the use of time-stamps in make, but is actually
# more subtle; the logic in many implementations of make (including gnumake)
# is not consistent with respect to the tests performed.  This can lead 
# one test deciding to build a file but another step to decide not to 
# include it in the subsequent step that is supposed to include everything 
# that was just built!
mpi-modules:
	$(MAKE) mpilib
	@if [ $(NOF77) = 0 ] ; then \
	    echo "Making Fortran interface" ; sleep 1 ; \
	    if cd src/fortran && $(MAKE) ; then : ; else exit 1 ; fi ; fi
	@if [ "@HAS_WEAK_SYMBOLS@" = 0  ] ; then \
	    $(MAKE) clean ; $(MAKE) profile ; fi
	@if [ $(ROMIO) = 1 -a -d romio ] ; then \
	    echo "making romio" ;  sleep 1 ; \
            if cd romio && $(MAKE) ; then \
	        ${RANLIB} $(libbuild_dir)/lib${MPILIBNAME}.a ;\
	    else exit 1 ; fi ; \
	fi
	@-if [ $(BUILDCPP) = 1 -a -d "${CPP_DIR}" ] ; then \
            echo "making C++ interface" ; sleep 1 ; \
	    $(MAKE) cpplib ; \
	fi
	@-if [ -s f90modules/Makefile -a "@NO_F90@" = 0 ] ; then \
	    echo "making Fortran 90 module for MPI" ; sleep 1 ; \
	    (cd f90modules && $(MAKE) ) ;\
	fi

# Use this target to test the libraries
mpi-lib-test:
	$(MAKE) profileliblink
	@echo "Testing that MPI applications can be linked..."
	$(MAKE) linktest

# Use this target for add-on features
mpi-addons:
	$(MAKE) mpelib        
	-@if [ "@SHAREDKIND@" != "ignore" ] ; then \
	$(MAKE) mpichsharelibs ; fi

# This target is for various utilities (mpirun, servers)
# Note that ch_p4 now invokes the device-dependent mpirun_setup script
mpi-utils:
	@rm -f ${binbuild_dir}/mpirun
	@if [ -x mpid/${DEVICE}/mpirun_setup ] ; then \
	    binbuild_dir=${binbuild_dir} ; libbuild_dir=${libbuild_dir} ; \
	    top_srcdir=${top_srcdir} ; srcdir=${srcdir} ; \
	    ( export binbuild_dir ; export libbuild_dir ; export top_srcdir ; \
	      MAKE="${MAKE}" ; export MAKE ; export srcdir ; \
	    mpid/${DEVICE}/mpirun_setup ; );\
	elif [ -x ${top_srcdir}/mpid/${DEVICE}/mpirun_setup ] ; then \
	    binbuild_dir=${binbuild_dir} ; libbuild_dir=${libbuild_dir} ; \
	    top_srcdir=${top_srcdir} ; srcdir=${srcdir} ; \
	    ( export binbuild_dir ; export libbuild_dir ; export top_srcdir ; \
	      MAKE="${MAKE}" ; export MAKE ; export srcdir ; \
	    ${top_srcdir}/mpid/${DEVICE}/mpirun_setup ; );\
	else \
	    ${MAKE} mpirun ; \
	fi    
	bin/mpicc -o ${binbuild_dir}/mpichversion ${top_srcdir}/util/mpichversion.c
	@rm -f ${binbuild_dir}/mpireconfig
	@$(MAKE) mpireconfig
	@$(MAKE) ./bin/mpiinstall

examples: ${binbuild_dir}/mpirun
	( cd examples && $(MAKE) default )

# 
# This is an experimental target.  We do only the libraries that we know 
# about.
# Note that we do *not* include the Fortran MPI_Init and its support 
# routines in the (C) shared libraries.  This is required for the Solaris
# shared libraries; if these files are not excluded, then the application
# will fail to link (even though no code even *references* the routines that 
# are used)!
#
# You will probably need to add @libbuild_dir@/shared to your LD_LIBRARY_PATH
# variable.  This value will need to be part of your environment, so that
# all programs will see it (including ones started on remote hosts).
#
# The ar at the end puts the Fortran MPI_Init and the routine that
# it calls to get getarg and iargc into a separate library.  This
# is needed for shared lib support
# Note that if there is no Fortran support, then we don't build the farg
# library
# One complication is when there are multiple Fortran libraries (the
# alternate Fortran support).  In that case, the routines are in 
# another file, conventionally libmpich-${compilername}.a
# The test on the filenames below simply prevents error messages
# when using these tests.
mpichsharelibs:
	@-( cd $(libbuild_dir) && \
	CC="$(CC)" ; export CC ; CLINKER="@CLINKER@" ; export CLINKER ; \
	for lib in lib${MPILIBNAME}.a libp${MPILIBNAME}.a \
            lib${FMPILIBNAME}.a ; do \
	    if [ -s $$lib ] ; then \
	      ${top_srcdir}/util/makesharedlib -exceptobjs="farg.o farg90.o initf.o" -lib=$$lib -kind=@SHAREDKIND@ ; \
	    fi ; \
	done ; \
        if [ $(NOF77) = 0 ] ; then \
	    if [ "@FLIBNAME@" != "@MPILIBNAME@" ] ; then \
	      ${top_srcdir}/util/makesharedlib -exceptobjs="farg.o farg90.o initf.o" -lib=lib@FLIBNAME@.a -kind=@SHAREDKIND@ ; \
	        ${ARCMD} x lib@FLIBNAME@.a farg.o initf.o 2>/dev/null ; \
	        ${AR} lib@FLIBNAME@farg.a farg.o initf.o ; \
	        rm -f farg.o initf.o ; \
	    else \
	        ${ARCMD} x lib${MPILIBNAME}.a farg.o initf.o 2>/dev/null ; \
	        if [ -s farg.o -a -s initf.o ] ; then \
	            ${AR} lib${MPILIBNAME}farg.a farg.o initf.o ; \
	            rm -f farg.o initf.o ; \
                fi ;\
	    fi ; \
	fi ; \
	)
	@if [ "@SHAREDKIND@" != "ignore" ] ; then \
	    echo "Testing that MPI applications can be linked with shared libs..." ;\
	    ( cd examples/test/pt2pt && MPICH_USE_SHLIB="yes" ; \
		export MPICH_USE_SHLIB ; ${MAKE} linktest ) ;\
	fi


mkbuilddirs:
	@$(top_srcdir)/util/mkdirs ${libbuild_dir} ${includebuild_dir} ${binbuild_dir} ${sysconfdir}

#
# Remove the - in the linktest because the linktest should abort the build
# when it fails.
linktest:
	@if [ $(NOF77) = 1 ] ; then \
	( cd examples/test/pt2pt && $(MAKE) linktest1 ) ; \
	else \
	( cd examples/test/pt2pt && $(MAKE) linktest ) ; \
	fi

testing:
	(cd examples/test && $(MAKE) testing)
#
# testing-boot is the same as testing except that mpichboot and mpichstop
# are executed around the test
testing-boot:
	(cd examples/test && $(MAKE) testing-boot )


#
# Make sure that a failure during the make causes the make to stop at 
# that point.  The "sleep 1" is used to work around a bug in make (!); 
# see the discussion above
#	${top_srcdir}/makelinks
mpilib: ${top_srcdir}/Makefile.in ${includebuild_dir}/mpichconf.h
	-@(cd mpid/@DEVICE@ && $(MAKE) setlinks)
	@for dir in $(CODEDIRS) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ; sleep 1 ; \
	  (cd $$dir && \
	  if [ "$$dir" = "mpid/@DEVICE@" ] ; then \
	      $(MAKE) default_all ; \
          elif [ $(NOF77) = 0 ] ; then \
              $(MAKE) default_all ; \
	  else $(MAKE) default_conly ; fi ; \
	  st=$$? ; if [ $$st != 0 ] ; then \
		echo "Exit status from make was $$st" ; fi ; exit $$st ) ;\
	  if [ $$? != 0 ] ; then exit 1 ; fi ; \
	  done
	-@(cd src/infoexport && $(MAKE) default_all )
	${RANLIB} $(libbuild_dir)/lib${MPILIBNAME}.a
	@if [ -w $(libbuild_dir)/lib${MPILIBNAME}++.a ] ; then \
		${RANLIB} $(libbuild_dir)/lib${MPILIBNAME}++.a ; fi

mpiflib: ${top_srcdir}/Makefile.in
	@echo "See src/fortran"

#
# This target is used to remove the libraries for this configuration; this
# can lead to better performance when rebuilding.
rmlib:
	rm -f $(libbuild_dir)/lib*.a 
	rm -f $(libbuild_dir)/shared/lib*.so*

#
# This is a special target for just the device part of the transport
# (used to speed builds for multiple Chameleon transport layers)
#
# WARNING: THIS DEPENDS ON THE ROUTINES IN MPIDIRS CALLING ROUTINES, NOT
# MACROS, FROM THE ADI.  THIS IS CURRENTLY THE CASE BUT MAY CHANGE
# 
# This uses the "default" entry instead of "default_all" because it is
# usually executed alone, and the RANLIB is needed at the end of this
# target anyway.
#
# Don't override MPE's includebuild_dir, libbuild_dir and binbuild_dir.
# MPE builds on its own set of build_dir's not those of MPICH. The targets
# built by MPE will be installed into MPICH's prefix  by mpeinstall during
# the final install.  The goal is to get MPICH encapulated from the details
# of MPE ( or at least as much as possible ).
# 
# In order not to force user to do a "make install" at the end of MPICH
# build, we need to make the build_dir's as complete as possible.  So a 
# "mpe/sbin/mpeinstall" is called to install MPE to the build_dir's right
# after MPE build. Then "${binbuild_dir}/mpicc -mpilog" will work at the
# end the build before doing a MPICH install.  If this is NOT a crucial
# requirement, simply delete the 2nd subsshell execution of mpeinstall.
# Everything, like mpeinstall, mpiinstall, .. , will still work the same.
# In that case, "mpicc -mpilog" will NOT be able to locate libmpe.a, etc
mpelib:
	@if [ $(NOMPE) = 0 ] ; then \
              echo "Making MPE Profiling Libraries" ; \
	      ( cd mpe && $(MAKE) ) ; if [ $$? != 0 ] ; then exit 1 ; fi ; \
	      ( MPE_TMP_PREFIX=`pwd` ; \
	        cd mpe && ./sbin/mpeinstall -prefix=$${MPE_TMP_PREFIX} ) ; \
	      echo "Finished making MPE Profiling Libraries" ; echo ; \
	  fi

# Grumble.  The mpichdev is supposed to be the subdirectory of the mpich
# home.
# Note that mpi.h expects to find an mpi++.h.  Create an empty one if 
# necessary, in both the final includedir and the topsrc/include directory
# (the C++ configure doesn't use the correct compiler test for mpi.h)
# The rm of mpi++.h when the -s test fails deletes mpi++.h ONLY when we've
# created a dummy with touch

# We also added a dummy mpi++.h.  However, the C++ build step both builds
# and tests, so it needs the *real* includes.  This is done by setting the
# CPPFLAGS to point to the MPI-2-C++/src build directory. During installation,
# these flags are (should be) reset.
#	@if [ ! -s $(includebuild_dir)/mpi++.h ] ; then \
#		touch $(includebuild_dir)/mpi++.h ; fi
#	@if [ ! -s include/mpi++.h ] ; then \
#		touch include/mpi++.h ; fi
#		if [ ! -s $(includedir)/mpi++.h ] ; then \
#		    rm -f $(includedir)/mpi++.h ; fi ; \
#	        if [ ! -s ../include/mpi++.h ] ; then \
#		    rm -f ../include/mpi++.h ; fi ; 

#
# If --with-profiling is specified, the generated library is libpmpi++.a, not
# libmpi++.a
cpplib:
	@if [ -d ${includebuild_dir}/mpi2c++ ] ; then \
	    if [ -f ${includebuild_dir}/mpi2c++/mpi2c++_config.h ] ; then \
	        rm -f ${includebuild_dir}/mpi2c++/mpi2c++_config.h ; \
            fi ; \
	fi
	@(cd ${CPP_DIR} && MAKE="$(MAKE)" ; export MAKE ; \
	rm -f config.cache ; \
	CXXFLAGS="" ; export CXXFLAGS ; \
	CXX="g++" ; export CXX ; \
	CC="@CC@" ; export CC ; \
	ldir=`echo $(libdir) | sed -e 's%$(MPIR_HOME)/%%g'` ; \
	if ${top_srcdir}/${CPP_DIR}/configure --with-mpich=.. \
			--with-libopt=" " \
			 --with-profiling \
			 --with-mpichbin=${binbuild_dir} \
			 --with-mpichlib=${libbuild_dir} \
			 --with-mpichsrc=${MPIR_HOME} @CXXENABLE@ \
			 --with-mpichlibname=${MPILIBNAME} \
	                 --with-mpichdev=$(libbuild_dir) ; then \
		$(MAKE) ; \
	fi ) 
	@if [ -f "${CPP_DIR}/src/libmpi++.a" ] ; then \
	cp -p ${CPP_DIR}/src/libmpi++.a $(libbuild_dir)/lib${MPILIBNAME}++.a ; \
	elif [ -f "${CPP_DIR}/src/libpmpi++.a" ] ; then \
	cp -p ${CPP_DIR}/src/libpmpi++.a $(libbuild_dir)/libp${MPILIBNAME}++.a ; fi 
	@if [ ! -d ${includebuild_dir}/mpi2c++ ] ; then \
		mkdir ${includebuild_dir}/mpi2c++ ; fi
	@if [ -d ${srcdir}/${CPP_DIR}/src/mpi2c++ ] ; then \
	    for file in ${srcdir}/${CPP_DIR}/src/mpi2c++/*.h ; do \
	        cp $$file ${includebuild_dir}/mpi2c++ ; done ; \
	    cp ${CPP_DIR}/src/mpi2c++/mpi2c++_config.h \
		${includebuild_dir}/mpi2c++ ; \
	else \
	    echo "Need install target for alternate cxx interface" ;\
	    for file in ${srcdir}/${CPP_DIR}/mpi*.h ; do \
		cp $$file ${includebuild_dir}/mpi2c++ ; done ; \
	    cp ${CPP_DIR}/mpicxxconf.h ${includebuild_dir}/mpi2c++ ;\
	fi

mpidevlib:
	(cd mpid/$(DEVICE) && $(MAKE) clean )
	@for dir in mpid/$(DEVICE) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir && $(MAKE) default) ;\
	  done

#
# This is mpilib, but with memory leak/usage debugging turned on.
# The command line switch -chmemdebug will enable leak reporting
# when MPI_Finalize is called.
mpilibdebug:
	@for dir in $(CODEDIRS) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir && \
	  $(MAKE) default_all MPIPROFILE="-DMPIR_DEBUG_MEM" ) ;\
	  (cd $$dir && $(MAKE) clean ; \
	  $(MAKE) profile_all MPIPROFILE="-DMPIR_DEBUG_MEM -DMPI_BUILD_PROFILING");\
	  done 
	${RANLIB} $(libbuild_dir)/lib${MPILIBNAME}.a
	${RANLIB} $(libbuild_dir)/libp${MPILIBNAME}.a
	@if [ -w $(libbuild_dir)/lib${MPILIBNAME}++.a ] ; then \
		${RANLIB} $(libbuild_dir)/lib${MPILIBNAME}++.a ; fi

# 
# We need to include the device here, so that the MPID symbols will be 
# defined in libpmpich.a (the best order of libs is -lmpich -lpmpich).
# Since we allow -lmpich *only*, we need the device files in both 
# libraries.  The directory list is the same as CODEDIRS
profile:
	@if [ "@HAS_WEAK_SYMBOLS@" = 0 ] ; then \
	  for dir in mpid/${DEVICE} $(MPIDIRS) $(MPI2DIRS) ; do \
	    echo " " ;\
	    echo making mpir in directory $$dir ;\
	    (cd $$dir && \
	    $(MAKE) profile_all MPIPROFILE="-DMPI_BUILD_PROFILING" ) ;\
	  done ; \
	  ${RANLIB} $(libbuild_dir)/libp${MPILIBNAME}.a ; \
	fi

#
# In some cases, we may not need to build a profiling library (if we can
# use weak symbols).  This ensures that users can always link with it, even
# if they don't need to.  Also, ROMIO may generate explicit profiling library
# routines, in that case the library will exist (but be small)
profileliblink:
	@if [ ! -s $(libbuild_dir)/libp${MPILIBNAME}.a ] ; then\
	  (cd $(libbuild_dir) && ln -s lib${MPILIBNAME}.a \
		libp${MPILIBNAME}.a ) ; \
	fi

#
# Make mpirun from mpirun.*.in
#
mpirun: ${binbuild_dir}/mpirun
# Substituting datadir and EXECER_DIR with $(MPIR_HOME)/util is wrong.  This
# places the machines file in the source directory in VPATH builds.  This will
# have to be fixed.
#
# If you change this, ALSO change it in the install target!

# We can't fill MPIRUNLIST with the output of a command that also uses 
# Makefile variables (sigh).
MPIRUNLIST = `test -s ${srcdir}/mpid/$(DEVICE)/mpirun.lst && cat ${srcdir}/mpid/$(DEVICE)/mpirun.lst || echo mpid/$(DEVICE)/mpirun.$(DEVICE).in`

${binbuild_dir}/mpirun: util/mpirun ${srcdir}/util/mpirun.args.in 
	-@for file in util/mpirun.args.in $(MPIRUNLIST) ; do \
	  bfile=`basename $$file .in` ; \
	  rm -f ${binbuild_dir}/$$bfile ; \
	  if test -f $$file ; then \
	    cp $$file $(binbuild_dir)/$$bfile ; \
	  else \
	    cp ${srcdir}/$$file $(binbuild_dir)/$$bfile ; \
	  fi ; \
	  chmod 775 $(binbuild_dir)/$$bfile ; \
	done ;
	-@for file in ${srcdir}/util/mpirun_dbg.* ; do \
	  bfile=`basename $$file .in` ; \
	  rm -f ${binbuild_dir}/$$bfile ; \
	  cp $$file  $(binbuild_dir)/$$bfile ; \
	  chmod 775 $(binbuild_dir)/$$bfile ; \
	done ;
	@cp util/mpirun ${binbuild_dir}
	-@if [ ! -x ${binbuild_dir}/tarch ] ; then \
	    cp ${top_srcdir}/bin/tarch ${binbuild_dir} ; \
	    cp ${top_srcdir}/bin/tdevice ${binbuild_dir} ; \
	fi

#
# If you change this, ALSO change it in the install target!
#	@-cp ${binbuild_dir}/mpireconfig config.status $(bindir)
mpireconfig: ${binbuild_dir}/mpireconfig config.status
${binbuild_dir}/mpireconfig: ${srcdir}/util/mpireconfig.in config.status
	-rm -f ${top_srcdir}/bin/mpireconfig.dat
	-rm -f ${binbuild_dir}/mpireconfig.dat
	@cat ${srcdir}/util/mpireconfig.in | \
		        sed -e "s%\#MPIR_HOME\#%$(MPIR_HOME)%g" \
			    -e "s%\#ARCH\#%$(LARCH)%g" \
			    -e "s%\#PREFIX\#%$(PREFIX)%g" \
			    -e "s%\#DEVICE\#%$(DEVICE)%g" \
			    -e "s%\#top_srcdir\#%$(top_srcdir)%g" \
			    -e "s%\#bindir\#%$(bindir)%g" \
			    -e "s%\#binbuild_dir\#%$(binbuild_dir)%g" \
				> \
		    ${binbuild_dir}/mpireconfig
	@chmod 775 ${binbuild_dir}/mpireconfig
	@sed -e 's%$$top_srcdir/$$file%$$file%g' \
	    -e 's%$$top_srcdir/$${file}%$${file}%g' \
		config.status > \
		${binbuild_dir}/mpireconfig.dat
	@-chmod 775 ${binbuild_dir}/mpireconfig.dat

#
# If you change this, ALSO change it in the install target!
#	-cp ${binbuild_dir}/chp4_servs $(bindir)
#	-cp util/chkserv $(bindir)
#	-cp util/chkmachine $(bindir)
# Note that we need to set the C compiler through an environment variable.
serv_p4 server:
	@if [ ! -d mpid/server ] ; then mkdir mpid/server ; fi
	@( cd mpid/server && rm -f config.cache ; \
	  CC="@CC@" ; export CC ; MAKE="${MAKE}" ; export MAKE ; \
	  ${top_srcdir}/mpid/server/configure ; $(MAKE) serv_p4 ; \
	  cp serv_p4 $(binbuild_dir) )
	@rm -f ${binbuild_dir}/chp4_servs
	@cat ${srcdir}/util/chp4_servs.in | \
	    sed -e "s%\#MPIR_HOME\#%$(MPIR_HOME)%g" \
		-e "s%\#DEFAULT_DEVICE\#%$(DEVICE)%g" \
		-e "s%\#RSHCOMMAND\#%$(RSHCOMMAND)%g" \
		-e "s%\#datadir\#%$(MPIR_HOME)/util/machines%g" \
		-e "s%\#bindir\#%$(binbuild_dir)%g" \
		-e "s%\#MPICH_JOBTYPE_REQUIRED\#%@MPICH_JOBTYPE_REQUIRED@%g" \
		-e "s%\#DEFAULT_MACHINE\#%$(DEFAULT_MACHINE)%g" \
		-e "s%\#DEFAULT_ARCH\#%$(LARCH)%g" > \
		    ${binbuild_dir}/chp4_servs ;\
	chmod 775 ${binbuild_dir}/chp4_servs
	-cp util/chkserv $(binbuild_dir)
	-cp util/chkmachine $(binbuild_dir)

#
# Changed clean to not remove the library, only the object files
#
# Also, it should not remove the "executables"
# We also do NOT clean util, since it has files (like mpicc) that are built
# by configure.  Builds with a new architecture
# should use make cleanslate
# We also remove the Makefile in nupshot after using it as it is created
# by the nupshot configure itself.
# We pass MAKE to the MPE Makefile to make sure that it has a valid
# version of make.  Since MPE is configured separately, it might have
# a make choice from a previous configuration.
# work.* are produced by the Intel ifc Fortran compiler.
clean:
	@-rm -f work.pc work.pcl
	@-for dir in tsuite bugs mpid/server mpid/mpd installtest \
		f90modules ; do \
	    if [ -d $$dir -a -s $$dir/Makefile ] ; then \
		(cd $$dir && $(MAKE) clean ) ; fi ; done
	@-if [ -d romio -a -s romio/Makefile -a "@ROMIO@" = 1 ] ; then \
	    (cd romio && $(MAKE) clean ) ; fi
	@-if [ -d "${CPP_DIR}" -a -s ${CPP_DIR}/Makefile -a "@buildcpp@" = 1 ] ; then \
	    (cd ${CPP_DIR} && $(MAKE) clean ) ; fi
	@-if [ -d mpe -a -s mpe/Makefile -a "@NOMPE@" = 0 ] ; then \
	    ( if [ -x $(binbuild_dir)/../sbin/mpeuninstall ] ; then \
	          $(binbuild_dir)/../sbin/mpeuninstall > /dev/null ; fi ) ; \
	    ( cd mpe && $(MAKE) MAKE="$(MAKE)" clean ) ; \
	  fi
	@-if [ -d src/fortran -a -s src/fortran/Makefile ] ; then \
	    (cd src/fortran && $(MAKE) clean ) ; fi
	@-for dir in $(DIRS) ;\
	  do \
	  if [ -s $$dir/Makefile ] ; then \
	  echo cleaning $$dir ;\
	  (cd $$dir && $(MAKE) clean ) ; fi ;\
	  done
	-@if [ -s mpid/ch_shmem/p2ptest/Makefile ] ; then \
	    echo "cleaning mpid/ch_shmem/p2ptest" ; \
	    (cd mpid/ch_shmem/p2ptest && $(MAKE) clean ) ; fi
	-@if [ -s mpid/tests/Makefile ] ; then \
	    (cd mpid/tests && $(MAKE) clean ) ; fi
cleanslate: clean
	(cd util && if [ -s Makefile ] ; then $(MAKE) clean ; fi )
#
# distclean removes mpirun etc as well as the libraries.
distclean: cleanslate
	-rm -f *~ *.ln bin/mpi* bin/upshot bin/jumpshot \
			    bin/startdaemons bin/tstmachines \
			    installtest/Makefile \
			    bin/clog* bin/logviewer bin/mperecofig* \
			    bin/slog_*
	-if [ -s util/Makefile ] ; then \
	    (cd util && rm -f chkmachine chkserv Makefile ) ; \
	    (cd util/machines && \
	    rm -f machines.IRIX* machines.sun* machines.solaris* \
	    machines.cray* machines.CRAY* machines.LINUX machines.rs600 \
	    machines.alpha machines.hp* ) ; fi
	-rm -f util/mympiinstall* util/mpichlib.conf
	-if [ -d mpid/server -a -s mpid/server/Makefile ] ; then \
	       (cd mpid/server && $(MAKE) distclean) ; fi
	-if [ -d jumpshot ] ; then \
	  rm -f jumpshot/confdefs.h jumpshot/config.log \
	  jumpshot/config.cache jumpshot/config.status ; fi
	-if [ -d mpe -a -s mpe/Makefile -a "@NOMPE@" = 0 ] ; then \
	    (cd mpe && $(MAKE) MAKE=$(MAKE) distclean ) ; fi
	-if [ -s f90modules/Makefile ] ; then \
	    (cd f90modules && $(MAKE) distclean ) ; fi
	-rm -f lib/*.[oa] lib/*.so.* lib/*.so lib/shared/* 
	-rm -rf lib
	-rm -rf include/f90choice include/f90base
	-rm -f include/mpidefs.h include/mpif.h include/mpif90.h \
		include/mpio.h include/mpichconf.h include/mpi_fortdefs.h \
		include/mpichconf.h.in include/mpif.f90
	-rm -rf include/mpi2c++
	-rm -f ID
	-for dir in $(DEVICES) ; do echo cleaning $$dir ; \
	   if [ -d $$dir ] ; then \
	     (cd $$dir && if [ -s Makefile ] ; then $(MAKE) distclean ; fi ) ; \
	   fi ; \
	done
	if [ -d mpid/tests -a -s mpid/tests/Makefile ] ; then \
	    (cd mpid/tests && $(MAKE) distclean ) ; fi
	if [ -s examples/perftest/Makefile ] ; then \
	    (cd examples/perftest && ${MAKE} distclean ) ; fi
	if [ -s romio/Makefile ] ; then \
	    (cd  romio && $(MAKE) cleanall ) ; fi
	-rm examples/test/io examples/io
	if [ -d "${CPP_DIR}" -a -s ${CPP_DIR}/Makefile -a "@buildcpp@" = 1 ] ; then \
	    (cd ${CPP_DIR} && $(MAKE) distclean ) ; fi
	for dir in $(DIRS) ;\
	  do \
	  echo removing Makefile in $$dir ;\
	  (cd $$dir && rm -f Makefile) ;\
	  done
	for dir in . coll context env profile pt2pt topol ; do \
	    if [ -s examples/test/$$dir/runtests ] ; then \
		rm -f examples/test/$$dir/runtests ; fi ; done
	if [ -s examples/test/config.status ] ; then \
	      rm -f examples/test/config.status ; fi
	if [ -s src/env/Makefile ] ; then \
	    rm -f src/env/mpehname.c  src/env/farg.f ; fi
	if [ -s src/fortran/Makefile ] ; then \
	    (cd src/fortran && ${MAKE} distclean ) ;  fi
	rm -f Makefile config.log config.status mpichconf.h
#
# Make an ID database from a suitable subset of the sources
# (Get mkid from sunsite if you want to use this)
#
ID: frc
	find include src/coll src/context src/dmpi src/env src/pt2pt \
		src/topol src/util src/infoexport \
	mpid/ch2 mpid/$(DEVICE) mpid/util -name "*.[hc]" -print | mkid -v -

frc:


## LOCAL START

maintainer: msgcat configure
msgcat: src/env/mpierrstrings.h
src/env/mpierrstrings.h: include/mpi_error.h \
	/home/MPI/maint/errmsgs/BaseErrMsgs.msg
	/home/MPI/maint/errmsgs/GetMsgCat
configure: configure.in aclocal.m4
	/home/MPI/maint/makeconfigs

## LOCAL END

INSTALLDIR = /usr/local/mpi
#
# The install target really needs to use some form of 'install' program that
# will create directories, set modes and owners, etc.  Alas, such a function
# is not standard (though autoconf-2 tries hard to find one).
# Note that clean removes mpirun (!) and mpiinstall (!) so we need to make
# sure that it is around before doing the install
# Make sure that we use our OWN copy of mpiinstall, because the created
# copy goes into the same directory as the source file.
# We also name it "mympiinstall" to ensure that we don't find the "wrong"
# directory
util/mympiinstall.in: ${top_srcdir}/util/mpiinstall.in
	@cp ${top_srcdir}/util/mpiinstall.in util/mympiinstall.in
./bin/mpiinstall: ${binbuild_dir}/mpireconfig util/mympiinstall.in
	@-(${binbuild_dir}/mpireconfig util/mympiinstall ; \
	rm -f ${binbuild_dir}/mpiinstall ; \
	sed -e 1d util/mympiinstall > ${binbuild_dir}/mpiinstall ; \
	chmod a+x ${binbuild_dir}/mpiinstall )

# Steps in preinstall:
# 1-Remove the old config.status and copy new one; this allows mpireconfig to
#   work with the current configuration.
# 2-Move the mpichconf.h file to where it will be used for the build.
#   Having it the final install directory allows us to see what was defined
# 3-Copy the scripts to the bindir
# 4-Copy mpidefs.h to includedir
# 5-Copy mpif.h to includedir
# Still to do: build mpif.h with MPICH and ROMIO contributions here.
# We do NOT use top_srcdir for the derived files, because they are created in 
# the current directory by configure
# These are done by configure for includebuild_dir.  includedir should be
# done only during installation
#	-cp include/mpidefs.h ${includedir}/mpidefs.h
#	-cp include/mpif.h ${includedir}/mpif.h
# We need to resurrect this for the actual install
#		true cp ${binbuild_dir}/$$file ${bindir}/$$file ;
#	rm -f ${binbuild_dir}/config.status 
#	cp config.status ${binbuild_dir}
preinstall:
	@cp mpichconf.h ${includebuild_dir}
	@cp ${top_srcdir}/mpichconf.h.in ${includebuild_dir}
	@for file in mpicc mpicxx mpif77 mpif90 mpiinstall mpiman ; do \
	    if test -s util/$$file ; then \
	        rm -f ${binbuild_dir}/$$file ; \
		mv util/$$file ${binbuild_dir}/$$file ;\
	    fi ;\
	done
	@if [ "@CASE_SENSITIVE@" = "no" ] ; then \
	    cp ${binbuild_dir}/mpicxx ${binbuild_dir}/mpiCC ; fi

${includebuild_dir}/mpichconf.h: mpichconf.h
	cp mpichconf.h ${includebuild_dir}

# Eventually, this should have preinstall as a source.
# Allow make install MPIINSTALL_OPTS=-noman
# Use the default prefix (no override) if possible; this 
# simplifies the use of --with-common-prefix
install: mpirun ./bin/mpiinstall
	@if [ ! -x ./bin/mpiinstall ] ; then echo "No mpiinstall script!" ; fi
	if [ "${PREFIX}" = "@PREFIX@" ] ; then \
	    ./bin/mpiinstall ${MPIINSTALL_OPTS} ; \
	else \
	    ./bin/mpiinstall -prefix=$(PREFIX) ${MPIINSTALL_OPTS} ; \
	fi

installlib: mpirun ./bin/mpiinstall
	if [ "${PREFIX}" = "@PREFIX@" ] ; then \
	   ./bin/mpiinstall -libonly -device=$(DEVICE) ; \
	else \
	   ./bin/mpiinstall -prefix=$(PREFIX) -libonly -device=$(DEVICE) ; \
	fi

#
# Install adds ALL of the examples to the installation area
# This is an initial version.
install-all: install
	(rm $(PREFIX)/examples/*)
	-$(CPRP) -r examples $(PREFIX)
	# Update the makefiles
	(cd $(PREFIX)/examples && \
		$(bindir)/mpireconfig Makefile ; \
		for dir in `find . -type d -print` ; do \
			(cd $$dir && \
			if [ -s Makefile.in ] ; then \
				$(bindir)/mpireconfig Makefile ; \
			fi ) ; \
		done \
	)

etags:
	etags include/*.h mpid/$(DEVICE)/*.h 
	for dir in ${CODEDIRS} ; do etags --append $$dir/*.c ; done

# This tags target builds in the current directory, not just the source
# directory.
TAGS:  
	tags=; \
	here=`pwd`; \
	(cd $(srcdir) && etags -o $$here/TAGS include/*.h mpid/${DEVICE}/*.h ;\
	for dir in ${CODEDIRS} ; do etags -o $$here/TAGS --append $$dir/*.c ;\
	done)