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