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