Update copyright to LGPL on all files
[dyninst.git] / dyninstAPI / tests / make.module.tmpl
1 #
2 # make.module.tmpl for dyninst test suite
3 # Not intended to be a seperate makefile, but to be used in conjunction with
4 # higher level, platform-specific makefiles in the build directories
5
6 RM = rm -f
7 RMDIR ?= rmdir
8 M_GCC ?= gcc
9 M_GXX ?= g++
10 DEPCC ?= gcc
11 DEPENDFLAGS ?= -MM -MT
12 DEPENDDIR = ./depends
13 VPATH   = ../src $(DEPENDDIR)
14
15 DYNINST_INCDIR = -I../../h
16 SYMTAB_INCDIR = -I../../../symtabAPI/h
17 INSTRUCTION_INCDIR = -I../../../instructionAPI/h
18 DYNUTIL_INCDIR = -I../../../dynutil/h
19
20 IFLAGS += $(DYNINST_INCDIR) 
21 IFLAGS += $(DYNUTIL_INCDIR) 
22 IFLAGS += $(SYMTAB_INCDIR) 
23 IFLAGS += $(INSTRUCTION_INCDIR)
24 CXXFLAGS += $(DYNINST_INCDIR) 
25 CXXFLAGS += $(DYNUTIL_INCDIR) 
26 CXXFLAGS += $(SYMTAB_INCDIR) 
27 CXXFLAGS += $(INSTRUCTION_INCDIR)
28 MUTATOR_CXXFLAGS += $(DYNINST_INCDIR) 
29 MUTATOR_CXXFLAGS += $(DYNUTIL_INCDIR)
30 MUTATOR_CXXFLAGS += $(SYMTAB_INCDIR)
31 MUTATOR_CXXFLAGS += $(INSTRUCTION_INCDIR)
32
33 #######################################################################
34 ###  Generate compiler id strings
35 ###
36 ###  COMPILERT_NATIVE_CC, COMPILERT_NATIVE_CXX must be defined prior to
37 ###  inclusion of this file.  gcc/g++ are handled here as platform-indep
38 ###
39 #######################################################################
40
41 EMPTY:=
42 BLANK:=$(EMPTY) $(EMPTY)
43 LPAREN:=(
44 RPAREN:=)
45 COMMA=,
46
47 COMPILERT_GCC = $(shell $(M_GCC) -v 2>&1 | grep version | head -1)
48 COMPILER1_GCC = $(subst $(BLANK),_,$(COMPILERT_GCC))
49 COMPILER2_GCC = $(subst $(LPAREN),_,$(COMPILER1_GCC))
50 COMPILER_GCC = $(subst $(RPAREN),_,$(COMPILER2_GCC))
51 MUTATEE_CFLAGS_GNU += -DCOMPILER='"$(COMPILER_GCC)"'
52
53 COMPILERT_GXX = $(shell $(M_GCC) -v 2>&1 | grep version | head -1)
54 COMPILER1_GXX = $(subst $(BLANK),_,$(COMPILERT_GXX))
55 COMPILER2_GXX = $(subst $(LPAREN),_,$(COMPILER1_GXX))
56 COMPILER_GXX = $(subst $(RPAREN),_,$(COMPILER2_GXX))
57 MUTATEE_CXXFLAGS_GNU += -DCOMPILER='"$(COMPILER_GXX)"'
58
59 COMPILER1_NATIVE_CC = $(subst $(BLANK),_,$(COMPILERT_NATIVE_CC))
60 COMPILER2_NATIVE_CC = $(subst $(LPAREN),_,$(COMPILER1_NATIVE_CC))
61 COMPILER_NATIVE_CC = $(subst $(RPAREN),_,$(COMPILER2_NATIVE_CC))
62 MUTATEE_CFLAGS_NATIVE += -DCOMPILER='"$(COMPILER_NATIVE_CC)"'
63
64 COMPILER1_NATIVE_CXX = $(subst $(BLANK),_,$(COMPILERT_NATIVE_CXX))
65 COMPILER2_NATIVE_CXX = $(subst $(LPAREN),_,$(COMPILER1_NATIVE_CXX))
66 COMPILER_NATIVE_CXX = $(subst $(RPAREN),_,$(COMPILER2_NATIVE_CXX))
67 MUTATEE_CXXFLAGS_NATIVE += -DCOMPILER='"$(COMPILER_NATIVE_CXX)"'
68
69 TEST_DEST = $(TO_CORE)/../$(PLATFORM)/testprogs
70
71 #######################################################################
72 ###  Basic definitions (filename prefixes)
73 #######################################################################
74
75 MUTATORS =      test1 \
76                 test2 \
77                 test3 \
78                 test4 \
79                 test5 \
80                 test6 \
81                 test7 \
82                 test8 \
83                 test9 \
84                 test10 \
85                 test12 \
86                 test13 \
87                 test14 \
88                 test15
89       
90
91 FORALL_MUTATORS = test_util
92
93 MUTATEES_C =    test1.mutatee \
94                 test2.mutatee \
95                 test3.mutatee \
96                 test4a.mutatee \
97                 test4b.mutatee \
98                 test6.mutatee \
99                 test7.mutatee \
100                 test8.mutatee \
101                 test9.mutatee \
102                 test10.mutatee \
103                 test12.mutatee \
104                 test13.mutatee \
105                 test14.mutatee \
106                 test15.mutatee 
107
108 # MUTATEES_CXX specifies a subset of MUTATEES_C that are also compiled with a C++ compiler
109 MUTATEES_CXX =  test1.mutatee \
110                 test2.mutatee \
111                 test3.mutatee \
112                 test4a.mutatee \
113                 test4b.mutatee \
114                 test7.mutatee \
115                 test8.mutatee \
116                 test9.mutatee \
117                 test12.mutatee \
118                 test13.mutatee \
119                 test14.mutatee \
120                 test15.mutatee
121
122 #  Most C mutatees are also compiled as C++ mutatees, there are some (well, one)
123 #  that are c++ only, which cannot also be compiled as C mutatees
124
125 MUTATEES_CXX_ONLY = test5.mutatee
126
127 MUTATEES_FORTRAN = test1.mutatee
128
129 FORALL_MUTATEES = mutatee_util
130
131 TESTLIB_STEMS   += libtestA libtestB libInstMe libLoadMe
132 TESTLIBS = $(addsuffix .so, $(TESTLIB_STEMS))
133
134 ifdef M_ABI
135 TESTLIBS_ABI = $(addsuffix _$(M_ABI).so, $(TESTLIB_STEMS))
136 endif
137
138 #######################################################################
139 ### Generated lists of source files
140 #######################################################################
141
142 # build source names from above prefixes
143 SRCS_MUTATORS           += $(addsuffix .C,$(MUTATORS))
144 SRCS_FORALL_MUTATORS    += $(addsuffix .C,$(FORALL_MUTATORS))
145
146 SRCS_MUTATEES_C         += $(addsuffix .c,$(MUTATEES_C))
147 SRCS_FORALL_MUTATEES    += $(addsuffix .c,$(FORALL_MUTATEES))
148 SRCS_MUTATEES_CXX       += $(addsuffix .c,$(MUTATEES_CXX))
149 SRCS_MUTATEES_CXX       += $(addsuffix .C,$(MUTATEES_CXX_ONLY))
150
151 #######################################################################
152 ###  Target file name list generation
153 #######################################################################
154
155 # build object/exec names from above prefixes
156
157 MUTATEES_GCC            += $(addsuffix _gcc,$(MUTATEES_C))
158 MUTATEES_GXX            += $(addsuffix _g++,$(MUTATEES_CXX))
159 MUTATEES_GXX            += $(addsuffix _g++,$(MUTATEES_CXX_ONLY))
160
161 ifdef M_ABI
162 MUTATEES_GCC_ABI        += $(addsuffix _gcc_$(M_ABI), $(MUTATEES_C))
163 MUTATEES_GXX_ABI        += $(addsuffix _g++_$(M_ABI), $(MUTATEES_CXX))
164 MUTATEES_GXX_ABI        += $(addsuffix _g++_$(M_ABI), $(MUTATEES_CXX_ONLY))
165
166 # Special Case: NASM does not produce x86_64 object files yet.
167 MUTATEES_GCC_ABI        := $(filter-out test6%, $(MUTATEES_GCC_ABI))
168 endif
169
170 ifdef M_G77
171 MUTATEES_G77            += $(addsuffix _g77,$(MUTATEES_FORTRAN))
172 endif
173
174 ifdef NATIVE_CC
175 MUTATEES_NATIVE_CC              += $(filter-out test10.mutatee_$(NATIVE_CC), $(addsuffix _$(NATIVE_CC),$(MUTATEES_C)))
176 endif
177
178 ifdef NATIVE_CXX
179 MUTATEES_NATIVE_CXX             += $(addsuffix _$(NATIVE_CXX),$(MUTATEES_CXX))
180 MUTATEES_NATIVE_CXX_ONLY        += $(addsuffix _$(NATIVE_CXX),$(MUTATEES_CXX_ONLY))
181 endif
182
183 ifdef NATIVE_FC
184 MUTATEES_NATIVE_FC              += $(addsuffix _$(NATIVE_FC),$(MUTATEES_FORTRAN))
185 endif
186
187 TEST6_AS_OBJ_GNU                = $(addsuffix .o,$(TEST6_AS_OBJ_BASE))
188 CALL35_1_OBJ                    = $(CALL35_1_SRC:call%.s=call%.o)
189
190 ifdef M_ABI
191 CALL35_1_OBJ_ABI                = $(CALL35_1_SRC_ABI:call%.s=call%.o)
192 endif
193
194 OBJS_FORALL_MUTATORS            = $(SRCS_FORALL_MUTATORS:%.C=%.o)
195
196 #######################################################################
197 ###  A list of all the targets we're building, for install purposes
198 #######################################################################
199
200 ALL_TARGETS                     = $(MUTATORS) $(MUTATEES_GCC) $(MUTATEES_GXX)
201 ALL_TARGETS                     += $(TESTLIBS)
202 ALL_TARGETS                     += test11
203 ALL_TARGETS                     += libTest12.so
204 ifdef M_ABI
205 ALL_TARGETS                     += $(MUTATEES_GCC_ABI) $(MUTATEES_GXX_ABI)
206 ALL_TARGETS                     += $(TESTLIBS_ABI)
207 endif
208 ifdef M_G77
209 ALL_TARGETS                     += $(MUTATEES_G77)
210 endif
211 ifdef NATIVE_CC
212 ALL_TARGETS                     += $(MUTATEES_NATIVE_CC)
213 endif
214 ifdef NATIVE_CXX
215 ALL_TARGETS                     += $(MUTATEES_NATIVE_CXX)
216 ALL_TARGETS                     += $(MUTATEES_NATIVE_CXX_ONLY)
217 endif
218 ifdef NATIVE_FC
219 ALL_TARGETS                     += $(MUTATEES_NATIVE_FC)
220 endif
221
222 ALL_TARGETS_DEST                = $(addprefix $(TEST_DEST)/,$(ALL_TARGETS))
223
224 #######################################################################
225 ###  Some pattern rules
226 #######################################################################
227
228
229 %_$(NATIVE_CC).o : %.c
230         $(NATIVE_CC) $(STD_NATIVE_ABI_FLAG) -c $< $(CFLAGS_NATIVE) $(MUTATEE_CFLAGS_NATIVE) -o $@
231 %_$(NATIVE_CXX).o : %.c
232         $(NATIVE_CXX) $(STD_NATIVE_ABI_FLAG) -c $< $(CXXFLAGS_NATIVE) $(MUTATEE_CXXFLAGS_NATIVE) -o $@
233
234 %_gcc.o: %.c
235         $(M_GCC) $(STD_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@
236 %_g++.o: %.c 
237         $(M_GXX) $(STD_ABI_FLAG) $(CXXFLAGS) $(MUTATEE_CXXFLAGS_GNU) -c $< -o $@
238 %_g++.o: %.C 
239         $(M_GXX) $(STD_ABI_FLAG) $(CXXFLAGS) $(MUTATEE_CXXFLAGS_GNU) -c $< -o $@
240
241 ifdef M_ABI
242 %_gcc_$(M_ABI).o: %.c
243         $(M_GCC) $(M_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@
244 %_g++_$(M_ABI).o: %.c 
245         $(M_GXX) $(M_ABI_FLAG) $(CXXFLAGS) $(MUTATEE_CXXFLAGS_GNU) -c $< -o $@
246 %_g++_$(M_ABI).o: %.C 
247         $(M_GXX) $(M_ABI_FLAG) $(CXXFLAGS) $(MUTATEE_CXXFLAGS_GNU) -c $< -o $@
248 endif
249
250
251
252 .C.o:
253         $(CXX) $(STD_ABI_FLAG) -c $< $(CXXFLAGS) $(MUTATOR_CXXFLAGS) -o $@
254
255 $(TEST_DEST)/%: %
256         -$(CP) $< $(TEST_DEST)
257
258 #######################################################################
259 ###  High level targets
260 #######################################################################
261
262 MUTATOR_LDFLAGS += -lsymtabAPI -ldyninstAPI -lcommon $(MUTATOR_LIBS) -lpthread -lstdc++
263
264
265 all: mutators testlibs mutatees 
266 echo:
267         @echo "DEPS TESTLIBS = $(DEPS_TESTLIBS)"
268         @echo "MUTATEES_NATIVE_CXX = $(MUTATEES_NATIVE_CXX)"
269
270 install: $(TEST_DEST) $(ALL_TARGETS_DEST)
271         @echo "install completed"
272
273 clean:
274         $(RM) *.da *.bb. *.bbg 
275         $(RM) $(TESTLIBS) $(TESTLIBS_ABI)
276         $(RM) libTest12.so
277         $(RM) $(MUTATORS) $(MUTATEES_GCC) $(MUTATEES_GXX) $(MUTATEES_GCC_ABI) $(MUTATEES_GXX_ABI) $(MUTATEES_G77) $(MUTATEES_GXX_ONLY)
278         $(RM) *.o $(MUTATEES_NATIVE_CC) $(MUTATEES_NATIVE_CXX) $(MUTATEES_NATIVE_FC) $(MUTATEES_NATIVE_CXX_ONLY)
279         $(RM) test11
280         $(RM) imagefile
281         $(RM) core core.*
282         $(RM) .__afs*
283
284 distclean: clean
285         @if [ -d $(DEPENDDIR) ]; then \
286           $(RM) $(DEPENDDIR)/*.dep; \
287           rmdir $(DEPENDDIR); \
288          fi
289
290 ifdef M_ABI
291 $(CALL35_1_OBJ_ABI): $(CALL35_1_SRC_ABI)
292         $(M_GCC) $(M_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@ 
293 endif
294
295 mutators: $(MUTATORS) test11
296 mutatees: gnu_mutatees native_mutatees
297 gnu_mutatees: $(MUTATEES_GCC) $(MUTATEES_GXX) $(MUTATEES_G77) $(MUTATEES_GCC_ABI) $(MUTATEES_GXX_ABI)
298 native_mutatees: $(MUTATEES_NATIVE_CC) $(MUTATEES_NATIVE_CXX) $(MUTATEES_NATIVE_FC) $(MUTATEES_NATIVE_CXX_ONLY)
299 testlibs: $(TESTLIBS) $(TESTLIBS_ABI) libTest12.so
300
301 .PHONY: clean install distclean mutators mutatees testlibs gnu_mutatees native_mutatees
302
303
304 # Despite the look, this isn't actually a pattern rule and so is
305 # defined _after_ all:
306 $(CALL35_1_OBJ): $(CALL35_1_SRC)
307         $(M_GCC) $(STD_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@ 
308 $(TEST6_AS_OBJ_GNU): $(TEST6_AS_SRC)
309         $(TEST6_AS_GNU) $(TEST6_ASFLAGS_GNU) -o $@ $<
310
311
312 #######################################################################
313 ###  Build command for test libraries
314 #######################################################################
315
316 $(TESTLIBS): %.so : %.c $(DEPENDDIR)/%.dep
317 ifdef MAKE_SHARED_LIB
318         $(GCC) $(STD_ABI_FLAG) -g -c $(CFLAGS) -I$(TO_CORE)/dyninstAPI_RT/h $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
319         $(MAKE_SHARED_LIB) $(STD_NATIVE_ABI_LDFLAG) $(TESTLIB_FLAGS) $*.o -o $@
320 else
321         $(GCC) $(STD_ABI_FLAG) $(TESTLIB_FLAGS) -I$(TO_CORE)/dyninstAPI_RT/h -I../src/ $(filter %.c,$^) -o $@
322 endif
323
324 ifdef M_ABI
325 $(TESTLIBS_ABI): %_$(M_ABI).so : %.c $(DEPENDDIR)/%.dep
326 ifdef MAKE_SHARED_LIB
327         $(GCC) $(M_ABI_FLAG) -g -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
328         $(MAKE_SHARED_LIB) $(M_NATIVE_ABI_LDFLAG) $(TESTLIB_FLAGS) $*.o -o $@
329 else
330         $(GCC) $(M_ABI_FLAG) $(TESTLIB_FLAGS) -I$(TO_CORE)/dyninstAPI_RT/h -I../src/ $(filter %.c,$^) -o $@
331 endif
332 endif
333
334 libTest12.so: libTest12.c $(DEPENDDIR)/libTest12.dep
335 ifdef MAKE_SHARED_LIB
336         $(GCC) $(STD_ABI_FLAG) -g -c $(CFLAGS) -I$(TO_CORE)/dyninst_RT/h $(CFLAGS_TESTLIBS) $(filter %.c, $^)  -o libTest12.o
337         $(MAKE_SHARED_LIB) $(STD_NATIVE_ABI_LDFLAG) $(TESTLIB_FLAGS) $(LIBTEST12_FLAGS) libTest12.o -o $@
338 else
339         $(GCC) $(STD_ABI_FLAG) $(TESTLIB_FLAGS) -I$(TO_CORE)/dyninstAPI_RT/h $(LIBTEST12_FLAGS) $(filter %.c, $^) -o $@
340 endif
341 #######################################################################
342 ###  Special Prerequisites for specific Mutatees:
343 #######################################################################
344
345 # Test 1 mutatee depends on two extra files
346 test1.mutatee_gcc: $(CALL35_1_OBJ) test1.mutateeCommon_gcc.o
347 test1.mutatee_g++: $(CALL35_1_OBJ) test1.mutateeCommon_g++.o
348 test1.mutatee_$(NATIVE_CC): $(CALL35_1_SRC) test1.mutateeCommon.c
349 test1.mutatee_$(NATIVE_CXX): $(CALL35_1_SRC) test1.mutateeCommon.c
350
351 ifdef M_ABI
352 test1.mutatee_gcc_$(M_ABI): $(CALL35_1_OBJ_ABI) test1.mutateeCommon_gcc_$(M_ABI).o
353 test1.mutatee_g++_$(M_ABI): $(CALL35_1_OBJ_ABI) test1.mutateeCommon_g++_$(M_ABI).o
354 test1.mutatee_$(NATIVE_CC)_$(M_ABI): $(CALL35_1_SRC_ABI) test1.mutateeCommon.c
355 test1.mutatee_$(NATIVE_CXX)_$(M_ABI): $(CALL35_1_SRC_ABI) test1.mutateeCommon.c
356 endif
357
358 # Test 6 mutatee depends on a platform-specific asm file
359 test6.mutatee_$(NATIVE_CC): $(TEST6_AS_OBJ_GNU) 
360 test6.mutatee_$(NATIVE_CXX): $(TEST6_AS_OBJ_GNU) 
361 test6.mutatee_gcc: $(TEST6_AS_OBJ_GNU) 
362
363 # libInstMe.so must be built before test9.mutatee
364 test9.mutatee_gcc: libInstMe.so
365 test9.mutatee_$(NATIVE_CC): libInstMe.so
366
367 ifdef M_ABI
368 test9.mutatee_gcc: libInstMe_$(M_ABI).so
369 test9.mutatee_$(NATIVE_CC): libInstMe_$(M_ABI).so
370 endif
371
372 # MUTATEE_SPECIFIC_LIBS is analyzed by gmake when constructing the link line
373 # If you want to specify that a specific library should be used to link a specific
374 # mutatee, add an entry to this variable in the format <testno>.-libwhatever
375
376 # The <testno>. will be stripped off, leaving -libwhatever on the link line
377
378 MUTATEE_SPECIFIC_LIBS_GNU       += $(MUTATEE_TEST9_EXTRA_LIB)
379 MUTATEE_SPECIFIC_LIBS_GNU       += 12.-lpthread
380 MUTATEE_SPECIFIC_LIBS_NATIVE    += $(MUTATEE_TEST9_EXTRA_LIB)
381 MUTATEE_SPECIFIC_LIBS_NATIVE    += 12.-lpthread
382 MUTATEE_SPECIFIC_LIBS_GNU += 13.-lpthread
383 MUTATEE_SPECIFIC_LIBS_GNU += 14.-lpthread
384 MUTATEE_SPECIFIC_LIBS_GNU += 15.-lpthread
385 MUTATEE_SPECIFIC_LIBS_NATIVE    += 13.-lpthread
386 MUTATEE_SPECIFIC_LIBS_NATIVE    += 14.-lpthread
387 MUTATEE_SPECIFIC_LIBS_NATIVE    += 15.-lpthread
388
389 ifdef MUTATEE_USE_LIBDL_SELECTIVELY
390 MUTATEE_SPECIFIC_LIBS_GNU       += 1.-ldl
391 MUTATEE_SPECIFIC_LIBS_NATIVE    += 1.-ldl
392 MUTATEE_SPECIFIC_LIBS_GNU       += 2.-ldl
393 MUTATEE_SPECIFIC_LIBS_NATIVE    += 2.-ldl
394 MUTATEE_SPECIFIC_LIBS_GNU       += 12.-ldl
395 MUTATEE_SPECIFIC_LIBS_NATIVE    += 12.-ldl
396
397 ifdef M_ABI
398 MUTATEE_SPECIFIC_LIBS_GNU_ABI   += 1.-ldl
399 MUTATEE_SPECIFIC_LIBS_GNU_ABI   += 2.-ldl
400 MUTATEE_SPECIFIC_LIBS_GNU_ABI   += 12.-ldl
401 endif
402 endif
403
404 ifdef M_ABI
405 MUTATEE_SPECIFIC_LIBS_GNU_ABI   += $(MUTATEE_TEST9_EXTRA_LIB_ABI)
406 MUTATEE_SPECIFIC_LIBS_GNU_ABI   += 12.-lpthread
407 MUTATEE_SPECIFIC_LIBS_GNU_ABI += 13.-lpthread
408 MUTATEE_SPECIFIC_LIBS_GNU_ABI += 14.-lpthread
409 MUTATEE_SPECIFIC_LIBS_GNU_ABI += 15.-lpthread
410 endif
411
412 #######################################################################
413 ###  Generic mutatee build rules (GNU and NATIVE):
414 #######################################################################
415
416 # GNU Mutatees
417
418 $(MUTATEES_GCC): test%.mutatee_gcc : test%.mutatee_gcc.o $(DEPENDDIR)/test%.mutatee_gcc.dep mutatee_util_gcc.o
419         $(M_GCC) $(STD_ABI_FLAG) -o $@ $(filter %.o,$^) $(MUTATEE_LDFLAGS_GNU) $(MUTATEE_LIBS) \
420             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_GNU)))
421
422 $(MUTATEES_GXX): test%.mutatee_g++ : test%.mutatee_g++.o $(DEPENDDIR)/test%.mutatee_g++.dep mutatee_util_g++.o
423         $(M_GXX) $(STD_ABI_FLAG) -o $@ $(filter %.o,$^) $(MUTATEE_LDFLAGS_GNU) $(MUTATEE_LIBS) \
424             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_GNU)))
425
426 # GNU Secondary ABI Mutatees
427 ifdef M_ABI
428 $(MUTATEES_GCC_ABI): test%.mutatee_gcc_$(M_ABI) : test%.mutatee_gcc_$(M_ABI).o $(DEPENDDIR)/test%.mutatee_gcc.dep mutatee_util_gcc_$(M_ABI).o
429         $(M_GCC) $(M_ABI_FLAG) -o $@ $(filter %.o,$^) $(MUTATEE_LDFLAGS_GNU) $(MUTATEE_LIBS) \
430             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_GNU_ABI)))
431
432 $(MUTATEES_GXX_ABI): test%.mutatee_g++_$(M_ABI) : test%.mutatee_g++_$(M_ABI).o $(DEPENDDIR)/test%.mutatee_g++.dep mutatee_util_g++_$(M_ABI).o
433         $(M_GXX) $(M_ABI_FLAG) -o $@ $(filter %.o,$^) $(MUTATEE_LDFLAGS_GNU) $(MUTATEE_LIBS) \
434             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_GNU_ABI)))
435 endif
436
437
438 # GNU Fortran (g77) mutatees
439
440 # There is no real advantage to generality here since there is only one fortran mutatee
441 # (ie for test1), thus all constituent files are built explicitly
442
443 ifdef M_G77
444 test1.mutatee_g77.o: ../src/test1.mutateeFort.F
445         $(M_G77) $(STD_ABI_FLAG) -g  $(MUTATEE_G77_FFLAGS) -c -o $@ $^ 
446 test1.mutateeFortC_g77.o: $(TEST1_FORTRAN_CSOURCE)
447         $(M_GCC) $(STD_ABI_FLAG) $(MUTATEE_G77_CFLAGS) $(filter %.c,$^) -o $@
448
449 $(MUTATEES_G77): test%.mutatee_g77 : test%.mutatee_g77.o test1.mutateeFortC_g77.o test1.mutateeCommon_gcc.o mutatee_util_gcc.o $(DEPENDDIR)/test%.mutatee_g77.dep
450         $(M_G77) $(STD_ABI_FLAG) -o $@ $(filter %.o,$^) $(MUTATEE_G77_LDFLAGS) $(MUTATEE_LIBS)
451 endif
452
453 # Native Mutatees
454
455 ifdef NATIVE_CC
456 $(MUTATEES_NATIVE_CC): test%.mutatee_$(NATIVE_CC) : test%.mutatee.c mutatee_util_$(NATIVE_CC).o
457         $(NATIVE_CC) $(STD_NATIVE_ABI_FLAG) $(MUTATEE_CFLAGS_NATIVE) $(MUTATEE_LDFLAGS_NATIVE) -o $@ $(MUTATEE_LIBS) $(filter %.c  %.s %.S %.o, $^) \
458             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_NATIVE)))
459
460 endif
461
462 ifdef NATIVE_CXX
463 $(MUTATEES_NATIVE_CXX): test%.mutatee_$(NATIVE_CXX) : test%.mutatee.c mutatee_util_$(NATIVE_CXX).o
464         $(NATIVE_CXX) $(STD_NATIVE_ABI_FLAG) $(MUTATEE_CXXFLAGS_NATIVE) -o $@ $(filter %.c %.s %.S %.o,$^) $(MUTATEE_LDFLAGS_NATIVE) $(MUTATEE_LIBS) \
465             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_NATIVE)))
466
467 $(MUTATEES_NATIVE_CXX_ONLY): test%.mutatee_$(NATIVE_CXX) : test%.mutatee.C mutatee_util_$(NATIVE_CXX).o
468         $(NATIVE_CXX) $(STD_NATIVE_ABI_FLAG) $(MUTATEE_CXXFLAGS_NATIVE) -o $@ $(filter %.C %.s %.S %.o,$^) $(MUTATEE_LDFLAGS_NATIVE) $(MUTATEE_LIBS) \
469             $(subst $*.,,$(filter $*.%, $(MUTATEE_SPECIFIC_LIBS_NATIVE)))
470 endif
471
472
473 # Native Fortran mutatees
474
475 # There is no real advantage to generality here since there is only one fortran mutatee
476 # (ie for test1), thus all constituent files are built explicitly
477
478 ifdef NATIVE_FC 
479 test1.mutatee_$(NATIVE_FC).o: ../src/test1.mutateeFort.F
480         $(NATIVE_FC) $(STD_NATIVE_ABI_FLAG) -g  $(MUTATEE_NATIVE_FFLAGS) -c -o $@ $^ 
481 test1.mutateeFortC_$(NATIVE_FC).o: ../src/test1.mutateeFortC.c
482         $(NATIVE_FORTRAN_CC) $(STD_NATIVE_ABI_FLAG) $(MUTATEE_NATIVE_FC_CFLAGS) -c $(filter %.c,$^) -o $@
483
484 $(MUTATEES_NATIVE_FC): test%.mutatee_$(NATIVE_FC) : test%.mutatee_$(NATIVE_FC).o test1.mutateeFortC_$(NATIVE_FC).o test1.mutateeCommon_$(NATIVE_FORTRAN_CC).o mutatee_util_$(NATIVE_FORTRAN_CC).o $(DEPENDDIR)/test%.mutatee_$(NATIVE_FC).dep
485         $(NATIVE_FC) $(STD_NATIVE_ABI_FFLAG) -o $@ $(filter %.o,$^) $(MUTATEE_NATIVE_FC_LDFLAGS) $(MUTATEE_LIBS) 
486 endif
487
488 # Install directory
489 $(TEST_DEST): 
490         mkdir $(TEST_DEST)
491
492 #######################################################################
493 ###  Generic Mutator build rule:
494 ###
495 ###  resorts to pattern matching test% (matches test1, test2, ... etc)
496 ###  to generate correct, minimal set of prerequisites for each test.
497 ###  It would be nicer to just match something simpler that wasn't 
498 ###  name-dependant, but gnu make is not making this easy.
499 ###
500 #######################################################################
501
502 $(MUTATORS): test% : test%.o $(OBJS_FORALL_MUTATORS) $(DEPENDDIR)/test%.dep
503         $(CXX) $(STD_ABI_FLAG) -o $@ $(filter %.o,$^) $(MUTATOR_LDFLAGS) $(LIBDIR) $(LIBS) $(LDFLAGS) $(MUTATOR_LDFLAGS)
504
505 test11:
506         cp ../src/test11.sh test11
507
508 #######################################################################
509 ###  Depends
510 #######################################################################
511
512 DEPS_MUTATORS           += $(addprefix $(DEPENDDIR)/,$(addsuffix .dep,$(MUTATORS)))
513 DEPS_MUTATORS           += $(addprefix $(DEPENDDIR)/,$(addsuffix .dep,$(FORALL_MUTATORS)))
514
515 DEPS_MUTATEES_GCC       += $(addprefix $(DEPENDDIR)/,$(addsuffix _gcc.dep, $(MUTATEES_C)))
516 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX)))
517 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX_ONLY)))
518 DEPS_TESTLIBS           += $(addprefix $(DEPENDDIR)/,$(addsuffix .dep,$(TESTLIB_STEMS)))
519 DEPS_TESTLIBS           += $(DEPENDDIR)/libTest12.dep
520 ifdef M_G77
521 DEPS_MUTATEES_G77       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g77.dep, $(MUTATEES_FORTRAN)))
522 endif
523
524 ifdef NATIVE_FC
525 DEPS_MUTATEES_NATIVE_FC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_FC).dep, $(MUTATEES_FORTRAN)))
526 endif
527
528 ifdef NATIVE_CC
529 DEPS_MUTATEES_NATIVE_CC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CC).dep, $(MUTATEES_C)))
530 endif
531
532 ifdef NATIVE_CXX
533 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX)))
534 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX_ONLY)))
535 endif
536
537
538 depend: $(DEPS_MUTATORS)
539
540 depend_dir:
541         @echo "mut deps: $(DEPS_MUTATORS)"
542         @if [ -d $(DEPENDDIR) ]; then \
543           echo "Directory \"$(DEPENDDIR)\" already exists..."; \
544          else \
545           mkdir -p $(DEPENDIR); \
546           echo "Made \"$(DEPENDDIR)\" directory..."; \
547          fi
548
549 $(DEPS_MUTATORS): $(DEPENDDIR)/test%.dep : test%.C 
550         @mkdir -p $(DEPENDDIR)
551         $(DEPCC) $(STD_ABI_FLAG) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) test$*.o > $@ 
552
553 $(DEPS_MUTATEES_GCC): $(DEPENDDIR)/test%.mutatee_gcc.dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
554         @mkdir -p $(DEPENDDIR)
555         $(M_GCC) $(STD_ABI_FLAG) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_gcc.o > $@ 
556
557 $(DEPS_MUTATEES_GXX): $(DEPENDDIR)/test%.mutatee_g++.dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
558         @mkdir -p $(DEPENDDIR)
559         $(M_GXX) $(STD_ABI_FLAG) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_gxx.o > $@
560
561 $(DEPS_MUTATEES_G77): $(DEPENDDIR)/test%.mutatee_g77.dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
562         @mkdir -p $(DEPENDDIR)
563         $(M_G77) $(STD_ABI_FLAG) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_g77.o > $@
564
565
566 # Use gcc to generate deps for native compilers
567
568 ifdef NATIVE_CC
569 $(DEPS_MUTATEES_NATIVE_CC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CC).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
570         @mkdir -p $(DEPENDDIR)
571         $(M_GCC) $(STD_ABI_FLAG) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CC).o > $@
572 endif
573
574 ifdef NATIVE_CXX
575 $(DEPS_MUTATEES_NATIVE_CXX): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX).dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
576         @mkdir -p $(DEPENDDIR)
577         $(M_GXX) $(STD_ABI_FLAG) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX).o > $@
578 endif
579
580 ifdef NATIVE_FC
581 $(DEPS_MUTATEES_NATIVE_FC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_FC).dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
582         @mkdir -p $(DEPENDDIR)
583         $(M_G77) $(STD_ABI_FLAG) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_$(NATIVE_FC).o > $@
584 endif
585
586
587 $(DEPS_TESTLIBS): $(DEPENDDIR)/lib%.dep : lib%.c 
588         @mkdir -p $(DEPENDDIR)
589         $(DEPCC) $(STD_ABI_FLAG) $(CXXFLAGS) -I$(TO_CORE)/dyninstAPI_RT/h $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) lib$*.so > $@
590
591 # do not include dep files for "clean" targets
592 ifneq ($(MAKECMDGOALS),clean)
593 ifneq ($(MAKECMDGOALS),distclean)
594 ifneq ($(MAKECMDGOALS),echo)
595
596 -include $(DEPS_MUTATORS)
597 -include $(DEPS_MUTATEES_GCC)
598 -include $(DEPS_MUTATEES_GXX)
599 -include $(DEPS_TESTLIBS)
600
601 ifdef M_G77
602 -include $(DEPS_MUTATEES_G77)
603 endif
604
605 ifdef NATIVE_CC
606 -include $(DEPS_MUTATEES_NATIVE_CC)
607 endif
608
609 ifdef NATIVE_CXX
610 -include $(DEPS_MUTATEES_NATIVE_CXX)
611 endif
612
613 ifdef NATIVE_FC
614 -include $(DEPS_MUTATEES_NATIVE_FC)
615 endif
616
617 endif
618 endif
619 endif
620
621 # Why we normally compile the _tests_ with -fno-implicit-templates, I don't know.
622 test1.o : test1.C
623         $(CXX) $(STD_ABI_FLAG) -c -o $@ $(CFLAGS) $(DYNINST_INCDIR) $<