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
12 EXES := $(TESTS) output/txn_test
14 RUNTIME_SRCS := runtime/runtime.c runtime/rcu.c runtime/lwt.c runtime/mem.c
15 TEST_SRCS := $(RUNTIME_SRCS)
16 rcu_test_SRCS := $(TEST_SRCS)
17 list_test_SRCS := $(TEST_SRCS) struct/list.c
18 ht_test_SRCS := $(TEST_SRCS) struct/ht.c test/ht_test.c test/CuTest.c
19 txn_test_SRCS := $(TEST_SRCS) struct/ht.c txn/txn.c
25 ###################################################################################################
27 ###################################################################################################
28 test: $(addsuffix .log, $(TESTS))
31 $(addsuffix .log, $(TESTS)) : %.log : %
32 @echo "Running $*" && $* | tee $*.log
34 ###################################################################################################
35 # Rebuild an executable if any of it's source files need to be recompiled
37 # Note: Calculating dependancies as a side-effect of compilation is disabled. There is a bug in
38 # gcc. Compilation fails when -MM -MF is used and there is more than one source file.
39 # -MM -MT $@.d -MF $@.d
40 ###################################################################################################
41 $(EXES): output/% : output/%.d makefile
42 gcc $(CFLAGS) $(INCS) -DMAKE_$* -o $@ $($*_SRCS)
44 ###################################################################################################
45 # Build tags file for vi
46 ###################################################################################################
50 ###################################################################################################
52 ###################################################################################################
56 .PHONY: clean test tags
58 ###################################################################################################
59 # Generate the dependencies lists for each executable
61 # Note: -combine is removed from CFLAGS because of a bug in gcc. The compiler chokes when
62 # -MM is used with -combine.
63 ###################################################################################################
64 $(addsuffix .d, $(EXES)) : output/%.d :
65 gcc $(CFLAGS:-combine:) $(INCS) -DMAKE_$* -MM -MT $@ $($*_SRCS) > $@
67 -include $(addsuffix .d, $(EXES))