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