Fix Windows build
[dyninst.git] / testsuite / make.module.tmpl
1 #
2 # make.module.tmpl for 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
7 RM = rm -f
8 RMDIR ?= rmdir
9 M_GCC ?= purify $(GCC)
10 M_GXX ?= $(GXX)
11 DEPCC ?= $(GCC)
12 DEPENDFLAGS ?= -MM -MT
13 DEPENDDIR = ./depends
14 VPATH   = ../src $(DEPENDDIR)
15
16 IFLAGS += ../../../include
17 #DYNINST_INCDIR = -I../../dyninstAPI/h
18 #SYMTAB_INCDIR = -I../../symtabAPI/h
19 #DYNUTIL_INCDIR = -I../../dynutil/h
20 #INSTRUCTION_INCDIR = -I../../instructionAPI/h
21 #PROCCONTROL_INCDIR = -I../../proccontrol/h
22 BOOST_INCDIR = -I../../external
23
24 IFLAGS += $(DYNINST_INCDIR)
25 IFLAGS += $(DYNUTIL_INCDIR)
26 IFLAGS += $(SYMTAB_INCDIR)
27 IFLAGS += $(INSTRUCTION_INCDIR)
28 IFLAGS += $(PROCCONTROL_INCDIR)
29 IFLAGS += $(BOOST_INCDIR)
30
31 #######################################################################
32 ### We don't want all of the CFLAGS stuff that came from make.config.
33 ### Strip away most of it.
34 #######################################################################
35
36 CFLAGS = $(UNIFIED_TEST_DEF:%=%_test) $(ARCH_FLAGS) $(AC_DEF) $(FIRST_INCLUDE) -I$(INCLUDE_DEST) -I../src -g $(BOOST_INCDIR)
37 CXXFLAGS = $(CFLAGS)
38 CXXFLAGS += $(PLATFORM_CXXFLAGS)
39 CFLAGS_NATIVE = $(CFLAGS)
40 CXXFLAGS_NATIVE = $(CXXFLAGS)
41 MUTATEE_CFLAGS_NATIVE ?= $(CFLAGS)
42 MUTATEE_CXXFLAGS_NATIVE ?= $(CXXFLAGS)
43
44 #######################################################################
45 ###  Generate compiler id strings
46 ###
47 ###  COMPILERT_NATIVE_CC, COMPILERT_NATIVE_CXX must be defined prior to
48 ###  inclusion of this file.  gcc/g++ are handled here as platform-indep
49 ###
50 #######################################################################
51
52 EMPTY:=
53 BLANK:=$(EMPTY) $(EMPTY)
54 LPAREN:=(
55 RPAREN:=)
56 COMMA=,
57 RSQBRACK:=[
58 LSQBRACK:=]
59
60 COMPILERT_GCC = $(shell $(M_GCC) -v 2>&1 | grep version | head -1)
61 COMPILER1_GCC = $(subst $(BLANK),_,$(COMPILERT_GCC))
62 COMPILER2_GCC = $(subst $(LPAREN),_,$(COMPILER1_GCC))
63 COMPILER3_GCC = $(subst $(RSQBRACK),_,$(COMPILER2_GCC))
64 COMPILER4_GCC = $(subst $(LSQBRACK),_,$(COMPILER3_GCC))
65 COMPILER_GCC = $(subst $(RPAREN),_,$(COMPILER4_GCC))
66 MUTATEE_CFLAGS_GNU += -DCOMPILER='"$(COMPILER_GCC)"'
67 MUTATEE_LDFLAGS_GNU += $(LDFLAGS) -L.
68
69 COMPILERT_GXX = $(shell $(M_GCC) -v 2>&1 | grep version | head -1)
70 COMPILER1_GXX = $(subst $(BLANK),_,$(COMPILERT_GXX))
71 COMPILER2_GXX = $(subst $(LPAREN),_,$(COMPILER1_GXX))
72 COMPILER3_GXX = $(subst $(RSQBRACK),_,$(COMPILER2_GXX))
73 COMPILER4_GXX = $(subst $(LSQBRACK),_,$(COMPILER3_GXX))
74 COMPILER_GXX = $(subst $(RPAREN),_,$(COMPILER4_GXX))
75 MUTATEE_CXXFLAGS_GNU += -DCOMPILER='"$(COMPILER_GXX)"'
76
77 COMPILER1_NATIVE_CC = $(subst $(BLANK),_,$(COMPILERT_NATIVE_CC))
78 COMPILER2_NATIVE_CC = $(subst $(LPAREN),_,$(COMPILER1_NATIVE_CC))
79 COMPILER_NATIVE_CC = $(subst $(RPAREN),_,$(COMPILER2_NATIVE_CC))
80 MUTATEE_CFLAGS_NATIVE += -DCOMPILER='"$(COMPILER_NATIVE_CC)"'
81 MUTATEE_LDFLAGS_NATIVE += $(LDFLAGS) -L.
82
83 COMPILER1_NATIVE_CXX = $(subst $(BLANK),_,$(COMPILERT_NATIVE_CXX))
84 COMPILER2_NATIVE_CXX = $(subst $(LPAREN),_,$(COMPILER1_NATIVE_CXX))
85 COMPILER_NATIVE_CXX = $(subst $(RPAREN),_,$(COMPILER2_NATIVE_CXX))
86 MUTATEE_CXXFLAGS_NATIVE += -DCOMPILER='"$(COMPILER_NATIVE_CXX)"'
87
88 TEST_DEST = $(TO_CORE)/$(PROGRAM_DEST)/testprogs_new2
89 LIB_DEST = $(TO_CORE)/$(LIBRARY_DEST)
90
91 LIBDIR += -L$(LIBRARY_DEST)
92
93 #######################################################################
94 ###  Basic definitions (filename prefixes)
95 #######################################################################
96
97 FORALL_MUTATORS =  
98
99 FORALL_MUTATEES = mutatee_util
100
101 SRCS_LIBTESTSUITE = test_lib.C \
102                     test_lib_soExecution.C \
103                     ParameterDict.C \
104                     TestData.C \
105                     TestMutator.C \
106                     TestOutputDriver.C \
107                     StdOutputDriver.C \
108                     ResumeLog.C \
109                     test_info_new.C
110
111 SRCS_TEMPLATES = test_driver_templates.C 
112
113 OBJS_LIBTESTSUITE = $(SRCS_LIBTESTSUITE:%.C=%.o)
114 OBJS_TEMPLATES = $(SRCS_TEMPLATES:%.C=%.o)
115
116 ifdef USE_LIBTESTSUITE_EXT_A
117 LIBTESTSUITE = libtestSuite.a
118 else
119 LIBTESTSUITE = libtestSuite.so
120 endif
121
122 TESTDRIVER_LDFLAGS = $(DEMANGLER_EXEC_LINK)
123 #######################################################
124 # Dyninst infrastructure components
125 #######################################################
126 SRCS_DYNINSTCOMP_LIB = dyninst/dyninst_comp.C \
127                        dyninst/test_lib_mutateeStart.C \
128                        dyninst/Callbacks.C \
129                        dyninst/Process_data.C \
130                        dyninst/ParseThat.C \
131                        dyninst/test_lib_test7.C \
132                        dyninst/test_lib_test9.C
133 OBJS_DYNINSTCOMP_LIB = $(notdir $(SRCS_DYNINSTCOMP_LIB:%.C=%.o))
134 SRCS_DYNINSTTESTLIB = dyninst/libtestA.c \
135                       dyninst/libtestB.c \
136                       dyninst/libTest12.c
137
138 #                      dyninst/libInstMe.c \
139 #                      dyninst/libLoadMe.c \
140
141 dyninst_MUTATOR_FLAGS = -L. -ltestdyninst -ldyninstAPI
142
143 ifdef M_ABI
144 DYNINST_TESTLIBS = $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%.so))
145 DYNINST_STATIC_TESTLIBS = $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%.a))
146 DYNINST_TESTLIBS_ABI = $(addsuffix _$(M_ABI).so, $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%)))
147 DYNINST_STATIC_TESTLIBS_ABI = $(addsuffix _$(M_ABI).a, $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%)))
148 else
149 DYNINST_TESTLIBS = $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%.so))
150 DYNINST_STATIC_TESTLIBS = $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%.a))
151 DYNINST_TESTLIBS_ABI =
152 DYNINST_STATIC_TESTLIBS_ABI = 
153 endif
154
155 ifdef USE_LIBTESTSUITE_EXT_A
156 LIBDYNINSTCOMP = libtestdyninst.a
157 else
158 LIBDYNINSTCOMP = libtestdyninst.so
159 endif
160
161 dyninst_MUTATOR_LIB = $(LIBDYNINSTCOMP)
162 dyninst_COMPONENT_LIB = $(LIBDYNINSTCOMP)
163
164
165 #######################################################
166 # Symtab infrastructure components
167 #######################################################
168 SRCS_SYMTABCOMP_LIB = symtab/symtab_comp.C
169 OBJS_SYMTABCOMP_LIB = $(notdir $(SRCS_SYMTABCOMP_LIB:%.C=%.o))
170 symtab_MUTATOR_FLAGS = -L. -ltestsymtab -lcommon
171
172 ifdef USE_LIBTESTSUITE_EXT_A
173 LIBSYMTABCOMP = libtestsymtab.a
174 else
175 LIBSYMTABCOMP = libtestsymtab.so
176 endif
177
178 symtab_MUTATOR_LIB = $(LIBSYMTABCOMP)
179 symtab_COMPONENT_LIB = $(LIBSYMTABCOMP)
180
181 #######################################################
182 # Instruction infrastructure components
183 #######################################################
184 SRCS_INSTRUCTIONCOMP_LIB = instruction/instruction_comp.C
185 OBJS_INSTRUCTIONCOMP_LIB = $(notdir $(SRCS_INSTRUCTIONCOMP_LIB:%.C=%.o))
186 instruction_MUTATOR_FLAGS = -L. -ltestinstruction -linstructionAPI -lcommon
187
188 ifdef USE_LIBTESTSUITE_EXT_A
189 LIBINSTRUCTIONCOMP = libtestinstruction.a
190 else
191 LIBINSTRUCTIONCOMP = libtestinstruction.so
192 endif
193
194 instruction_MUTATOR_LIB = $(LIBINSTRUCTIONCOMP)
195 instruction_COMPONENT_LIB = $(LIBINSTRUCTIONCOMP)
196
197 #######################################################
198 # ProcControlAPI infrastructure components
199 #######################################################
200 SRCS_PROCCONTROLCOMP_LIB = proccontrol/proccontrol_comp.C
201 OBJS_PROCCONTROLCOMP_LIB = $(notdir $(SRCS_PROCCONTROLCOMP_LIB:%.C=%.o))
202 proccontrol_MUTATOR_FLAGS = -L. -ltestproccontrol -lpcontrol -lcommon
203
204 ifdef USE_LIBTESTSUITE_EXT_A
205 LIBPROCCONTROLCOMP = libtestproccontrol.a
206 else
207 LIBPROCCONTROLCOMP = libtestproccontrol.so
208 endif
209
210 proccontrol_MUTATOR_LIB = $(LIBPROCCONTROLCOMP)
211 proccontrol_COMPONENT_LIB = $(LIBPROCCONTROLCOMP)
212
213
214 ######################################################################
215 ### Main target
216 ######################################################################
217
218 default: testlibs mutators mutatees_minimum drivers output_drivers components
219         @echo "**********************************************************"
220         @echo "* Build complete."
221         @echo "*"
222         @echo "* High optimization mutatees were not built, use 'make all'"
223         @echo "* to build them."
224         @echo "**********************************************************"
225
226 all: testlibs mutators mutatees drivers output_drivers components
227
228 # test_info_new.gen.o is special-cased because it makes use of the
229 # COMPILER_CONTROL_DEFS to determine which mutatees to enable for compilers
230 # that are not present at all sites.
231 test_info_new.gen.o: test_info_new.gen.C
232         $(CXX) -c -o $@ $(CXXFLAGS) $(COMPILER_CONTROL_DEFS) -I../src/ test_info_new.gen.C
233
234 #######################################################################
235 ###  A list of all the targets we're building, for install purposes
236 #######################################################################
237
238 ALL_TARGETS_DEST                = $(addprefix $(TEST_DEST)/,$(ALL_TARGETS))
239 LIBTESTSUITE_DEST               = $(addprefix $(TEST_DEST)/,$(LIBTESTSUITE))
240
241 #######################################################################
242 ###  Some pattern rules
243 #######################################################################
244
245 CXXTFLAGS := $(filter-out -fno-implicit-templates, $(CXXFLAGS))
246
247 #######################################################################
248 ###  High level targets
249 #######################################################################
250
251 MUTATOR_LDFLAGS := $(LDFLAGS) $(LIBDIR) $(MUTATOR_LIBS) $(MUTATOR_LDFLAGS) -lpthread
252 MUTATOR_SO_LDFLAGS = $(filter-out -liberty, $(MUTATOR_LDFLAGS))
253 MUTATEE_NATIVE_FC_LDFLAGS += $(LDFLAGS)
254 MUTATEE_NATIVE_CXX_OMP_LDFLAGS += $(LDFLAGS)
255 TESTDRIVER_LDFLAGS += $(LDFLAGS)
256
257 # all: testlibs mutators mutatees drivers
258 # See also an addition to the 'all' rule at the end of the file
259
260 ### Automatically generated variables; generated by makemake.py
261
262 include make.mutators.gen
263
264 include make.solo_mutatee.gen
265
266 mutatees:
267
268 mutators:
269
270 components:
271
272 testlibs:
273
274 #######################################################################
275 ###  Filter results, if needed
276 #######################################################################
277
278 MINIMUM_BUILD_FILTER = %_max %_high %_low
279 BUILD_FILTER =
280 ifdef SKIP_BUILD_RTLIB_32
281         BUILD_FILTER += %_32_max %_32_high %_32_low %_32_none
282 endif
283
284 ifneq ($(wildcard ../src/dyninst), )
285 mutatees: $(filter-out $(BUILD_FILTER), $(dyninst_SOLO_MUTATEES))
286 mutatees_minimum: $(filter-out $(BUILD_FILTER), $(filter-out $(MINIMUM_BUILD_FILTER), $(dyninst_SOLO_MUTATEES)))
287 mutators: $(dyninst_MUTATORS_SO)
288 components: $(LIBDYNINSTCOMP)
289 testlibs: $(DYNINST_TESTLIBS) $(DYNINST_STATIC_TESTLIBS)
290 ifndef SKIP_BUILD_RTLIB_32
291 testlibs: $(DYNINST_TESTLIBS_ABI) $(DYNINST_STATIC_TESTLIBS_ABI)
292 endif
293 endif
294
295 ifneq ($(wildcard ../src/symtab), )
296 mutatees: $(filter-out $(BUILD_FILTER), $(symtab_SOLO_MUTATEES))
297 mutatees_minimum: $(filter-out $(BUILD_FILTER), $(filter-out $(MINIMUM_BUILD_FILTER), $(symtab_SOLO_MUTATEES)))
298 mutators: $(symtab_MUTATORS_SO)
299 components: $(LIBSYMTABCOMP)
300 testlibs:
301 endif
302
303 ifneq ($(wildcard ../src/instruction), )
304 mutatees: $(filter-out $(BUILD_FILTER), $(instruction_SOLO_MUTATEES))
305 mutatees_minimum: $(filter-out $(BUILD_FILTER), $(filter-out $(MINIMUM_BUILD_FILTER), $(instruction_SOLO_MUTATEES)))
306 mutators: $(instruction_MUTATORS_SO)
307 ifneq ($(instruction_MUTATORS_SO), )
308 components: $(LIBINSTRUCTIONCOMP)
309 testlibs:
310 endif
311 endif
312
313 ifneq ($(wildcard ../src/proccontrol), )
314 mutatees: $(proccontrol_SOLO_MUTATEES)
315 mutatees_minimum: $(filter-out $(MINIMUM_BUILD_FILTER), $(proccontrol_SOLO_MUTATEES))
316 mutators: $(proccontrol_MUTATORS_SO)
317 ifneq ($(proccontrol_MUTATORS_SO), )
318 components: $(LIBPROCCONTROLCOMP)
319 testlibs: $(PROCCONTROL_TESTLIBS) $(PROCCONTROL_TESTLIBS_ABI)
320 endif
321 endif
322
323
324 install: all
325
326 symlink: all
327
328 clean: clean_solo_mutatees dyninst_clean_solo_mutatees
329         @$(RM) *.da *.bb. *.bbg 
330         @$(RM) $(TESTLIBS) $(TESTLIBS_ABI) $(LIBTESTSUITE) test_driver runTests libTest12.so
331         @$(RM) $(dyninst_MUTATORS_SO)
332         @$(RM) $(symtab_MUTATORS_SO)
333         @$(RM) $(symtab_SOLO_MUTATEES)
334         @$(RM) $(instruction_MUTATORS_SO)
335         @$(RM) $(instruction_SOLO_MUTATEES)
336         @$(RM) $(proccontrol_MUTATORS_SO)
337         @$(RM) $(proccontrol_SOLO_MUTATEES)
338         @$(RM) $(OUTPUT_DRIVERS)
339         @$(RM) $(LIBDYNINSTCOMP)
340         @$(RM) $(LIBSYMTABCOMP)
341         @$(RM) $(LIBINSTRUCTIONCOMP)
342         @$(RM) $(DYNINST_TESTLIBS) $(DYNINST_STATIC_TESTLIBS) $(DYNINST_TESTLIBS_ABI) $(DYNINST_STATIC_TESTLIBS_ABI)
343         @$(RM) *.o
344         @$(RM) test11
345         @$(RM) imagefile
346         @$(RM) core core.*
347         @$(RM) -r _dyninstsaved*
348         @$(RM) *.ii *.ti
349         @$(RM) .__afs*
350  
351
352 distclean: clean
353         @if [ -d $(DEPENDDIR) ]; then \
354           $(RM) $(DEPENDDIR)/*.dep; \
355           rmdir $(DEPENDDIR); \
356          fi
357
358 specclean:
359         $(RM) *.gen *.pl tuples test_info_new.gen.C
360
361 ifdef M_ABI
362 $(CALL35_1_OBJ_ABI): $(CALL35_1_SRC_ABI)
363         $(M_GCC) $(M_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@ 
364 endif
365
366 testlibs: $(LIBTESTSUITE)
367
368 drivers: test_driver runTests
369
370 .PHONY: clean install distclean mutators mutatees testlibs gnu_mutatees native_mutatees echo all
371
372 #######################################################################
373 ###  Build command for test libraries
374 #######################################################################
375
376 $(dyninst_OBJS_ALL_MUTATORS): %.o : dyninst/%.C $(DEPENDDIR)/%.dep
377         @echo Compiling $<
378         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/dyninst ../src/dyninst/$*.C
379 $(symtab_OBJS_ALL_MUTATORS): %.o : symtab/%.C $(DEPENDDIR)/%.dep
380         @echo Compiling $<
381         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/symtab ../src/symtab/$*.C
382 $(instruction_OBJS_ALL_MUTATORS): %.o : instruction/%.C $(DEPENDDIR)/%.dep
383         @echo Compiling $<
384         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/instruction ../src/instruction/$*.C
385 $(proccontrol_OBJS_ALL_MUTATORS): %.o : proccontrol/%.C $(DEPENDDIR)/%.dep
386         @echo Compiling $<
387         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/proccontrol ../src/proccontrol/$*.C
388
389 $(DYNINST_TESTLIBS): %.so : dyninst/%.c $(DEPENDDIR)/%.dep
390 ifdef MAKE_SHARED_LIB
391         @echo Compiling $<
392         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
393         @$(MAKE_SHARED_LIB) $(TESTLIB_FLAGS) $*.o -o $@
394 else
395         @echo Compiling $<
396         @$(CC) $(TESTLIB_FLAGS) -I../src/ $(filter %.c,$^) -o $@
397 endif
398
399 $(DYNINST_STATIC_TESTLIBS): %.a : dyninst/%.c $(DEPENDDIR)/%.dep
400         @echo Compiling $<
401         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
402         @$(AR) rcs $@ $*.o
403
404 ifdef M_ABI
405 $(DYNINST_TESTLIBS_ABI): %_$(M_ABI).so : dyninst/%.c $(DEPENDDIR)/%.dep
406 ifdef MAKE_SHARED_LIB
407         @echo Compiling $<
408         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
409         @$(MAKE_SHARED_LIB) $(TESTLIB_FLAGS) $*.o -o $@
410 else
411         @echo Compiling $<
412         @$(CC) $(M_ABI_FLAG) $(TESTLIB_FLAGS) -I../src/ $(filter %.c,$^) -o $@
413 endif
414
415 ifdef cap_instruction_api
416     INSNAPI_LINK = -linstructionAPI
417 endif
418
419 $(DYNINST_STATIC_TESTLIBS_ABI): %_$(M_ABI).a : dyninst/%.c $(DEPENDDIR)/%.dep
420         @echo Compiling $<
421         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
422         @$(AR) rcs $@ $*.o
423 endif
424
425 $(OBJS_TEMPLATES): %.o : ../src/%.C
426         @echo Compiling $<
427         @$(M_GXX) -c -o $@ $(CXXTFLAGS) -I../src/ ../src/$*.C
428
429 test_lib_templates.o : ../src/test_lib_templates.C
430         @echo Compiling $<
431         @$(M_GXX) -c -o $@ -fPIC $(CXXTFLAGS) -I../src/ ../src/$*.C
432
433 $(OBJS_DYNINSTCOMP_LIB): %.o : ../src/dyninst/%.C $(DEPENDDIR)/%.dep
434         @echo Compiling $<
435         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/dyninst/$*.C
436
437 $(OBJS_SYMTABCOMP_LIB): %.o : ../src/symtab/%.C $(DEPENDDIR)/%.dep
438         @echo Compiling $<
439         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/symtab/$*.C
440
441 $(OBJS_INSTRUCTIONCOMP_LIB): %.o : ../src/instruction/%.C $(DEPENDDIR)/%.dep
442         @echo Compiling $<
443         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/instruction/$*.C
444
445 $(OBJS_PROCCONTROLCOMP_LIB): %.o : ../src/proccontrol/%.C $(DEPENDDIR)/%.dep
446         @echo Compiling $<
447         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/proccontrol/$*.C
448
449 $(OBJS_LIBTESTSUITE): %.o : ../src/%.C $(DEPENDDIR)/%.dep
450         @echo Compiling $<
451         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/$*.C
452
453 $(LIBDYNINSTCOMP) : $(OBJS_DYNINSTCOMP_LIB) $(LIBTESTSUITE)
454         @echo Compiling $<
455         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_DYNINSTCOMP_LIB) -o $@ -L. -ltestSuite -ldyninstAPI -lsymtabAPI \
456 -lcommon -linstructionAPI
457
458 $(LIBSYMTABCOMP) : $(OBJS_SYMTABCOMP_LIB) $(LIBTESTSUITE)
459         @echo Compiling $<
460         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_SYMTABCOMP_LIB) -o $@ -L. -ltestSuite -lsymtabAPI -lcommon
461
462 $(LIBINSTRUCTIONCOMP) : $(OBJS_INSTRUCTIONCOMP_LIB) $(LIBTESTSUITE)
463         @echo Compiling $<
464         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_INSTRUCTIONCOMP_LIB) -o $@ -L. -ltestSuite -linstructionAPI -lcommon
465
466 $(LIBPROCCONTROLCOMP) : $(OBJS_PROCCONTROLCOMP_LIB) $(LIBTESTSUITE)
467         @echo Compiling $<
468         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_PROCCONTROLCOMP_LIB) -o $@ -L. -ltestSuite -lpcontrol -lcommon
469
470 $(LIBTESTSUITE) : $(OBJS_LIBTESTSUITE) test_lib_templates.o test_lib.h
471         @echo Compiling $<
472         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(LIBS_LIBTESTSUITE) $(OBJS_LIBTESTSUITE) test_lib_templates.o -o $@
473
474 #
475 # Native Fortran mutatees
476
477 # There is no real advantage to generality here since there is only one fortran mutatee
478 # (ie for test1), thus all constituent files are built explicitly
479
480 ifdef NATIVE_FC 
481 test1.mutatee_$(NATIVE_FC).o: ../src/test1.mutateeFort.F
482         $(NATIVE_FC)  $(MUTATEE_NATIVE_FFLAGS) -c -o $@ $^ 
483 test1.mutateeFortC_$(NATIVE_FC).o: ../src/test1.mutateeFortC.c
484         $(NATIVE_FORTRAN_CC) $(MUTATEE_NATIVE_FC_CFLAGS) -c $(filter %.c,$^) -o $@
485
486 $(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
487         $(NATIVE_FC) -o $@ $(filter %.o,$^) $(MUTATEE_NATIVE_FC_LDFLAGS) $(MUTATEE_LIBS) 
488 endif
489
490 # Native OpenMP mutatees
491 # There is no real advantage to generality here since there is only one OpenMP mutatee
492 # (ie for test16), thus all constituent files are built explicitly
493 ifdef NATIVE_CXX_OMP 
494 test16.mutatee_$(NATIVE_CXX_OMP).o: ../src/test16.mutatee.c
495         $(NATIVE_CXX_OMP)  $(MUTATEE_NATIVE_CXX_CFLAGS) -o $@ $^ 
496
497 $(MUTATEES_NATIVE_CXX_OMP): test%.mutatee_$(NATIVE_CXX_OMP) : test%.mutatee_$(NATIVE_CXX_OMP).o $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX_OMP).dep
498         $(NATIVE_CXX_OMP) $(MUTATEE_NATIVE_CXX_OMP_LDFLAGS) -o $@ $(filter %.o,$^) $(MUTATEE_LIBS) 
499
500 #$(MUTATEES_NATIVE_CXX_OMP): ../src/test16.mutatee.c
501 #       $(NATIVE_CXX_OMP)  $(MUTATEE_NATIVE_CXX_CFLAGS) -o $@ $^ 
502
503 endif
504
505
506 # Install directory
507 $(TEST_DEST): 
508         mkdir $(TEST_DEST)
509
510 #######################################################################
511 ###  Generic Mutator build rule:
512 ###
513 ###  resorts to pattern matching test% (matches test1, test2, ... etc)
514 ###  to generate correct, minimal set of prerequisites for each test.
515 ###  It would be nicer to just match something simpler that wasn't 
516 ###  name-dependant, but gnu make is not making this easy.
517 ###
518 #######################################################################
519
520 MUTATEE_DEFS := -Dgnu_cc=_gcc -Dgnu_cxx=_g++
521
522 ifdef M_ABI
523 MUTATEE_DEFS += -Dgnu_abi_cc=_gcc_$(M_ABI) -Dgnu_abi_cxx=_g++_$(M_ABI) -Dm_abi
524 endif
525
526 ifdef M_G77
527 MUTATEE_DEFS += -Dgnu_fc=_g77
528 endif
529
530 ifdef NATIVE_CC
531 MUTATEE_DEFS += -Dnative_cc=_$(NATIVE_CC)
532 endif
533
534 ifdef NATIVE_CXX
535 MUTATEE_DEFS += -Dnative_cxx=_$(NATIVE_CXX)
536 endif
537
538 ifdef NATIVE_FC
539 MUTATEE_DEFS += -Dnative_fc=_$(NATIVE_FC)
540 endif
541
542 runTests.o: ../src/runTests.C $(DEPENDDIR)/runTests.dep
543         @echo Compiling $<
544         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/runTests.C
545 runTests_static.o: ../src/runTests.C $(DEPENDDIR)/runTests.dep
546         @echo Compiling $<
547         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) -DSTATIC_TEST_DRIVER ../src/runTests.C
548
549 runTests-utils.o: ../src/runTests-utils.C $(DEPENDDIR)/runTests-utils.dep
550         @echo Compiling $<
551         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/runTests-utils.C
552
553 runTests: runTests.o runTests-utils.o test_driver_templates.o 
554         @echo Linking $@
555         @$(CXX) $(CXXFLAGS) -o $@ runTests.o runTests-utils.o test_driver_templates.o 
556 runTests_static: runTests_static.o runTests-utils.o test_driver_templates.o 
557         @echo Linking $@
558         @$(CXX) $(CXXFLAGS) -o runTests runTests_static.o runTests-utils.o test_driver_templates.o 
559
560 test_driver.o: ../src/test_driver.C $(DEPENDDIR)/test_driver.dep
561         @echo Compiling $<
562         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/test_driver.C
563
564 test_driver_static.o: ../src/test_driver.C $(DEPENDDIR)/test_driver_static.dep
565         @echo Compiling $<
566         @$(CXX) -c -o $@ -DSTATIC_TEST_DRIVER $(CXXFLAGS) $(MUTATEE_DEFS) ../src/test_driver.C
567
568 test_driver: test_driver.o test_driver_templates.o test_info_new.gen.o $(DEPENDDIR)/test_driver.dep $(LIBTESTSUITE)
569         @echo Linking $@ $(TESTDRIVER_LDFLAGS)
570         $(CXX) -o $@ test_driver.o test_driver_templates.o test_info_new.gen.o -L. -ltestSuite $(MUTATOR_LDFLAGS) $(LIBS) $(TESTDRIVER_LDFLAGS) -lcommon; $(TESTDRIVER_EXTRA_LINK_STEP)
571         
572
573 ######################################################################
574 ### Output Drivers
575 ######################################################################
576
577 OUTPUT_DRIVERS = DatabaseOutputDriver.so
578
579 DatabaseOutputDriver.o : ../src/DatabaseOutputDriver.C # $(DEPENDDIR)/DatabaseOutputDriver.dep
580         @echo Compiling $<
581         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/$*.C
582
583 DatabaseOutputDriver.so: DatabaseOutputDriver.o $(LIBTESTSUITE) # $(DEPENDDIR)/DatabaseOutputDriver.dep
584         @echo Linking $@
585         @$(CXX) -o $@ -shared $(filter %.o,$^) $(MUTATOR_SO_LDFLAGS) $(LIBDIR) $(LIBS) -L. -ltestSuite
586 ifndef NO_OPT_FLAG
587 ifdef STRIP_SO
588         $(STRIP_SO) $@
589 endif
590 endif
591
592 .PHONY: output_drivers
593 output_drivers: $(OUTPUT_DRIVERS)
594
595 #######################################################################
596 ###  Depends
597 #######################################################################
598
599 DEPS_MUTATORS           += $(DEPENDDIR)/test_driver.dep
600 DEPS_MUTATORS           += $(DEPENDDIR)/runTests.dep $(DEPENDDIR)/runTests-utils.dep
601 DEPS_SYMTAB_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(symtab_OBJS_ALL_MUTATORS:%.o=%.dep))
602 DEPS_DYNINST_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(dyninst_OBJS_ALL_MUTATORS:%.o=%.dep))
603 DEPS_INSTRUCTION_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(instruction_OBJS_ALL_MUTATORS:%.o=%.dep))
604 DEPS_PROCCONTROL_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(proccontrol_OBJS_ALL_MUTATORS:%.o=%.dep))
605
606 DEPS_MUTATEES_GCC       += $(addprefix $(DEPENDDIR)/,$(addsuffix _gcc.dep, $(MUTATEES_C)))
607 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX)))
608 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX_ONLY)))
609 DEPS_DYNINST_TESTLIBS   = $(addprefix $(DEPENDDIR)/,$(DYNINST_TESTLIBS:%.so=%.dep))
610 DEPS_LIBTESTSUITE        = $(addprefix $(DEPENDDIR)/,$(SRCS_LIBTESTSUITE:%.C=%.dep))
611 DEPS_DYNINSTCOMP       =  $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_DYNINSTCOMP_LIB:%.C=%.dep)))
612 DEPS_SYMTABCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_SYMTABCOMP_LIB:%.C=%.dep)))
613 DEPS_INSTRUCTIONCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_INSTRUCTIONCOMP_LIB:%.C=%.dep)))
614 DEPS_PROCCONTROLCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_PROCCONTROLCOMP_LIB:%.C=%.dep)))
615
616 ifdef M_G77
617 DEPS_MUTATEES_G77       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g77.dep, $(MUTATEES_FORTRAN)))
618 endif
619
620 ifdef NATIVE_FC
621 DEPS_MUTATEES_NATIVE_FC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_FC).dep, $(MUTATEES_FORTRAN)))
622 endif
623
624 ifdef NATIVE_CXX_OMP
625 DEPS_MUTATEES_NATIVE_CXX_OMP += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX_OMP).dep, $(MUTATEES_OPENMP)))
626 endif
627
628 ifdef NATIVE_CC
629 DEPS_MUTATEES_NATIVE_CC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CC).dep, $(MUTATEES_C)))
630 endif
631
632 ifdef NATIVE_CXX
633 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX)))
634 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX_ONLY)))
635 endif
636
637 depend: $(DEPS_MUTATORS)
638
639 depend_dir:
640         @echo "mut deps: $(DEPS_MUTATORS)"
641         @if [ -d $(DEPENDDIR) ]; then \
642           echo "Directory \"$(DEPENDDIR)\" already exists..."; \
643          else \
644           mkdir -p $(DEPENDIR); \
645           echo "Made \"$(DEPENDDIR)\" directory..."; \
646          fi
647
648 $(DEPENDDIR)/test_driver_static.dep: test_driver.C
649         @mkdir -p $(DEPENDDIR)
650         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) -DSTATIC_TEST_DRIVER $(DEPENDFLAGS) $*.o > $@
651
652 $(DEPS_MUTATORS): $(DEPENDDIR)/%.dep : %.C
653         @mkdir -p $(DEPENDDIR)
654         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
655
656 $(DEPS_SYMTAB_MUTATORS): $(DEPENDDIR)/%.dep : symtab/%.C
657         @mkdir -p $(DEPENDDIR)
658         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
659
660 $(DEPS_INSTRUCTION_MUTATORS): $(DEPENDDIR)/%.dep : instruction/%.C
661         @mkdir -p $(DEPENDDIR)
662         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
663
664 $(DEPS_PROCCONTROL_MUTATORS): $(DEPENDDIR)/%.dep : proccontrol/%.C
665         @mkdir -p $(DEPENDDIR)
666         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
667
668 $(DEPS_DYNINST_MUTATORS): $(DEPENDDIR)/%.dep : dyninst/%.C
669         @mkdir -p $(DEPENDDIR)
670         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
671
672 $(DEPS_MUTATEES_GCC): $(DEPENDDIR)/test%.mutatee_gcc.dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
673         @mkdir -p $(DEPENDDIR)
674         $(M_GCC) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_gcc.o > $@
675
676 $(DEPS_MUTATEES_GXX): $(DEPENDDIR)/test%.mutatee_g++.dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
677         @mkdir -p $(DEPENDDIR)
678         $(M_GXX) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_gxx.o > $@
679
680 $(DEPS_MUTATEES_G77): $(DEPENDDIR)/test%.mutatee_g77.dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
681         @mkdir -p $(DEPENDDIR)
682         $(M_G77) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_g77.o > $@
683
684
685 # Use gcc to generate deps for native compilers
686
687 ifdef NATIVE_CC
688 $(DEPS_MUTATEES_NATIVE_CC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CC).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
689         @mkdir -p $(DEPENDDIR)
690         $(M_GCC) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CC).o > $@
691 endif
692
693 ifdef NATIVE_CXX
694 $(DEPS_MUTATEES_NATIVE_CXX): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX).dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
695         @mkdir -p $(DEPENDDIR)
696         $(M_GXX) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX).o > $@
697 endif
698
699 ifdef NATIVE_FC
700 $(DEPS_MUTATEES_NATIVE_FC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_FC).dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
701         @mkdir -p $(DEPENDDIR)
702         $(M_G77) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_$(NATIVE_FC).o > $@
703 endif
704
705 ifdef NATIVE_CXX_OMP
706 $(DEPS_MUTATEES_NATIVE_CXX_OMP): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX_OMP).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
707         @mkdir -p $(DEPENDDIR)
708         $(M_GXX) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX_OMP).o > $@
709 endif
710
711
712 $(DEPS_DYNINST_TESTLIBS): $(DEPENDDIR)/lib%.dep : ../src/dyninst/lib%.c 
713         @mkdir -p $(DEPENDDIR)
714         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) lib$*.so > $@
715
716 $(DEPS_LIBTESTSUITE): $(DEPENDDIR)/%.dep : %.C
717         @mkdir -p $(DEPENDDIR)
718         $(DEPCC) $(CXXFLAGS) -I../src $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
719
720 $(DEPS_DYNINSTCOMP): $(DEPENDDIR)/%.dep : dyninst/%.C
721         @mkdir -p $(DEPENDDIR)
722         $(DEPCC) $(CXXFLAGS) -I../src -I../src/dyninst $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
723
724 $(DEPS_SYMTABCOMP): $(DEPENDDIR)/%.dep : symtab/%.C
725         @mkdir -p $(DEPENDDIR)
726         $(DEPCC) $(CXXFLAGS) -I../src -I../src/symtab $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
727
728 $(DEPS_INSTRUCTIONCOMP): $(DEPENDDIR)/%.dep : instruction/%.C
729         @mkdir -p $(DEPENDDIR)
730         $(DEPCC) $(CXXFLAGS) -I../src -I../src/instruction $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
731
732 $(DEPS_PROCCONTROLCOMP): $(DEPENDDIR)/%.dep : proccontrol/%.C
733         @mkdir -p $(DEPENDDIR)
734         $(DEPCC) $(CXXFLAGS) -I../src -I../src/proccontrol $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
735
736 # do not include dep files for "clean" targets
737 ifneq ($(MAKECMDGOALS),clean)
738 ifneq ($(MAKECMDGOALS),distclean)
739 ifneq ($(MAKECMDGOALS),echo)
740
741 -include $(DEPS_MUTATORS)
742 # -include $(DEPS_MUTATEES_GCC)
743 # -include $(DEPS_MUTATEES_GXX)
744 # -include $(DEPS_TESTLIBS)
745
746 ifdef M_G77
747 # -include $(DEPS_MUTATEES_G77)
748 endif
749
750 ifdef NATIVE_CC
751 # -include $(DEPS_MUTATEES_NATIVE_CC)
752 endif
753
754 ifdef NATIVE_CXX
755 -include $(DEPS_MUTATEES_NATIVE_CXX)
756 endif
757
758 ifdef NATIVE_FC
759 -include $(DEPS_MUTATEES_NATIVE_FC)
760 endif
761
762 ifdef NATIVE_CXX_OMP
763 -include $(DEPS_MUTATEES_NATIVE_CXX_OMP)
764 endif
765
766 endif
767 endif
768 endif