add a separate rule for futex.o
[c11tester.git] / Makefile
1 include common.mk
2
3 OBJECTS := libthreads.o schedule.o model.o threads.o librace.o action.o \
4            nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
5            datarace.o impatomic.o cmodelint.o \
6            snapshot.o malloc.o mymemory.o common.o mutex.o conditionvariable.o \
7            context.o execution.o libannotate.o plugins.o pthread.o futex.o fuzzer.o \
8            sleeps.o
9
10 CPPFLAGS += -Iinclude -I.
11 LDFLAGS := -ldl -lrt -rdynamic
12 SHARED := -shared
13
14 # Mac OSX options
15 ifeq ($(UNAME), Darwin)
16 LDFLAGS := -ldl
17 SHARED := -Wl,-undefined,dynamic_lookup -dynamiclib
18 endif
19
20 TESTS_DIR := test
21
22 MARKDOWN := doc/Markdown/Markdown.pl
23
24 all: $(LIB_SO) tests README.html
25
26 debug: CPPFLAGS += -DCONFIG_DEBUG
27 debug: all
28
29 PHONY += docs
30 docs: *.c *.cc *.h README.html
31         doxygen
32
33 README.html: README.md
34         $(MARKDOWN) $< > $@
35
36 malloc.o: malloc.c
37         $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
38
39 futex.o: futex.cc
40         $(CXX) -fPIC -c futex.cc -std=c++11 $(CPPFLAGS)
41
42 %.o : %.cc
43         $(CXX) -MMD -MF .$@.d -fPIC -c $< $(CPPFLAGS)
44
45
46 $(LIB_SO): $(OBJECTS)
47         $(CXX) $(SHARED) -o $(LIB_SO) $+ $(LDFLAGS)
48
49 %.pdf: %.dot
50         dot -Tpdf $< -o $@
51
52 -include $(OBJECTS:%=.%.d)
53
54 PHONY += clean
55 clean:
56         rm -f *.o *.so .*.d *.pdf *.dot
57         $(MAKE) -C $(TESTS_DIR) clean
58
59 PHONY += mrclean
60 mrclean: clean
61         rm -rf docs
62
63 PHONY += tags
64 tags:
65         ctags -R
66
67 PHONY += tests
68 tests: $(LIB_SO)
69 #       $(MAKE) -C $(TESTS_DIR)
70
71 BENCH_DIR := benchmarks
72
73 PHONY += benchmarks
74 benchmarks: $(LIB_SO)
75         @if ! test -d $(BENCH_DIR); then \
76                 echo "Directory $(BENCH_DIR) does not exist" && \
77                 echo "Please clone the benchmarks repository" && \
78                 echo && \
79                 exit 1; \
80         fi
81         $(MAKE) -C $(BENCH_DIR)
82
83 PHONY += pdfs
84 pdfs: $(patsubst %.dot,%.pdf,$(wildcard *.dot))
85
86 .PHONY: $(PHONY)
87
88 # A 1-inch margin PDF generated by 'pandoc'
89 %.pdf: %.md
90         pandoc -o $@ $< -V header-includes='\usepackage[margin=1in]{geometry}'
91
92 tabbing:
93         uncrustify -c C.cfg --no-backup --replace *.cc
94         uncrustify -c C.cfg --no-backup --replace *.h