bug 1100: snip_ref_shlib_var fix
[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) $(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 += -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 += -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 := $(LIBDIR) $(MUTATOR_LIBS) $(MUTATOR_LDFLAGS) -lpthread
252 MUTATOR_SO_LDFLAGS = $(filter-out -liberty, $(MUTATOR_LDFLAGS))
253
254
255 # all: testlibs mutators mutatees drivers
256 # See also an addition to the 'all' rule at the end of the file
257
258 ### Automatically generated variables; generated by makemake.py
259
260 include make.mutators.gen
261
262 include make.solo_mutatee.gen
263
264 mutatees:
265
266 mutators:
267
268 components:
269
270 testlibs:
271
272 #######################################################################
273 ###  Filter results, if needed
274 #######################################################################
275
276 MINIMUM_BUILD_FILTER = %_max %_high %_low
277 BUILD_FILTER =
278 ifdef SKIP_BUILD_RTLIB_32
279         BUILD_FILTER += %_32_max %_32_high %_32_low %_32_none
280 endif
281
282 ifneq ($(wildcard ../src/dyninst), )
283 mutatees: $(filter-out $(BUILD_FILTER), $(dyninst_SOLO_MUTATEES))
284 mutatees_minimum: $(filter-out $(BUILD_FILTER), $(filter-out $(MINIMUM_BUILD_FILTER), $(dyninst_SOLO_MUTATEES)))
285 mutators: $(dyninst_MUTATORS_SO)
286 components: $(LIBDYNINSTCOMP)
287 testlibs: $(DYNINST_TESTLIBS) $(DYNINST_STATIC_TESTLIBS)
288 ifndef SKIP_BUILD_RTLIB_32
289 testlibs: $(DYNINST_TESTLIBS_ABI) $(DYNINST_STATIC_TESTLIBS_ABI)
290 endif
291 endif
292
293 ifneq ($(wildcard ../src/symtab), )
294 mutatees: $(filter-out $(BUILD_FILTER), $(symtab_SOLO_MUTATEES))
295 mutatees_minimum: $(filter-out $(BUILD_FILTER), $(filter-out $(MINIMUM_BUILD_FILTER), $(symtab_SOLO_MUTATEES)))
296 mutators: $(symtab_MUTATORS_SO)
297 components: $(LIBSYMTABCOMP)
298 testlibs:
299 endif
300
301 ifneq ($(wildcard ../src/instruction), )
302 mutatees: $(filter-out $(BUILD_FILTER), $(instruction_SOLO_MUTATEES))
303 mutatees_minimum: $(filter-out $(BUILD_FILTER), $(filter-out $(MINIMUM_BUILD_FILTER), $(instruction_SOLO_MUTATEES)))
304 mutators: $(instruction_MUTATORS_SO)
305 ifneq ($(instruction_MUTATORS_SO), )
306 components: $(LIBINSTRUCTIONCOMP)
307 testlibs:
308 endif
309 endif
310
311 ifneq ($(wildcard ../src/proccontrol), )
312 mutatees: $(proccontrol_SOLO_MUTATEES)
313 mutatees_minimum: $(filter-out $(MINIMUM_BUILD_FILTER), $(proccontrol_SOLO_MUTATEES))
314 mutators: $(proccontrol_MUTATORS_SO)
315 ifneq ($(proccontrol_MUTATORS_SO), )
316 components: $(LIBPROCCONTROLCOMP)
317 testlibs: $(PROCCONTROL_TESTLIBS) $(PROCCONTROL_TESTLIBS_ABI)
318 endif
319 endif
320
321
322 install: all
323
324 symlink: all
325
326 clean: clean_solo_mutatees dyninst_clean_solo_mutatees
327         @$(RM) *.da *.bb. *.bbg 
328         @$(RM) $(TESTLIBS) $(TESTLIBS_ABI) $(LIBTESTSUITE) test_driver runTests libTest12.so
329         @$(RM) $(dyninst_MUTATORS_SO)
330         @$(RM) $(symtab_MUTATORS_SO)
331         @$(RM) $(symtab_SOLO_MUTATEES)
332         @$(RM) $(instruction_MUTATORS_SO)
333         @$(RM) $(instruction_SOLO_MUTATEES)
334         @$(RM) $(proccontrol_MUTATORS_SO)
335         @$(RM) $(proccontrol_SOLO_MUTATEES)
336         @$(RM) $(OUTPUT_DRIVERS)
337         @$(RM) $(LIBDYNINSTCOMP)
338         @$(RM) $(LIBSYMTABCOMP)
339         @$(RM) $(LIBINSTRUCTIONCOMP)
340         @$(RM) $(DYNINST_TESTLIBS) $(DYNINST_STATIC_TESTLIBS) $(DYNINST_TESTLIBS_ABI) $(DYNINST_STATIC_TESTLIBS_ABI)
341         @$(RM) *.o
342         @$(RM) test11
343         @$(RM) imagefile
344         @$(RM) core core.*
345         @$(RM) -r _dyninstsaved*
346         @$(RM) *.ii *.ti
347         @$(RM) .__afs*
348  
349
350 distclean: clean
351         @if [ -d $(DEPENDDIR) ]; then \
352           $(RM) $(DEPENDDIR)/*.dep; \
353           rmdir $(DEPENDDIR); \
354          fi
355
356 specclean:
357         $(RM) *.gen *.pl tuples test_info_new.gen.C
358
359 ifdef M_ABI
360 $(CALL35_1_OBJ_ABI): $(CALL35_1_SRC_ABI)
361         $(M_GCC) $(M_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@ 
362 endif
363
364 testlibs: $(LIBTESTSUITE)
365
366 drivers: test_driver runTests
367
368 .PHONY: clean install distclean mutators mutatees testlibs gnu_mutatees native_mutatees echo all
369
370 #######################################################################
371 ###  Build command for test libraries
372 #######################################################################
373
374 $(dyninst_OBJS_ALL_MUTATORS): %.o : dyninst/%.C $(DEPENDDIR)/%.dep
375         @echo Compiling $<
376         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/dyninst ../src/dyninst/$*.C
377 $(symtab_OBJS_ALL_MUTATORS): %.o : symtab/%.C $(DEPENDDIR)/%.dep
378         @echo Compiling $<
379         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/symtab ../src/symtab/$*.C
380 $(instruction_OBJS_ALL_MUTATORS): %.o : instruction/%.C $(DEPENDDIR)/%.dep
381         @echo Compiling $<
382         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/instruction ../src/instruction/$*.C
383 $(proccontrol_OBJS_ALL_MUTATORS): %.o : proccontrol/%.C $(DEPENDDIR)/%.dep
384         @echo Compiling $<
385         @$(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/proccontrol ../src/proccontrol/$*.C
386
387 $(DYNINST_TESTLIBS): %.so : dyninst/%.c $(DEPENDDIR)/%.dep
388 ifdef MAKE_SHARED_LIB
389         @echo Compiling $<
390         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
391         @$(MAKE_SHARED_LIB) $(TESTLIB_FLAGS) $*.o -o $@
392 else
393         @echo Compiling $<
394         @$(CC) $(TESTLIB_FLAGS) -I../src/ $(filter %.c,$^) -o $@
395 endif
396
397 $(DYNINST_STATIC_TESTLIBS): %.a : dyninst/%.c $(DEPENDDIR)/%.dep
398         @echo Compiling $<
399         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
400         @$(AR) rcs $@ $*.o
401
402 ifdef M_ABI
403 $(DYNINST_TESTLIBS_ABI): %_$(M_ABI).so : dyninst/%.c $(DEPENDDIR)/%.dep
404 ifdef MAKE_SHARED_LIB
405         @echo Compiling $<
406         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
407         @$(MAKE_SHARED_LIB) $(TESTLIB_FLAGS) $*.o -o $@
408 else
409         @echo Compiling $<
410         @$(CC) $(M_ABI_FLAG) $(TESTLIB_FLAGS) -I../src/ $(filter %.c,$^) -o $@
411 endif
412
413 ifdef cap_instruction_api
414     INSNAPI_LINK = -linstructionAPI
415 endif
416
417 $(DYNINST_STATIC_TESTLIBS_ABI): %_$(M_ABI).a : dyninst/%.c $(DEPENDDIR)/%.dep
418         @echo Compiling $<
419         @$(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
420         @$(AR) rcs $@ $*.o
421 endif
422
423 $(OBJS_TEMPLATES): %.o : ../src/%.C
424         @echo Compiling $<
425         @$(M_GXX) -c -o $@ $(CXXTFLAGS) -I../src/ ../src/$*.C
426
427 test_lib_templates.o : ../src/test_lib_templates.C
428         @echo Compiling $<
429         @$(M_GXX) -c -o $@ -fPIC $(CXXTFLAGS) -I../src/ ../src/$*.C
430
431 $(OBJS_DYNINSTCOMP_LIB): %.o : ../src/dyninst/%.C $(DEPENDDIR)/%.dep
432         @echo Compiling $<
433         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/dyninst/$*.C
434
435 $(OBJS_SYMTABCOMP_LIB): %.o : ../src/symtab/%.C $(DEPENDDIR)/%.dep
436         @echo Compiling $<
437         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/symtab/$*.C
438
439 $(OBJS_INSTRUCTIONCOMP_LIB): %.o : ../src/instruction/%.C $(DEPENDDIR)/%.dep
440         @echo Compiling $<
441         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/instruction/$*.C
442
443 $(OBJS_PROCCONTROLCOMP_LIB): %.o : ../src/proccontrol/%.C $(DEPENDDIR)/%.dep
444         @echo Compiling $<
445         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/proccontrol/$*.C
446
447 $(OBJS_LIBTESTSUITE): %.o : ../src/%.C $(DEPENDDIR)/%.dep
448         @echo Compiling $<
449         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/$*.C
450
451 $(LIBDYNINSTCOMP) : $(OBJS_DYNINSTCOMP_LIB) $(LIBTESTSUITE)
452         @echo Compiling $<
453         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_DYNINSTCOMP_LIB) -o $@ -L. -ltestSuite -ldyninstAPI -lsymtabAPI \
454 -lcommon -linstructionAPI
455
456 $(LIBSYMTABCOMP) : $(OBJS_SYMTABCOMP_LIB) $(LIBTESTSUITE)
457         @echo Compiling $<
458         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_SYMTABCOMP_LIB) -o $@ -L. -ltestSuite -lsymtabAPI -lcommon
459
460 $(LIBINSTRUCTIONCOMP) : $(OBJS_INSTRUCTIONCOMP_LIB) $(LIBTESTSUITE)
461         @echo Compiling $<
462         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_INSTRUCTIONCOMP_LIB) -o $@ -L. -ltestSuite -linstructionAPI -lcommon
463
464 $(LIBPROCCONTROLCOMP) : $(OBJS_PROCCONTROLCOMP_LIB) $(LIBTESTSUITE)
465         @echo Compiling $<
466         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_PROCCONTROLCOMP_LIB) -o $@ -L. -ltestSuite -lpcontrol -lcommon
467
468 $(LIBTESTSUITE) : $(OBJS_LIBTESTSUITE) test_lib_templates.o test_lib.h
469         @echo Compiling $<
470         @$(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(LIBS_LIBTESTSUITE) $(OBJS_LIBTESTSUITE) test_lib_templates.o -o $@
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)  $(MUTATEE_NATIVE_FFLAGS) -c -o $@ $^ 
481 test1.mutateeFortC_$(NATIVE_FC).o: ../src/test1.mutateeFortC.c
482         $(NATIVE_FORTRAN_CC) $(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) -o $@ $(filter %.o,$^) $(MUTATEE_NATIVE_FC_LDFLAGS) $(MUTATEE_LIBS) 
486 endif
487
488 # Native OpenMP mutatees
489 # There is no real advantage to generality here since there is only one OpenMP mutatee
490 # (ie for test16), thus all constituent files are built explicitly
491 ifdef NATIVE_CXX_OMP 
492 test16.mutatee_$(NATIVE_CXX_OMP).o: ../src/test16.mutatee.c
493         $(NATIVE_CXX_OMP)  $(MUTATEE_NATIVE_CXX_CFLAGS) -o $@ $^ 
494
495 $(MUTATEES_NATIVE_CXX_OMP): test%.mutatee_$(NATIVE_CXX_OMP) : test%.mutatee_$(NATIVE_CXX_OMP).o $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX_OMP).dep
496         $(NATIVE_CXX_OMP) $(MUTATEE_NATIVE_CXX_OMP_LDFLAGS) -o $@ $(filter %.o,$^) $(MUTATEE_LIBS) 
497
498 #$(MUTATEES_NATIVE_CXX_OMP): ../src/test16.mutatee.c
499 #       $(NATIVE_CXX_OMP)  $(MUTATEE_NATIVE_CXX_CFLAGS) -o $@ $^ 
500
501 endif
502
503
504 # Install directory
505 $(TEST_DEST): 
506         mkdir $(TEST_DEST)
507
508 #######################################################################
509 ###  Generic Mutator build rule:
510 ###
511 ###  resorts to pattern matching test% (matches test1, test2, ... etc)
512 ###  to generate correct, minimal set of prerequisites for each test.
513 ###  It would be nicer to just match something simpler that wasn't 
514 ###  name-dependant, but gnu make is not making this easy.
515 ###
516 #######################################################################
517
518 MUTATEE_DEFS := -Dgnu_cc=_gcc -Dgnu_cxx=_g++
519
520 ifdef M_ABI
521 MUTATEE_DEFS += -Dgnu_abi_cc=_gcc_$(M_ABI) -Dgnu_abi_cxx=_g++_$(M_ABI) -Dm_abi
522 endif
523
524 ifdef M_G77
525 MUTATEE_DEFS += -Dgnu_fc=_g77
526 endif
527
528 ifdef NATIVE_CC
529 MUTATEE_DEFS += -Dnative_cc=_$(NATIVE_CC)
530 endif
531
532 ifdef NATIVE_CXX
533 MUTATEE_DEFS += -Dnative_cxx=_$(NATIVE_CXX)
534 endif
535
536 ifdef NATIVE_FC
537 MUTATEE_DEFS += -Dnative_fc=_$(NATIVE_FC)
538 endif
539
540 runTests.o: ../src/runTests.C $(DEPENDDIR)/runTests.dep
541         @echo Compiling $<
542         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/runTests.C
543 runTests_static.o: ../src/runTests.C $(DEPENDDIR)/runTests.dep
544         @echo Compiling $<
545         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) -DSTATIC_TEST_DRIVER ../src/runTests.C
546
547 runTests-utils.o: ../src/runTests-utils.C $(DEPENDDIR)/runTests-utils.dep
548         @echo Compiling $<
549         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/runTests-utils.C
550
551 runTests: runTests.o runTests-utils.o test_driver_templates.o 
552         @echo Linking $@
553         @$(CXX) $(CXXFLAGS) -o $@ runTests.o runTests-utils.o test_driver_templates.o 
554 runTests_static: runTests_static.o runTests-utils.o test_driver_templates.o 
555         @echo Linking $@
556         @$(CXX) $(CXXFLAGS) -o runTests runTests_static.o runTests-utils.o test_driver_templates.o 
557
558 test_driver.o: ../src/test_driver.C $(DEPENDDIR)/test_driver.dep
559         @echo Compiling $<
560         @$(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/test_driver.C
561
562 test_driver_static.o: ../src/test_driver.C $(DEPENDDIR)/test_driver_static.dep
563         @echo Compiling $<
564         @$(CXX) -c -o $@ -DSTATIC_TEST_DRIVER $(CXXFLAGS) $(MUTATEE_DEFS) ../src/test_driver.C
565
566 test_driver: test_driver.o test_driver_templates.o test_info_new.gen.o $(DEPENDDIR)/test_driver.dep $(LIBTESTSUITE)
567         @echo Linking $@ $(TESTDRIVER_LDFLAGS)
568         $(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)
569         
570
571 ######################################################################
572 ### Output Drivers
573 ######################################################################
574
575 OUTPUT_DRIVERS = DatabaseOutputDriver.so
576
577 DatabaseOutputDriver.o : ../src/DatabaseOutputDriver.C # $(DEPENDDIR)/DatabaseOutputDriver.dep
578         @echo Compiling $<
579         @$(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/$*.C
580
581 DatabaseOutputDriver.so: DatabaseOutputDriver.o $(LIBTESTSUITE) # $(DEPENDDIR)/DatabaseOutputDriver.dep
582         @echo Linking $@
583         @$(CXX) -o $@ -shared $(filter %.o,$^) $(MUTATOR_SO_LDFLAGS) $(LIBDIR) $(LIBS) $(LDFLAGS) -L. -ltestSuite
584 ifndef NO_OPT_FLAG
585 ifdef STRIP_SO
586         $(STRIP_SO) $@
587 endif
588 endif
589
590 .PHONY: output_drivers
591 output_drivers: $(OUTPUT_DRIVERS)
592
593 #######################################################################
594 ###  Depends
595 #######################################################################
596
597 DEPS_MUTATORS           += $(DEPENDDIR)/test_driver.dep
598 DEPS_MUTATORS           += $(DEPENDDIR)/runTests.dep $(DEPENDDIR)/runTests-utils.dep
599 DEPS_SYMTAB_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(symtab_OBJS_ALL_MUTATORS:%.o=%.dep))
600 DEPS_DYNINST_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(dyninst_OBJS_ALL_MUTATORS:%.o=%.dep))
601 DEPS_INSTRUCTION_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(instruction_OBJS_ALL_MUTATORS:%.o=%.dep))
602 DEPS_PROCCONTROL_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(proccontrol_OBJS_ALL_MUTATORS:%.o=%.dep))
603
604 DEPS_MUTATEES_GCC       += $(addprefix $(DEPENDDIR)/,$(addsuffix _gcc.dep, $(MUTATEES_C)))
605 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX)))
606 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX_ONLY)))
607 DEPS_DYNINST_TESTLIBS   = $(addprefix $(DEPENDDIR)/,$(DYNINST_TESTLIBS:%.so=%.dep))
608 DEPS_LIBTESTSUITE        = $(addprefix $(DEPENDDIR)/,$(SRCS_LIBTESTSUITE:%.C=%.dep))
609 DEPS_DYNINSTCOMP       =  $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_DYNINSTCOMP_LIB:%.C=%.dep)))
610 DEPS_SYMTABCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_SYMTABCOMP_LIB:%.C=%.dep)))
611 DEPS_INSTRUCTIONCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_INSTRUCTIONCOMP_LIB:%.C=%.dep)))
612 DEPS_PROCCONTROLCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_PROCCONTROLCOMP_LIB:%.C=%.dep)))
613
614 ifdef M_G77
615 DEPS_MUTATEES_G77       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g77.dep, $(MUTATEES_FORTRAN)))
616 endif
617
618 ifdef NATIVE_FC
619 DEPS_MUTATEES_NATIVE_FC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_FC).dep, $(MUTATEES_FORTRAN)))
620 endif
621
622 ifdef NATIVE_CXX_OMP
623 DEPS_MUTATEES_NATIVE_CXX_OMP += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX_OMP).dep, $(MUTATEES_OPENMP)))
624 endif
625
626 ifdef NATIVE_CC
627 DEPS_MUTATEES_NATIVE_CC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CC).dep, $(MUTATEES_C)))
628 endif
629
630 ifdef NATIVE_CXX
631 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX)))
632 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX_ONLY)))
633 endif
634
635 depend: $(DEPS_MUTATORS)
636
637 depend_dir:
638         @echo "mut deps: $(DEPS_MUTATORS)"
639         @if [ -d $(DEPENDDIR) ]; then \
640           echo "Directory \"$(DEPENDDIR)\" already exists..."; \
641          else \
642           mkdir -p $(DEPENDIR); \
643           echo "Made \"$(DEPENDDIR)\" directory..."; \
644          fi
645
646 $(DEPENDDIR)/test_driver_static.dep: test_driver.C
647         @mkdir -p $(DEPENDDIR)
648         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) -DSTATIC_TEST_DRIVER $(DEPENDFLAGS) $*.o > $@
649
650 $(DEPS_MUTATORS): $(DEPENDDIR)/%.dep : %.C
651         @mkdir -p $(DEPENDDIR)
652         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
653
654 $(DEPS_SYMTAB_MUTATORS): $(DEPENDDIR)/%.dep : symtab/%.C
655         @mkdir -p $(DEPENDDIR)
656         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
657
658 $(DEPS_INSTRUCTION_MUTATORS): $(DEPENDDIR)/%.dep : instruction/%.C
659         @mkdir -p $(DEPENDDIR)
660         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
661
662 $(DEPS_PROCCONTROL_MUTATORS): $(DEPENDDIR)/%.dep : proccontrol/%.C
663         @mkdir -p $(DEPENDDIR)
664         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
665
666 $(DEPS_DYNINST_MUTATORS): $(DEPENDDIR)/%.dep : dyninst/%.C
667         @mkdir -p $(DEPENDDIR)
668         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
669
670 $(DEPS_MUTATEES_GCC): $(DEPENDDIR)/test%.mutatee_gcc.dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
671         @mkdir -p $(DEPENDDIR)
672         $(M_GCC) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_gcc.o > $@
673
674 $(DEPS_MUTATEES_GXX): $(DEPENDDIR)/test%.mutatee_g++.dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
675         @mkdir -p $(DEPENDDIR)
676         $(M_GXX) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_gxx.o > $@
677
678 $(DEPS_MUTATEES_G77): $(DEPENDDIR)/test%.mutatee_g77.dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
679         @mkdir -p $(DEPENDDIR)
680         $(M_G77) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_g77.o > $@
681
682
683 # Use gcc to generate deps for native compilers
684
685 ifdef NATIVE_CC
686 $(DEPS_MUTATEES_NATIVE_CC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CC).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
687         @mkdir -p $(DEPENDDIR)
688         $(M_GCC) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CC).o > $@
689 endif
690
691 ifdef NATIVE_CXX
692 $(DEPS_MUTATEES_NATIVE_CXX): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX).dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
693         @mkdir -p $(DEPENDDIR)
694         $(M_GXX) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX).o > $@
695 endif
696
697 ifdef NATIVE_FC
698 $(DEPS_MUTATEES_NATIVE_FC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_FC).dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
699         @mkdir -p $(DEPENDDIR)
700         $(M_G77) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_$(NATIVE_FC).o > $@
701 endif
702
703 ifdef NATIVE_CXX_OMP
704 $(DEPS_MUTATEES_NATIVE_CXX_OMP): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX_OMP).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
705         @mkdir -p $(DEPENDDIR)
706         $(M_GXX) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX_OMP).o > $@
707 endif
708
709
710 $(DEPS_DYNINST_TESTLIBS): $(DEPENDDIR)/lib%.dep : ../src/dyninst/lib%.c 
711         @mkdir -p $(DEPENDDIR)
712         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) lib$*.so > $@
713
714 $(DEPS_LIBTESTSUITE): $(DEPENDDIR)/%.dep : %.C
715         @mkdir -p $(DEPENDDIR)
716         $(DEPCC) $(CXXFLAGS) -I../src $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
717
718 $(DEPS_DYNINSTCOMP): $(DEPENDDIR)/%.dep : dyninst/%.C
719         @mkdir -p $(DEPENDDIR)
720         $(DEPCC) $(CXXFLAGS) -I../src -I../src/dyninst $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
721
722 $(DEPS_SYMTABCOMP): $(DEPENDDIR)/%.dep : symtab/%.C
723         @mkdir -p $(DEPENDDIR)
724         $(DEPCC) $(CXXFLAGS) -I../src -I../src/symtab $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
725
726 $(DEPS_INSTRUCTIONCOMP): $(DEPENDDIR)/%.dep : instruction/%.C
727         @mkdir -p $(DEPENDDIR)
728         $(DEPCC) $(CXXFLAGS) -I../src -I../src/instruction $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
729
730 $(DEPS_PROCCONTROLCOMP): $(DEPENDDIR)/%.dep : proccontrol/%.C
731         @mkdir -p $(DEPENDDIR)
732         $(DEPCC) $(CXXFLAGS) -I../src -I../src/proccontrol $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
733
734 # do not include dep files for "clean" targets
735 ifneq ($(MAKECMDGOALS),clean)
736 ifneq ($(MAKECMDGOALS),distclean)
737 ifneq ($(MAKECMDGOALS),echo)
738
739 -include $(DEPS_MUTATORS)
740 # -include $(DEPS_MUTATEES_GCC)
741 # -include $(DEPS_MUTATEES_GXX)
742 # -include $(DEPS_TESTLIBS)
743
744 ifdef M_G77
745 # -include $(DEPS_MUTATEES_G77)
746 endif
747
748 ifdef NATIVE_CC
749 # -include $(DEPS_MUTATEES_NATIVE_CC)
750 endif
751
752 ifdef NATIVE_CXX
753 -include $(DEPS_MUTATEES_NATIVE_CXX)
754 endif
755
756 ifdef NATIVE_FC
757 -include $(DEPS_MUTATEES_NATIVE_FC)
758 endif
759
760 ifdef NATIVE_CXX_OMP
761 -include $(DEPS_MUTATEES_NATIVE_CXX_OMP)
762 endif
763
764 endif
765 endif
766 endif