Merge branch 'master' of git.dyninst.org:/pub/dyninst
[dyninst.git] / newtestsuite / make.module.tmpl
1 #
2 # make.module.tmpl for test suite
3 # Not intended to be a seperate makefile, but to be used in conjunction with
4 # higher level, platform-specific makefiles in the build directories
5
6 RM = rm -f
7 RMDIR ?= rmdir
8 M_GCC ?= purify $(GCC)
9 M_GXX ?= $(GXX)
10 DEPCC ?= $(GCC)
11 DEPENDFLAGS ?= -MM -MT
12 DEPENDDIR = ./depends
13 VPATH   = ../src $(DEPENDDIR)
14
15 DYNINST_INCDIR = -I../../dyninstAPI/h
16 SYMTAB_INCDIR = -I../../symtabAPI/h
17 DYNUTIL_INCDIR = -I../../dynutil/h
18
19 IFLAGS += $(DYNINST_INCDIR)
20 IFLAGS += $(DYNUTIL_INCDIR)
21 IFLAGS += $(SYMTAB_INCDIR)
22
23 #######################################################################
24 ### We don't want all of the CFLAGS stuff that came from make.config.
25 ### Strip away most of it.
26 #######################################################################
27
28 CFLAGS = $(UNIFIED_DEF:%=%_test) -I../../../include -I../src -g
29 CXXFLAGS = $(CFLAGS)
30 CFLAGS_NATIVE = $(CFLAGS)
31 CXXFLAGS_NATIVE = $(CXXFLAGS)
32 MUTATEE_CFLAGS_NATIVE = $(CFLAGS)
33 MUTATEE_CXXFLAGS_NATIVE = $(CXXFLAGS)
34
35 #######################################################################
36 ###  Generate compiler id strings
37 ###
38 ###  COMPILERT_NATIVE_CC, COMPILERT_NATIVE_CXX must be defined prior to
39 ###  inclusion of this file.  gcc/g++ are handled here as platform-indep
40 ###
41 #######################################################################
42
43 EMPTY:=
44 BLANK:=$(EMPTY) $(EMPTY)
45 LPAREN:=(
46 RPAREN:=)
47 COMMA=,
48
49 COMPILERT_GCC = $(shell $(M_GCC) -v 2>&1 | grep version | head -1)
50 COMPILER1_GCC = $(subst $(BLANK),_,$(COMPILERT_GCC))
51 COMPILER2_GCC = $(subst $(LPAREN),_,$(COMPILER1_GCC))
52 COMPILER_GCC = $(subst $(RPAREN),_,$(COMPILER2_GCC))
53 MUTATEE_CFLAGS_GNU += -DCOMPILER='"$(COMPILER_GCC)"'
54
55 COMPILERT_GXX = $(shell $(M_GCC) -v 2>&1 | grep version | head -1)
56 COMPILER1_GXX = $(subst $(BLANK),_,$(COMPILERT_GXX))
57 COMPILER2_GXX = $(subst $(LPAREN),_,$(COMPILER1_GXX))
58 COMPILER_GXX = $(subst $(RPAREN),_,$(COMPILER2_GXX))
59 MUTATEE_CXXFLAGS_GNU += -DCOMPILER='"$(COMPILER_GXX)"'
60
61 COMPILER1_NATIVE_CC = $(subst $(BLANK),_,$(COMPILERT_NATIVE_CC))
62 COMPILER2_NATIVE_CC = $(subst $(LPAREN),_,$(COMPILER1_NATIVE_CC))
63 COMPILER_NATIVE_CC = $(subst $(RPAREN),_,$(COMPILER2_NATIVE_CC))
64 MUTATEE_CFLAGS_NATIVE += -DCOMPILER='"$(COMPILER_NATIVE_CC)"'
65
66 COMPILER1_NATIVE_CXX = $(subst $(BLANK),_,$(COMPILERT_NATIVE_CXX))
67 COMPILER2_NATIVE_CXX = $(subst $(LPAREN),_,$(COMPILER1_NATIVE_CXX))
68 COMPILER_NATIVE_CXX = $(subst $(RPAREN),_,$(COMPILER2_NATIVE_CXX))
69 MUTATEE_CXXFLAGS_NATIVE += -DCOMPILER='"$(COMPILER_NATIVE_CXX)"'
70
71 TEST_DEST = $(TO_CORE)/$(PROGRAM_DEST)/testprogs_new2
72 LIB_DEST = $(TO_CORE)/$(LIBRARY_DEST)
73
74 #######################################################################
75 ###  Basic definitions (filename prefixes)
76 #######################################################################
77
78 FORALL_MUTATORS =  
79
80 FORALL_MUTATEES = mutatee_util
81
82 SRCS_LIBTESTSUITE = test_lib.C \
83                     test_lib_soExecution.C \
84                     ParameterDict.C \
85                     TestData.C \
86                     TestMutator.C \
87                     TestOutputDriver.C \
88                     StdOutputDriver.C \
89                     ResumeLog.C \
90                     test_info_new.C
91
92 SRCS_TEMPLATES = test_driver_templates.C 
93
94 OBJS_LIBTESTSUITE = $(SRCS_LIBTESTSUITE:%.C=%.o)
95 OBJS_TEMPLATES = $(SRCS_TEMPLATES:%.C=%.o)
96
97 ifdef USE_LIBTESTSUITE_EXT_A
98 LIBTESTSUITE = libtestSuite.a
99 else
100 LIBTESTSUITE = libtestSuite.so
101 endif
102
103 #######################################################
104 # Dyninst infrastructure components
105 #######################################################
106 SRCS_DYNINSTCOMP_LIB = dyninst/dyninst_comp.C \
107                        dyninst/test_lib_mutateeStart.C \
108                        dyninst/Callbacks.C \
109                        dyninst/Process_data.C \
110                        dyninst/test_lib_test7.C \
111                        dyninst/test_lib_test9.C
112 OBJS_DYNINSTCOMP_LIB = $(notdir $(SRCS_DYNINSTCOMP_LIB:%.C=%.o))
113 SRCS_DYNINSTTESTLIB = dyninst/libtestA.c \
114                       dyninst/libtestB.c \
115                       dyninst/libInstMe.c \
116                       dyninst/libLoadMe.c \
117                       dyninst/libTest12.c
118 dyninst_MUTATOR_FLAGS = -L. -ltestdyninst -ldyninstAPI
119
120 ifdef M_ABI
121 DYNINST_TESTLIBS = $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%.so))
122 DYNINST_TESTLIBS_ABI = $(addsuffix _$(M_ABI).so, $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%)))
123 else
124 DYNINST_TESTLIBS = $(notdir $(SRCS_DYNINSTTESTLIB:%.c=%.so))
125 DYNINST_TESTLIBS_ABI =
126 endif
127
128 ifdef USE_LIBTESTSUITE_EXT_A
129 LIBDYNINSTCOMP = libtestdyninst.a
130 else
131 LIBDYNINSTCOMP = libtestdyninst.so
132 endif
133
134 dyninst_MUTATOR_LIB = $(LIBDYNINSTCOMP)
135
136
137 #######################################################
138 # Symtab infrastructure components
139 #######################################################
140 SRCS_SYMTABCOMP_LIB = symtab/symtab_comp.C
141 OBJS_SYMTABCOMP_LIB = $(notdir $(SRCS_SYMTABCOMP_LIB:%.C=%.o))
142 symtab_MUTATOR_FLAGS = -L. -ltestsymtab -lsymtabAPI
143
144 ifdef USE_LIBTESTSUITE_EXT_A
145 LIBSYMTABCOMP = libtestsymtab.a
146 else
147 LIBSYMTABCOMP = libtestsymtab.so
148 endif
149
150 symtab_MUTATOR_LIB = $(LIBSYMTABCOMP)
151
152 ######################################################################
153 ### Main target
154 ######################################################################
155
156 default: testlibs mutators mutatees_minimum drivers output_drivers components
157         @echo "**********************************************************"
158         @echo "* Build complete."
159         @echo "*"
160         @echo "* High optimization mutatees were not built, use 'make all'"
161         @echo "* to build them."
162         @echo "**********************************************************"
163
164 all: testlibs mutators mutatees drivers output_drivers components
165
166 # test_info_new.gen.o is special-cased because it makes use of the
167 # COMPILER_CONTROL_DEFS to determine which mutatees to enable for compilers
168 # that are not present at all sites.
169 test_info_new.gen.o: test_info_new.gen.C
170         $(CXX) -c -o $@ $(CXXFLAGS) $(COMPILER_CONTROL_DEFS) -I../src/ test_info_new.gen.C
171
172 #######################################################################
173 ###  A list of all the targets we're building, for install purposes
174 #######################################################################
175
176 ALL_TARGETS_DEST                = $(addprefix $(TEST_DEST)/,$(ALL_TARGETS))
177 LIBTESTSUITE_DEST               = $(addprefix $(TEST_DEST)/,$(LIBTESTSUITE))
178
179 #######################################################################
180 ###  Some pattern rules
181 #######################################################################
182
183 CXXTFLAGS := $(filter-out -fno-implicit-templates, $(CXXFLAGS))
184
185 #######################################################################
186 ###  High level targets
187 #######################################################################
188
189 MUTATOR_LDFLAGS := -L. -ltestSuite $(LIBDIR) $(MUTATOR_LIBS) $(MUTATOR_LDFLAGS) -lpthread
190 MUTATOR_SO_LDFLAGS = $(filter-out -liberty, $(MUTATOR_LDFLAGS))
191
192
193 # all: testlibs mutators mutatees drivers
194 # See also an addition to the 'all' rule at the end of the file
195
196 ### Automatically generated variables; generated by makemake.py
197
198 include make.mutators.gen
199
200 include make.solo_mutatee.gen
201
202 mutatees:
203
204 mutators:
205
206 components:
207
208 testlibs:
209
210 #######################################################################
211 ###  Filter results, if needed
212 #######################################################################
213
214 MINIMUM_BUILD_FILTER = %_max %_high %_low
215 ifneq ($(wildcard ../src/dyninst), )
216 mutatees: $(dyninst_SOLO_MUTATEES)
217 mutatees_minimum: $(filter-out $(MINIMUM_BUILD_FILTER), $(dyninst_SOLO_MUTATEES))
218 mutators: $(dyninst_MUTATORS_SO)
219 components: $(LIBDYNINSTCOMP)
220 testlibs: $(DYNINST_TESTLIBS) $(DYNINST_TESTLIBS_ABI)
221 endif
222
223 ifneq ($(wildcard ../src/symtab), )
224 mutatees: $(symtab_SOLO_MUTATEES)
225 mutatees_minimum: $(filter-out $(MINIMUM_BUILD_FILTER), $(symtab_SOLO_MUTATEES))
226 mutators: $(symtab_MUTATORS_SO)
227 components: $(LIBSYMTABCOMP)
228 testlibs:
229 endif
230
231 install: all
232
233 symlink: all
234
235 clean: clean_solo_mutatees
236         @$(RM) *.da *.bb. *.bbg 
237         @$(RM) $(TESTLIBS) $(TESTLIBS_ABI) $(LIBTESTSUITE) test_driver runTests libTest12.so
238         @$(RM) $(dyninst_MUTATORS_SO)
239 #       @$(RM) $(dyninst_SOLO_MUTATEES)
240         @$(RM) $(dyninst_SOLO_MUTATEES_gnu_cxx)
241         @$(RM) $(dyninst_SOLO_MUTATEES_native_cxx)
242         @$(RM) $(dyninst_SOLO_MUTATEES_gnu_cc)
243         @$(RM) $(dyninst_SOLO_MUTATEES_native_cc)
244         @$(RM) $(symtab_MUTATORS_SO)
245         @$(RM) $(symtab_SOLO_MUTATEES)
246         @$(RM) $(OUTPUT_DRIVERS)
247         @$(RM) $(LIBDYNINSTCOMP)
248         @$(RM) $(LIBSYMTABCOMP)
249         @$(RM) *.o
250         @$(RM) test11
251         @$(RM) imagefile
252         @$(RM) core core.*
253         @$(RM) -r _dyninstsaved*
254         @$(RM) *.ii *.ti
255         @$(RM) .__afs*
256  
257
258 distclean: clean
259         @if [ -d $(DEPENDDIR) ]; then \
260           $(RM) $(DEPENDDIR)/*.dep; \
261           rmdir $(DEPENDDIR); \
262          fi
263
264 specclean:
265         $(RM) *.gen *.pl tuples test_info_new.gen.C
266
267 ifdef M_ABI
268 $(CALL35_1_OBJ_ABI): $(CALL35_1_SRC_ABI)
269         $(M_GCC) $(M_ABI_FLAG) -c $< $(CFLAGS) $(MUTATEE_CFLAGS_GNU) -o $@ 
270 endif
271
272 testlibs: $(LIBTESTSUITE)
273
274 drivers: test_driver runTests
275
276 .PHONY: clean install distclean mutators mutatees testlibs gnu_mutatees native_mutatees echo all
277
278 #######################################################################
279 ###  Build command for test libraries
280 #######################################################################
281
282 $(dyninst_OBJS_ALL_MUTATORS): %.o : dyninst/%.C $(DEPENDDIR)/%.dep
283         $(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/dyninst ../src/dyninst/$*.C
284 $(symtab_OBJS_ALL_MUTATORS): %.o : symtab/%.C $(DEPENDDIR)/%.dep
285         $(CXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ -I../src/symtab ../src/symtab/$*.C
286
287 $(DYNINST_TESTLIBS): %.so : dyninst/%.c $(DEPENDDIR)/%.dep
288 ifdef MAKE_SHARED_LIB
289         $(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
290         $(MAKE_SHARED_LIB) $(TESTLIB_FLAGS) $*.o -o $@
291 else
292         $(CC) $(TESTLIB_FLAGS) -I../src/ $(filter %.c,$^) -o $@
293 endif
294
295 ifdef M_ABI
296 $(DYNINST_TESTLIBS_ABI): %_$(M_ABI).so : dyninst/%.c $(DEPENDDIR)/%.dep
297 ifdef MAKE_SHARED_LIB
298         $(CC) -c $(CFLAGS) $(CFLAGS_TESTLIBS) $(filter %.c, $^) -o $*.o
299         $(MAKE_SHARED_LIB) $(TESTLIB_FLAGS) $*.o -o $@
300 else
301         $(CC) $(M_ABI_FLAG) $(TESTLIB_FLAGS) -I../src/ $(filter %.c,$^) -o $@
302 endif
303 endif
304
305 $(OBJS_TEMPLATES): %.o : ../src/%.C
306         $(M_GXX) -c -o $@ $(CXXTFLAGS) -I../src/ ../src/$*.C
307
308 test_lib_templates.o : ../src/test_lib_templates.C
309         $(M_GXX) -c -o $@ -fPIC $(CXXTFLAGS) -I../src/ ../src/$*.C
310
311 $(OBJS_DYNINSTCOMP_LIB): %.o : ../src/dyninst/%.C $(DEPENDDIR)/%.dep
312         $(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/dyninst/$*.C
313
314 $(OBJS_SYMTABCOMP_LIB): %.o : ../src/symtab/%.C $(DEPENDDIR)/%.dep
315         $(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/symtab/$*.C
316
317 $(OBJS_LIBTESTSUITE): %.o : ../src/%.C $(DEPENDDIR)/%.dep
318         $(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/$*.C
319
320 $(LIBDYNINSTCOMP) : $(OBJS_DYNINSTCOMP_LIB) $(LIBTESTSUITE)
321         $(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_DYNINSTCOMP_LIB) -o $@ -L. -ltestSuite -ldyninstAPI -lsymtabAPI -lcommon
322
323 $(LIBSYMTABCOMP) : $(OBJS_SYMTABCOMP_LIB) $(LIBTESTSUITE)
324         $(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(OBJS_SYMTABCOMP_LIB) -o $@ -L. -ltestSuite -lsymtabAPI -lcommon
325
326 $(LIBTESTSUITE) : $(OBJS_LIBTESTSUITE) test_lib_templates.o test_lib.h
327         $(CXX) -shared $(TESTSUITE_FLAGS) $(LIBDIR) $(LIBS_LIBTESTSUITE) $(OBJS_LIBTESTSUITE) test_lib_templates.o -o $@
328
329 #
330 # Native Fortran mutatees
331
332 # There is no real advantage to generality here since there is only one fortran mutatee
333 # (ie for test1), thus all constituent files are built explicitly
334
335 ifdef NATIVE_FC 
336 test1.mutatee_$(NATIVE_FC).o: ../src/test1.mutateeFort.F
337         $(NATIVE_FC)  $(MUTATEE_NATIVE_FFLAGS) -c -o $@ $^ 
338 test1.mutateeFortC_$(NATIVE_FC).o: ../src/test1.mutateeFortC.c
339         $(NATIVE_FORTRAN_CC) $(MUTATEE_NATIVE_FC_CFLAGS) -c $(filter %.c,$^) -o $@
340
341 $(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
342         $(NATIVE_FC) -o $@ $(filter %.o,$^) $(MUTATEE_NATIVE_FC_LDFLAGS) $(MUTATEE_LIBS) 
343 endif
344
345 # Native OpenMP mutatees
346 # There is no real advantage to generality here since there is only one OpenMP mutatee
347 # (ie for test16), thus all constituent files are built explicitly
348 ifdef NATIVE_CXX_OMP 
349 test16.mutatee_$(NATIVE_CXX_OMP).o: ../src/test16.mutatee.c
350         $(NATIVE_CXX_OMP)  $(MUTATEE_NATIVE_CXX_CFLAGS) -o $@ $^ 
351
352 $(MUTATEES_NATIVE_CXX_OMP): test%.mutatee_$(NATIVE_CXX_OMP) : test%.mutatee_$(NATIVE_CXX_OMP).o $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX_OMP).dep
353         $(NATIVE_CXX_OMP) $(MUTATEE_NATIVE_CXX_OMP_LDFLAGS) -o $@ $(filter %.o,$^) $(MUTATEE_LIBS) 
354
355 #$(MUTATEES_NATIVE_CXX_OMP): ../src/test16.mutatee.c
356 #       $(NATIVE_CXX_OMP)  $(MUTATEE_NATIVE_CXX_CFLAGS) -o $@ $^ 
357
358 endif
359
360
361 # Install directory
362 $(TEST_DEST): 
363         mkdir $(TEST_DEST)
364
365 #######################################################################
366 ###  Generic Mutator build rule:
367 ###
368 ###  resorts to pattern matching test% (matches test1, test2, ... etc)
369 ###  to generate correct, minimal set of prerequisites for each test.
370 ###  It would be nicer to just match something simpler that wasn't 
371 ###  name-dependant, but gnu make is not making this easy.
372 ###
373 #######################################################################
374
375 MUTATEE_DEFS := -Dgnu_cc=_gcc -Dgnu_cxx=_g++
376
377 ifdef M_ABI
378 MUTATEE_DEFS += -Dgnu_abi_cc=_gcc_$(M_ABI) -Dgnu_abi_cxx=_g++_$(M_ABI) -Dm_abi
379 endif
380
381 ifdef M_G77
382 MUTATEE_DEFS += -Dgnu_fc=_g77
383 endif
384
385 ifdef NATIVE_CC
386 MUTATEE_DEFS += -Dnative_cc=_$(NATIVE_CC)
387 endif
388
389 ifdef NATIVE_CXX
390 MUTATEE_DEFS += -Dnative_cxx=_$(NATIVE_CXX)
391 endif
392
393 ifdef NATIVE_FC
394 MUTATEE_DEFS += -Dnative_fc=_$(NATIVE_FC)
395 endif
396
397 runTests.o: ../src/runTests.C $(DEPENDDIR)/runTests.dep
398         $(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/runTests.C
399 runTests_static.o: ../src/runTests.C $(DEPENDDIR)/runTests.dep
400         $(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) -DSTATIC_TEST_DRIVER ../src/runTests.C
401
402 runTests-utils.o: ../src/runTests-utils.C $(DEPENDDIR)/runTests-utils.dep
403         $(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/runTests-utils.C
404
405 runTests: runTests.o runTests-utils.o test_driver_templates.o 
406         $(CXX) $(CXXFLAGS) -o $@ runTests.o runTests-utils.o test_driver_templates.o 
407 runTests_static: runTests_static.o runTests-utils.o test_driver_templates.o 
408         $(CXX) $(CXXFLAGS) -o runTests runTests_static.o runTests-utils.o test_driver_templates.o 
409
410 test_driver.o: ../src/test_driver.C $(DEPENDDIR)/test_driver.dep
411         $(CXX) -c -o $@ $(CXXFLAGS) $(MUTATEE_DEFS) ../src/test_driver.C
412
413 test_driver_static.o: ../src/test_driver.C $(DEPENDDIR)/test_driver_static.dep
414         $(CXX) -c -o $@ -DSTATIC_TEST_DRIVER $(CXXFLAGS) $(MUTATEE_DEFS) ../src/test_driver.C
415
416 test_driver: test_driver.o test_driver_templates.o test_info_new.gen.o $(DEPENDDIR)/test_driver.dep $(LIBTESTSUITE)
417         $(CXX) -o $@ test_driver.o test_driver_templates.o test_info_new.gen.o $(MUTATOR_LDFLAGS) $(LIBS) $(TESTDRIVER_LDFLAGS)
418
419 ######################################################################
420 ### Output Drivers
421 ######################################################################
422
423 OUTPUT_DRIVERS = DatabaseOutputDriver.so
424
425 DatabaseOutputDriver.o : ../src/DatabaseOutputDriver.C # $(DEPENDDIR)/DatabaseOutputDriver.dep
426         $(M_GXX) -c -o $@ -fPIC $(CXXFLAGS) -I../src/ ../src/$*.C
427
428 DatabaseOutputDriver.so: DatabaseOutputDriver.o # $(DEPENDDIR)/DatabaseOutputDriver.dep
429         $(CXX) -o $@ -shared $(filter %.o,$^) $(MUTATOR_SO_LDFLAGS) $(LIBDIR) $(LIBS) $(LDFLAGS)
430 ifndef NO_OPT_FLAG
431 ifdef STRIP_SO
432         $(STRIP_SO) $@
433 endif
434 endif
435
436 .PHONY: output_drivers
437 output_drivers: $(OUTPUT_DRIVERS)
438
439 #######################################################################
440 ###  Depends
441 #######################################################################
442
443 DEPS_MUTATORS           += $(DEPENDDIR)/test_driver.dep
444 DEPS_MUTATORS           += $(DEPENDDIR)/runTests.dep $(DEPENDDIR)/runTests-utils.dep
445 DEPS_SYMTAB_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(symtab_OBJS_ALL_MUTATORS:%.o=%.dep))
446 DEPS_DYNINST_MUTATORS    += $(addprefix $(DEPENDDIR)/,$(dyninst_OBJS_ALL_MUTATORS:%.o=%.dep))
447
448 DEPS_MUTATEES_GCC       += $(addprefix $(DEPENDDIR)/,$(addsuffix _gcc.dep, $(MUTATEES_C)))
449 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX)))
450 DEPS_MUTATEES_GXX       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g++.dep, $(MUTATEES_CXX_ONLY)))
451 DEPS_DYNINST_TESTLIBS   = $(addprefix $(DEPENDDIR)/,$(DYNINST_TESTLIBS:%.so=%.dep))
452 DEPS_LIBTESTSUITE        = $(addprefix $(DEPENDDIR)/,$(SRCS_LIBTESTSUITE:%.C=%.dep))
453 DEPS_DYNINSTCOMP       =  $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_DYNINSTCOMP_LIB:%.C=%.dep)))
454 DEPS_SYMTABCOMP        = $(addprefix $(DEPENDDIR)/,$(notdir $(SRCS_SYMTABCOMP_LIB:%.C=%.dep)))
455
456 ifdef M_G77
457 DEPS_MUTATEES_G77       += $(addprefix $(DEPENDDIR)/,$(addsuffix _g77.dep, $(MUTATEES_FORTRAN)))
458 endif
459
460 ifdef NATIVE_FC
461 DEPS_MUTATEES_NATIVE_FC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_FC).dep, $(MUTATEES_FORTRAN)))
462 endif
463
464 ifdef NATIVE_CXX_OMP
465 DEPS_MUTATEES_NATIVE_CXX_OMP += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX_OMP).dep, $(MUTATEES_OPENMP)))
466 endif
467
468 ifdef NATIVE_CC
469 DEPS_MUTATEES_NATIVE_CC += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CC).dep, $(MUTATEES_C)))
470 endif
471
472 ifdef NATIVE_CXX
473 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX)))
474 DEPS_MUTATEES_NATIVE_CXX += $(addprefix $(DEPENDDIR)/,$(addsuffix _$(NATIVE_CXX).dep, $(MUTATEES_CXX_ONLY)))
475 endif
476
477 depend: $(DEPS_MUTATORS)
478
479 depend_dir:
480         @echo "mut deps: $(DEPS_MUTATORS)"
481         @if [ -d $(DEPENDDIR) ]; then \
482           echo "Directory \"$(DEPENDDIR)\" already exists..."; \
483          else \
484           mkdir -p $(DEPENDIR); \
485           echo "Made \"$(DEPENDDIR)\" directory..."; \
486          fi
487
488 $(DEPENDDIR)/test_driver_static.dep: test_driver.C
489         @mkdir -p $(DEPENDDIR)
490         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) -DSTATIC_TEST_DRIVER $(DEPENDFLAGS) $*.o > $@
491
492 $(DEPS_MUTATORS): $(DEPENDDIR)/%.dep : %.C
493         @mkdir -p $(DEPENDDIR)
494         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
495
496 $(DEPS_SYMTAB_MUTATORS): $(DEPENDDIR)/%.dep : symtab/%.C
497         @mkdir -p $(DEPENDDIR)
498         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
499
500 $(DEPS_DYNINST_MUTATORS): $(DEPENDDIR)/%.dep : dyninst/%.C
501         @mkdir -p $(DEPENDDIR)
502         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
503
504 $(DEPS_MUTATEES_GCC): $(DEPENDDIR)/test%.mutatee_gcc.dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
505         @mkdir -p $(DEPENDDIR)
506         $(M_GCC) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_gcc.o > $@
507
508 $(DEPS_MUTATEES_GXX): $(DEPENDDIR)/test%.mutatee_g++.dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
509         @mkdir -p $(DEPENDDIR)
510         $(M_GXX) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_gxx.o > $@
511
512 $(DEPS_MUTATEES_G77): $(DEPENDDIR)/test%.mutatee_g77.dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
513         @mkdir -p $(DEPENDDIR)
514         $(M_G77) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_g77.o > $@
515
516
517 # Use gcc to generate deps for native compilers
518
519 ifdef NATIVE_CC
520 $(DEPS_MUTATEES_NATIVE_CC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CC).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
521         @mkdir -p $(DEPENDDIR)
522         $(M_GCC) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CC).o > $@
523 endif
524
525 ifdef NATIVE_CXX
526 $(DEPS_MUTATEES_NATIVE_CXX): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX).dep : $(wildcard test%.mutatee.*) $(SRCS_FORALL_MUTATEES)
527         @mkdir -p $(DEPENDDIR)
528         $(M_GXX) $(CXXFLAGS) $< $(MUTATEE_CXXFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX).o > $@
529 endif
530
531 ifdef NATIVE_FC
532 $(DEPS_MUTATEES_NATIVE_FC): $(DEPENDDIR)/test%.mutatee_$(NATIVE_FC).dep : test%.mutateeFort.F $(SRCS_FORALL_MUTATEES)
533         @mkdir -p $(DEPENDDIR)
534         $(M_G77) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutateeFort_$(NATIVE_FC).o > $@
535 endif
536
537 ifdef NATIVE_CXX_OMP
538 $(DEPS_MUTATEES_NATIVE_CXX_OMP): $(DEPENDDIR)/test%.mutatee_$(NATIVE_CXX_OMP).dep : test%.mutatee.c $(SRCS_FORALL_MUTATEES)
539         @mkdir -p $(DEPENDDIR)
540         $(M_GXX) $(CFLAGS) $< $(MUTATEE_CFLAGS) $(DEPENDFLAGS) test$*.mutatee_$(NATIVE_CXX_OMP).o > $@
541 endif
542
543
544 $(DEPS_DYNINST_TESTLIBS): $(DEPENDDIR)/lib%.dep : ../src/dyninst/lib%.c 
545         @mkdir -p $(DEPENDDIR)
546         $(DEPCC) $(CXXFLAGS) $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) lib$*.so > $@
547
548 $(DEPS_LIBTESTSUITE): $(DEPENDDIR)/%.dep : %.C
549         @mkdir -p $(DEPENDDIR)
550         $(DEPCC) $(CXXFLAGS) -I../src $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
551
552 $(DEPS_DYNINSTCOMP): $(DEPENDDIR)/%.dep : dyninst/%.C
553         @mkdir -p $(DEPENDDIR)
554         $(DEPCC) $(CXXFLAGS) -I../src -I../src/dyninst $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
555
556 $(DEPS_SYMTABCOMP): $(DEPENDDIR)/%.dep : symtab/%.C
557         @mkdir -p $(DEPENDDIR)
558         $(DEPCC) $(CXXFLAGS) -I../src -I../src/symtab $< $(MUTATOR_CXXFLAGS) $(DEPENDFLAGS) $*.o > $@
559
560 # do not include dep files for "clean" targets
561 ifneq ($(MAKECMDGOALS),clean)
562 ifneq ($(MAKECMDGOALS),distclean)
563 ifneq ($(MAKECMDGOALS),echo)
564
565 -include $(DEPS_MUTATORS)
566 # -include $(DEPS_MUTATEES_GCC)
567 # -include $(DEPS_MUTATEES_GXX)
568 # -include $(DEPS_TESTLIBS)
569
570 ifdef M_G77
571 # -include $(DEPS_MUTATEES_G77)
572 endif
573
574 ifdef NATIVE_CC
575 # -include $(DEPS_MUTATEES_NATIVE_CC)
576 endif
577
578 ifdef NATIVE_CXX
579 -include $(DEPS_MUTATEES_NATIVE_CXX)
580 endif
581
582 ifdef NATIVE_FC
583 -include $(DEPS_MUTATEES_NATIVE_FC)
584 endif
585
586 ifdef NATIVE_CXX_OMP
587 -include $(DEPS_MUTATEES_NATIVE_CXX_OMP)
588 endif
589
590 endif
591 endif
592 endif