1#  (C) 1993 by Argonne National Laboratory and Mississipi State University.
2#      All rights reserved.  See COPYRIGHT in top-level directory.
3#
4
5##### User configurable options #####
6
7top_srcdir           = @top_srcdir@
8
9CC                   = @CC@
10CC_SHL               = @CC_SHL@
11CLINKER              = @CLINKER@
12MPI_CC               = @MPI_CC@
13MPI_CLINKER          = $(MPI_CC)
14AR                   = @AR@
15ARFLAGS              = cr
16RANLIB               = @RANLIB@
17MAKE                 = @MAKE@
18MPI_CFLAGS           = @MPI_CFLAGS@
19MPI_LIBS             = @MPI_LIBS@
20INCLUDE_DIR          = -I.. -I${top_srcdir}/include \
21                       -I../../.. -I${top_srcdir}/../../include
22PROF_LIBNAME         = @PROF_LIBNAME@
23CFLAGS               = @CFLAGS@
24MPE_LIBDIR           = @libbuild_dir@
25LIB_PATH             = $(MPI_LIBS)
26LDFLAGS              = @LDFLAGS@
27MPI_IMPL             = @MPI_IMPL@
28MPE_BUILD_FORTRAN2C  = @MPE_BUILD_FORTRAN2C@
29MPEDBG               = @MPEDBG@
30CC_DOES_C_O          = @CC_DOES_C_O@
31
32### End User configurable options ###
33
34SHELL            = @SHELL@
35RM               = @RM@
36MV               = @MV@
37CP               = @CPRP@
38
39@VPATH@
40
41# Installation directories
42prefix           = @prefix@
43exec_prefix      = @exec_prefix@
44bindir           = @bindir@
45includedir       = @includedir@
46libdir           = @libdir@
47# Build directories
48libbuild_dir     = @libbuild_dir@
49binbuild_dir     = @binbuild_dir@
50srcdir           = @srcdir@
51
52EXECS            = dbxtest@EXEEXT@ dbxtest2@EXEEXT@
53
54# GETNAME_DEFS are needed by mpehname.c
55CC_FLAGS         = $(INCLUDE_DIR) $(CFLAGS) $(MPE_COPTS)
56CC_LDFLAGS       = $(LDFLAGS) $(CFLAGS) $(MPE_LDOPTS)
57# MPE include path, x_INCS, goes in front of MPI include path, MPI_xFLAGS,
58# in case MPI include path is in MPI_xFLAGS containing old MPE include path.
59MPICC_FLAGS      = $(INCLUDE_DIR) $(MPI_CFLAGS) $(MPE_COPTS)
60MPICC_LDFLAGS    = $(LDFLAGS) $(MPI_CFLAGS) $(MPE_LDOPTS)
61
62MPE_CSOURCES     = decomp.c mpe_seq.c dbxerr.c getgrank.c \
63                   examine.c privtags.c mpehname.c mpe_io.c
64# MPE_TSOURCES     = decomp.c mpe_seq.c dbxerr.c getgrank.c
65MPE_P_COBJECTS   = $(MPE_CSOURCES:.c=.p@OBJEXT@)
66# MPE_N_COBJECTS   = $(MPE_CSOURCES:.c=.n@OBJEXT@)
67
68MPE_WSOURCES     = decompf.c mpe_seqf.c getgrankf.c
69MPE_P_WOBJECTS   = $(MPE_WSOURCES:.c=.p@OBJEXT@)
70# MPE_N_WOBJECTS   = $(MPE_WSOURCES:.c=.n@OBJEXT@)
71
72MPE_XSOURCES     = mpehname.c
73# MPE_P_XOBJECTS   = $(MPE_XSOURCES:.c=.p@OBJEXT@)
74MPE_N_XOBJECTS   = $(MPE_XSOURCES:.c=.n@OBJEXT@)
75
76MPE_SHLCOBJECTS  = $(MPE_COBJECTS:.@OBJEXT@=.lo)
77MPE_SHLWOBJECTS  = $(MPE_WOBJECTS:.@OBJEXT@=.lo)
78
79.SUFFIXES: .c .@OBJEXT@ .p@OBJEXT@ .n@OBJEXT@ .lo .a @EXEEXT@
80
81.c.p@OBJEXT@:
82	@if [ "$(CC_DOES_C_O)" = "yes" ]; then \
83	     cmd="$(MPI_CC) $(MPICC_FLAGS) -o $@ -c $<" ; \
84	 else \
85	     cmd="$(MPI_CC) $(MPICC_FLAGS) -c $< ; $(MV) $*.@OBJEXT@ $*.p@OBJEXT@" ; \
86	 fi ; \
87	 echo "$${cmd}" ; $${cmd}
88
89.c.n@OBJEXT@:
90	@if [ "$(CC_DOES_C_O)" = "yes" ]; then \
91	     cmd="$(CC) $(CC_FLAGS) -DMPE_NOMPI -o $@ -c $<" ; \
92	 else \
93	     cmd="$(CC) $(CC_FLAGS) -DMPE_NOMPI -c $< ; $(MV) $*.@OBJEXT@ $*.n@OBJEXT@" ; \
94	 fi ; \
95	 echo "$${cmd}" ; $${cmd}
96
97# Allow compilers that do not allow -o for renaming object files
98.c.lo:
99	$(CC_SHL) $(CC_FLAGS) -c $< $(INC_DIR)
100	@$(MV) $*.@OBJEXT@ $*.lo
101
102# default_all is the same as default, but without the RANLIB.  This
103# can speed up the build (ranlibs can take a LONG time).  profile_all
104# is the same, but for the profile library
105# **** Currently the same as default for simplicity ****
106default_all: default
107profile_all:
108
109#
110default:
111	$(MAKE) $(MAKEOPTS) mpe_debug_objs
112	$(MAKE) $(MAKEOPTS) ${libbuild_dir}/lib$(PROF_LIBNAME)_nompi.a
113	$(MAKE) $(MAKEOPTS) ${libbuild_dir}/lib$(PROF_LIBNAME).a
114
115#
116# This target will get compiled if the user specified --with-mpedbg option
117mpe_debug_objs:
118	@-if [ "$(MPEDBG)" = "yes" -a "$(MPI_IMPL)" = "MPICH" ] ; then \
119	    echo "Making MPICH's mpedbg" ;  \
120	    ( cd ../../../../src/env ; $(MAKE) $(MAKEOPTS) mpe_debug_objs ) ; \
121	fi
122
123#
124# It is tempting here to use ... libmpe.a($(MPE_OBJECTS)) as the dependency,
125# but this would require that all makes properly handle library dependencies.
126# Since makes that DO are the exception rather than the rule, we don't
127# use this form
128#
129# We've also had trouble with this.  Sometimes, under Solaris, the
130# first file in the dependency is built but not included with $?
131# This is clearly a bug in the make, since the determination of dependencies
132# is done once (e.g., a blip in the filesystem time can't be
133# responsible if make works as Sun documents it).  To fix this, we
134# add all the objects to the library, not just the "recent" ones.
135${libbuild_dir}/lib$(PROF_LIBNAME).a: $(MPE_P_COBJECTS)
136	$(AR) $(ARFLAGS) $@ $(MPE_P_COBJECTS)
137	@if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
138	     $(MAKE) $(MAKEOPTS) ${MPE_P_WOBJECTS} ; \
139	     $(AR) $(ARFLAGS) $@ ${MPE_P_WOBJECTS} ; \
140	 fi
141	$(RANLIB) $@
142
143${libbuild_dir}/lib$(PROF_LIBNAME)_nompi.a: $(MPE_N_XOBJECTS)
144	 $(AR) $(ARFLAGS) $@ $(MPE_N_XOBJECTS)
145	 $(RANLIB) $@
146
147dbxtest@EXEEXT@: dbxtest.p@OBJEXT@ ${libbuild_dir}/lib$(PROF_LIBNAME).a
148	$(CP) -f dbxtest.p@OBJEXT@ mpe2tmp.@OBJEXT@
149	$(MPI_CLINKER) $(MPICC_LDFLAGS) -o $@ mpe2tmp.@OBJEXT@ \
150	               -L${libbuild_dir} -l$(PROF_LIBNAME) $(MPI_LIBS)
151	@-$(RM) -f mpe2tmp.@OBJEXT@
152
153dbxtest2@EXEEXT@: dbxtest2.p@OBJEXT@
154	$(CP) -f dbxtest2.p@OBJEXT@ mpe2tmp.@OBJEXT@
155	$(MPI_CLINKER) $(MPICC_LDFLAGS) -o $@ mpe2tmp.@OBJEXT@ \
156	               $(LIB_PATH)
157	@-$(RM) -f mpe2tmp.@OBJEXT@
158
159#
160# Remove the old libraries before rebuilding (in case they came from another
161# architecture or are otherwise damaged)
162rmlib:
163	@-$(RM) -f ${libbuild_dir}/lib$(PROF_LIBNAME).a
164
165rmprog:
166	@-$(RM) -f $(EXECS)
167
168clean: rmprog
169	@-$(RM) -f *.*@OBJEXT@ ${srcdir}/*.*@OBJEXT@ *~ PI*
170
171distclean: clean rmlib
172	@-$(RM) -f Makefile dbxerr.c
173