run.sh: don't silently ignore a non-executable file argument
[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 promise.o conditionvariable.o \
7            context.o scanalysis.o execution.o plugins.o
8
9 CPPFLAGS += -Iinclude -I.
10 LDFLAGS := -ldl -lrt -rdynamic
11 SHARED := -shared
12
13 # Mac OSX options
14 ifeq ($(UNAME), Darwin)
15 LDFLAGS := -ldl
16 SHARED := -Wl,-undefined,dynamic_lookup -dynamiclib
17 endif
18
19 TESTS_DIR := test
20
21 MARKDOWN := doc/Markdown/Markdown.pl
22
23 all: $(LIB_SO) tests 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 $(LIB_SO): $(OBJECTS)
36         $(CXX) $(SHARED) -o $(LIB_SO) $+ $(LDFLAGS)
37
38 malloc.o: malloc.c
39         $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
40
41 %.o: %.cc
42         $(CXX) -MMD -MF .$@.d -fPIC -c $< $(CPPFLAGS)
43
44 %.pdf: %.dot
45         dot -Tpdf $< -o $@
46
47 -include $(OBJECTS:%=.%.d)
48
49 PHONY += clean
50 clean:
51         rm -f *.o *.so .*.d *.pdf *.dot
52         $(MAKE) -C $(TESTS_DIR) clean
53
54 PHONY += mrclean
55 mrclean: clean
56         rm -rf docs
57
58 PHONY += tags
59 tags:
60         ctags -R
61
62 PHONY += tests
63 tests: $(LIB_SO)
64         $(MAKE) -C $(TESTS_DIR)
65
66 BENCH_DIR := benchmarks
67
68 PHONY += benchmarks
69 benchmarks: $(LIB_SO)
70         @if ! test -d $(BENCH_DIR); then \
71                 echo "Directory $(BENCH_DIR) does not exist" && \
72                 echo "Please clone the benchmarks repository" && \
73                 echo && \
74                 exit 1; \
75         fi
76         $(MAKE) -C $(BENCH_DIR)
77
78 PHONY += pdfs
79 pdfs: $(patsubst %.dot,%.pdf,$(wildcard *.dot))
80
81 .PHONY: $(PHONY)