1dlvl = ../..
2include $(dlvl)/Bmake.inc
3
4#  --------------------------
5#  The communication routines
6#  --------------------------
7comm = igesd2d_.o sgesd2d_.o dgesd2d_.o cgesd2d_.o zgesd2d_.o \
8       itrsd2d_.o strsd2d_.o dtrsd2d_.o ctrsd2d_.o ztrsd2d_.o \
9       igerv2d_.o sgerv2d_.o dgerv2d_.o cgerv2d_.o zgerv2d_.o \
10       itrrv2d_.o strrv2d_.o dtrrv2d_.o ctrrv2d_.o ztrrv2d_.o \
11       igebs2d_.o sgebs2d_.o dgebs2d_.o cgebs2d_.o zgebs2d_.o \
12       igebr2d_.o sgebr2d_.o dgebr2d_.o cgebr2d_.o zgebr2d_.o \
13       itrbs2d_.o strbs2d_.o dtrbs2d_.o ctrbs2d_.o ztrbs2d_.o \
14       itrbr2d_.o strbr2d_.o dtrbr2d_.o ctrbr2d_.o ztrbr2d_.o \
15       igsum2d_.o sgsum2d_.o dgsum2d_.o cgsum2d_.o zgsum2d_.o \
16       igamx2d_.o sgamx2d_.o dgamx2d_.o cgamx2d_.o zgamx2d_.o \
17       igamn2d_.o sgamn2d_.o dgamn2d_.o cgamn2d_.o zgamn2d_.o
18
19#  -----------------------------------------------------------------------------
20#  These names are too long for the archiver to distinguish based on the suffix.
21#  I'm going to use logical links to get around this problem.  It's hokey, but
22#  it lets us use the suffix rule and keep the makefile portable.
23#  -----------------------------------------------------------------------------
24long = blacs_gridinit_.o blacs_gridmap_.o blacs_freebuff_.o \
25       blacs_gridexit_.o blacs_gridinfo_.o blacs_barrier_.o \
26       sys2blacs_handle_.o free_blacs_system_handle_.o \
27       blacs2sys_handle_.o
28
29Clong = Cblacs_gridinit_.C Cblacs_gridmap_.C Cblacs_freebuff_.C \
30        Cblacs_gridexit_.C Cblacs_gridinfo_.C Cblacs_barrier_.C \
31        Csys2blacs_handle_.C Cfree_blacs_system_handle_.C \
32        Cblacs2sys_handle_.C
33
34#  --------------------
35#  The support routines
36#  --------------------
37supp = blacs_setup_.o blacs_set_.o blacs_get_.o \
38       blacs_abort_.o blacs_exit_.o blacs_pnum_.o blacs_pcoord_.o \
39       ksendid_.o krecvid_.o kbsid_.o kbrid_.o \
40       dcputime00_.o dwalltime00_.o
41
42#  ----------------------------
43#  The fortran and C interfaces
44#  ----------------------------
45Fintobj   = $(comm) $(supp) $(long)
46Cintobj   = $(comm:.o=.C) $(supp:.o=.C) $(Clong)
47
48#  ---------------------
49#  The internal routines
50#  ---------------------
51internal = BI_HypBS.o BI_HypBR.o BI_IdringBS.o BI_IdringBR.o \
52           BI_MpathBS.o BI_MpathBR.o BI_SringBS.o BI_SringBR.o \
53           BI_TreeBS.o BI_TreeBR.o \
54           BI_Ssend.o BI_Rsend.o BI_Srecv.o BI_Asend.o BI_Arecv.o \
55           BI_TreeComb.o BI_BeComb.o BI_MringComb.o \
56           BI_ArgCheck.o BI_TransDist.o BI_GetBuff.o BI_UpdateBuffs.o \
57           BI_EmergencyBuff.o BI_BlacsErr.o BI_BlacsWarn.o BI_BlacsAbort.o \
58           BI_BuffIsFree.o BI_imvcopy.o BI_smvcopy.o BI_dmvcopy.o \
59           BI_ivmcopy.o BI_svmcopy.o BI_dvmcopy.o \
60           BI_Pack.o BI_Unpack.o BI_GetMpiGeType.o BI_GetMpiTrType.o \
61           BI_ivvsum.o BI_svvsum.o BI_dvvsum.o BI_cvvsum.o BI_zvvsum.o \
62           BI_ivvamx.o BI_svvamx.o BI_dvvamx.o BI_cvvamx.o BI_zvvamx.o \
63           BI_ivvamx2.o BI_svvamx2.o BI_dvvamx2.o BI_cvvamx2.o BI_zvvamx2.o \
64           BI_ivvamn.o BI_svvamn.o BI_dvvamn.o BI_cvvamn.o BI_zvvamn.o \
65           BI_ivvamn2.o BI_svvamn2.o BI_dvvamn2.o BI_cvvamn2.o BI_zvvamn2.o \
66           BI_iMPI_amx.o BI_sMPI_amx.o BI_dMPI_amx.o BI_cMPI_amx.o \
67           BI_zMPI_amx.o BI_iMPI_amx2.o BI_sMPI_amx2.o BI_dMPI_amx2.o \
68           BI_cMPI_amx2.o BI_zMPI_amx2.o BI_iMPI_amn.o BI_sMPI_amn.o \
69           BI_dMPI_amn.o BI_cMPI_amn.o BI_zMPI_amn.o BI_iMPI_amn2.o \
70           BI_sMPI_amn2.o BI_dMPI_amn2.o BI_cMPI_amn2.o BI_zMPI_amn2.o \
71           BI_cMPI_sum.o BI_zMPI_sum.o BI_ContxtNum.o BI_GlobalVars.o \
72           BI_MPI_F77_to_c_trans_comm.o BI_MPI_C_to_f77_trans_comm.o \
73           BI_TransUserComm.o bi_f77_mpi_attr_get.o bi_f77_mpi_op_create.o \
74           bi_f77_mpi_initialized.o bi_f77_mpi_test.o bi_f77_mpi_testall.o \
75           bi_f77_get_constants.o bi_f77_init.o
76
77lib : all
78f77lib : flib
79F77lib : flib
80Clib : clib
81
82#  ---------------------------------------
83#  Make both C and fortran interface BLACS
84#  ---------------------------------------
85all : INTERN $(Fintobj) $(Cintobj)
86	rm -f $(BLACSFINIT) $(BLACSCINIT)
87	make $(BLACSFINIT)
88	make $(BLACSCINIT)
89	$(ARCH) $(ARCHFLAGS) $(BLACSLIB) $(Fintobj) $(Cintobj)
90	$(RANLIB) $(BLACSLIB)
91
92$(BLACSFINIT) :
93	$(CC) -o Cblacs_pinfo.o -c $(CCFLAGS) $(BLACSDEFS) -DCallFromC -DMainInF77 \
94                 blacs_pinfo_.c
95	$(CC) -c $(CCFLAGS) $(BLACSDEFS) -DMainInF77 blacs_pinfo_.c
96	$(ARCH) $(ARCHFLAGS) $(BLACSFINIT) blacs_pinfo_.o Cblacs_pinfo.o
97	$(RANLIB) $(BLACSFINIT)
98
99$(BLACSCINIT) :
100	$(CC) -o Cblacs_pinfo.o -c $(CCFLAGS) $(BLACSDEFS) -DCallFromC -DMainInC \
101                 blacs_pinfo_.c
102	$(CC) -c $(CCFLAGS) $(BLACSDEFS) -DMainInC blacs_pinfo_.c
103	$(ARCH) $(ARCHFLAGS) $(BLACSCINIT) blacs_pinfo_.o Cblacs_pinfo.o
104	$(RANLIB) $(BLACSCINIT)
105
106#  ------------------
107#  Make the internals
108#  ------------------
109INTERN :
110	( cd INTERNAL ; $(MAKE) -f ../Makefile I_int "dlvl=$(BTOPdir)" )
111
112I_int : Bdef.h Bconfig.h $(internal)
113	$(ARCH) $(ARCHFLAGS) $(BLACSLIB) $(internal)
114
115Bdef.h : ../Bdef.h
116	rm -f Bdef.h
117	ln -s ../Bdef.h Bdef.h
118
119Bconfig.h : ../Bconfig.h
120	rm -f Bconfig.h
121	ln -s ../Bconfig.h Bconfig.h
122
123#  -----------------------
124#  Delete the object files
125#  -----------------------
126clean :
127	rm -f $(Cintobj) $(Fintobj) $(long:.o=.C)
128	rm -f blacs_pinfo_.o Cblacs_pinfo.o
129	( cd INTERNAL ; rm -f bi_f77_get_constants.o bi_f77_mpi_attr_get.o \
130                              bi_f77_mpi_initialized.o bi_f77_mpi_op_create.o \
131                              bi_f77_mpi_test.o bi_f77_mpi_testall.o \
132                              bi_f77_init.o Bdef.h Bconfig.h mpif.h )
133	( cd INTERNAL ; rm -f $(internal) )
134
135#  -------------------------------------
136#  Delete the library, object and source
137#  -------------------------------------
138killib :
139	$(MAKE) clean
140	rm -f $(Fintobj:.o=.c) Bdef.h Bconfig.h
141	rm -f blacs_pinfo_.c
142	( cd INTERNAL ; rm -f $(internal:.o=.c) Bdef.h Bconfig.h )
143	( cd INTERNAL ; rm -f bi_f77_get_constants.f bi_f77_mpi_attr_get.f \
144                              bi_f77_mpi_initialized.f bi_f77_mpi_op_create.f \
145                              bi_f77_mpi_test.f bi_f77_mpi_testall.f mpif.h )
146
147#  -------------------------------------------------------------------------
148#  Establish how to make logical links to the long-name C interface routines
149#  that are distinct in first 13 characters from their Fortran interface
150#  equivalents.
151#  -------------------------------------------------------------------------
152Cblacs_gridinit_.C : blacs_gridinit_.C
153	rm -f Cblacs_gridinit_.C
154	ln -s blacs_gridinit_.C Cblacs_gridinit_.C
155Cblacs_gridinfo_.C : blacs_gridinfo_.C
156	rm -f Cblacs_gridinfo_.C
157	ln -s blacs_gridinfo_.C Cblacs_gridinfo_.C
158Cblacs_gridexit_.C : blacs_gridexit_.C
159	rm -f Cblacs_gridexit_.C
160	ln -s blacs_gridexit_.C Cblacs_gridexit_.C
161Cblacs_gridmap_.C : blacs_gridmap_.C
162	rm -f Cblacs_gridmap_.C
163	ln -s blacs_gridmap_.C Cblacs_gridmap_.C
164Cblacs_freebuff_.C : blacs_freebuff_.C
165	rm -f Cblacs_freebuff_.C
166	ln -s blacs_freebuff_.C Cblacs_freebuff_.C
167Cblacs_barrier_.C : blacs_barrier_.C
168	rm -f Cblacs_barrier_.C
169	ln -s blacs_barrier_.C Cblacs_barrier_.C
170Csys2blacs_handle_.C : sys2blacs_handle_.C
171	rm -f Csys2blacs_handle_.C
172	ln -s sys2blacs_handle_.C Csys2blacs_handle_.C
173Cblacs2sys_handle_.C : blacs2sys_handle_.C
174	rm -f Cblacs2sys_handle_.C
175	ln -s blacs2sys_handle_.C Cblacs2sys_handle_.C
176Cfree_blacs_system_handle_.C : free_blacs_system_handle_.C
177	rm -f Cfree_blacs_system_handle_.C
178	ln -s free_blacs_system_handle_.C Cfree_blacs_system_handle_.C
179
180#  -------------------------------------
181#  Compile the (ouch!) fortran internals
182#  -------------------------------------
183bi_f77_init.o : mpif.h bi_f77_init.f
184	$(F77) -c $(F77FLAGS) $*.f
185bi_f77_get_constants.o : mpif.h bi_f77_get_constants.f
186	$(F77) -c $(F77FLAGS) $*.f
187bi_f77_mpi_attr_get.o : mpif.h bi_f77_mpi_attr_get.f
188	$(F77) -c $(F77FLAGS) $*.f
189bi_f77_mpi_initialized.o : mpif.h bi_f77_mpi_initialized.f
190	$(F77) -c $(F77FLAGS) $*.f
191bi_f77_mpi_op_create.o : mpif.h bi_f77_mpi_op_create.f
192	$(F77) -c $(F77FLAGS) $*.f
193bi_f77_mpi_test.o : mpif.h bi_f77_mpi_test.f
194	$(F77) -c $(F77FLAGS) $*.f
195bi_f77_mpi_testall.o : mpif.h bi_f77_mpi_testall.f
196	$(F77) -c $(F77FLAGS) $*.f
197
198mpif.h : $(MPIINCdir)/mpif.h
199	rm -f mpif.h
200	ln -s $(MPIINCdir)/mpif.h mpif.h
201
202#  ------------------------------------------------------------------------
203#  We move C .o files to .C so that we can use the portable suffix rule for
204#  compilation, and still have them coexist with the fortran interface
205#  .o files.
206#  ------------------------------------------------------------------------
207.SUFFIXES: .o .C
208.c.C:
209	$(CC) -o C$*.o -c $(CCFLAGS) $(BLACSDEFS) -DCallFromC $<
210	mv C$*.o $*.C
211.c.o:
212	$(CC) -c $(CCFLAGS) $(BLACSDEFS) $<
213