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