1 ###################################################################################################
2 # Written by Josh Dybnis and released to the public domain, as explained at
3 # http://creativecommons.org/licenses/publicdomain
5 ###################################################################################################
6 # Makefile for building programs with whole-program interfile optimization
7 ###################################################################################################
8 OPT := -fwhole-program -combine -03 #-DNDEBUG
9 CFLAGS := -g -Wall -Werror -std=c99 -m64 -fnested-functions #$(OPT) #-DENABLE_TRACE
10 INCS := $(addprefix -I, include)
11 TESTS := output/rcu_test output/list_test output/ht_test
14 RUNTIME_SRCS := runtime/runtime.c runtime/rcu.c runtime/lwt.c runtime/mem.c runtime/CuTest.c
15 rcu_test_SRCS := $(RUNTIME_SRCS)
16 list_test_SRCS := $(RUNTIME_SRCS) struct/list.c
17 ht_test_SRCS := $(RUNTIME_SRCS) struct/ht.c struct/ht_test.c
21 ###################################################################################################
23 ###################################################################################################
24 test: $(addsuffix .log, $(TESTS))
27 $(addsuffix .log, $(TESTS)) : %.log : %
28 @echo "Running $*" && $* | tee $*.log
30 ###################################################################################################
31 # Rebuild an executable if any of it's source files need to be recompiled
33 # Note: Calculating dependancies as a side-effect of compilation is disabled. There is a bug in
34 # gcc. Compilation fails when -MM -MF is used and there is more than one source file.
35 # -MM -MT $@.d -MF $@.d
36 ###################################################################################################
37 $(EXES): output/% : output/%.d makefile
38 gcc $(CFLAGS) $(INCS) -DMAKE_$* -o $@ $($*_SRCS)
40 ###################################################################################################
41 # Build tags file for vi
42 ###################################################################################################
46 ###################################################################################################
48 ###################################################################################################
52 .PHONY: clean test tags
54 ###################################################################################################
55 # Generate the dependencies lists for each executable
57 # Note: -combine is removed from CFLAGS because of a bug in gcc. The compiler chokes when
58 # -MM is used with -combine.
59 ###################################################################################################
60 $(addsuffix .d, $(EXES)) : output/%.d :
61 gcc $(CFLAGS:-combine:) $(INCS) -DMAKE_$* -MM -MT $@ $($*_SRCS) > $@
63 -include $(addsuffix .d, $(EXES))