Little adjustment
[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 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 history.o funcnode.o funcinst.o predicate.o printf.o newfuzzer.o \
9            concretepredicate.o waitobj.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 TESTS_DIR := test
22
23 MARKDOWN := doc/Markdown/Markdown.pl
24
25 all: $(LIB_SO) tests README.html
26
27 debug: CPPFLAGS += -DCONFIG_DEBUG
28 debug: all
29
30 PHONY += docs
31 docs: *.c *.cc *.h README.html
32         doxygen
33
34 README.html: README.md
35         $(MARKDOWN) $< > $@
36
37 malloc.o: malloc.c
38         $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=1 $(CPPFLAGS) -Wno-unused-variable
39
40 printf.o: printf.c
41         $(CC) -fPIC -c printf.c $(CPPFLAGS)
42
43 futex.o: futex.cc
44         $(CXX) -fPIC -c futex.cc -std=c++11 $(CPPFLAGS)
45
46 %.o : %.cc
47         $(CXX) -MMD -MF .$@.d -fPIC -c $< $(CPPFLAGS)
48
49
50 $(LIB_SO): $(OBJECTS)
51         $(CXX) $(SHARED) -o $(LIB_SO) $+ $(LDFLAGS)
52
53 %.pdf: %.dot
54         dot -Tpdf $< -o $@
55
56 -include $(OBJECTS:%=.%.d)
57
58 PHONY += clean
59 clean:
60         rm -f *.o *.so .*.d *.pdf *.dot
61         $(MAKE) -C $(TESTS_DIR) clean
62
63 PHONY += mrclean
64 mrclean: clean
65         rm -rf docs
66
67 PHONY += tags
68 tags:
69         ctags -R
70
71 PHONY += tests
72 tests: $(LIB_SO)
73 #       $(MAKE) -C $(TESTS_DIR)
74
75 BENCH_DIR := benchmarks
76
77 PHONY += benchmarks
78 benchmarks: $(LIB_SO)
79         @if ! test -d $(BENCH_DIR); then \
80                 echo "Directory $(BENCH_DIR) does not exist" && \
81                 echo "Please clone the benchmarks repository" && \
82                 echo && \
83                 exit 1; \
84         fi
85         $(MAKE) -C $(BENCH_DIR)
86
87 PHONY += pdfs
88 pdfs: $(patsubst %.dot,%.pdf,$(wildcard *.dot))
89
90 .PHONY: $(PHONY)
91
92 # A 1-inch margin PDF generated by 'pandoc'
93 %.pdf: %.md
94         pandoc -o $@ $< -V header-includes='\usepackage[margin=1in]{geometry}'
95
96 tabbing:
97         uncrustify -c C.cfg --no-backup --replace *.cc
98         uncrustify -c C.cfg --no-backup --replace *.h
99         uncrustify -c C.cfg --no-backup --replace include/*
100