]> pd.if.org Git - nbds/blob - makefile
fix potential blocking behavior in ht,c
[nbds] / makefile
1 ###################################################################################################
2 # Written by Josh Dybnis and released to the public domain, as explained at
3 # http://creativecommons.org/licenses/publicdomain
4 #
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)
13
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
18
19 tests: $(TESTS) 
20
21 ###################################################################################################
22 # Run the tests
23 ###################################################################################################
24 test: $(addsuffix .log, $(TESTS))
25         @echo > /dev/null
26
27 $(addsuffix .log, $(TESTS)) : %.log : % 
28         @echo "Running $*" && $* | tee $*.log
29
30 ###################################################################################################
31 # Rebuild an executable if any of it's source files need to be recompiled 
32 #
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)
39
40 ###################################################################################################
41 # Build tags file for vi
42 ###################################################################################################
43 tags:
44         ctags -R .
45
46 ###################################################################################################
47
48 ###################################################################################################
49 clean:
50         rm -rfv output/*
51
52 .PHONY: clean test tags
53
54 ###################################################################################################
55 # Generate the dependencies lists for each executable
56 #
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) > $@
62
63 -include $(addsuffix .d, $(EXES))