towards supporting scanalysis...
[cdsspec-compiler.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
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 all: $(LIB_SO) tests
22
23 debug: CPPFLAGS += -DCONFIG_DEBUG
24 debug: all
25
26 PHONY += docs
27 docs: *.c *.cc *.h
28         doxygen
29
30 $(LIB_SO): $(OBJECTS)
31         $(CXX) $(SHARED) -o $(LIB_SO) $+ $(LDFLAGS)
32
33 malloc.o: malloc.c
34         $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
35
36 %.o: %.cc
37         $(CXX) -MMD -MF .$@.d -fPIC -c $< $(CPPFLAGS)
38
39 %.pdf: %.dot
40         dot -Tpdf $< -o $@
41
42 -include $(OBJECTS:%=.%.d)
43
44 PHONY += clean
45 clean:
46         rm -f *.o *.so .*.d *.pdf *.dot
47         $(MAKE) -C $(TESTS_DIR) clean
48
49 PHONY += mrclean
50 mrclean: clean
51         rm -rf docs
52
53 PHONY += tags
54 tags:
55         ctags -R
56
57 PHONY += tests
58 tests: $(LIB_SO)
59         $(MAKE) -C $(TESTS_DIR)
60
61 BENCH_DIR := benchmarks
62
63 PHONY += benchmarks
64 benchmarks: $(LIB_SO)
65         @if ! test -d $(BENCH_DIR); then \
66                 echo "Directory $(BENCH_DIR) does not exist" && \
67                 echo "Please clone the benchmarks repository" && \
68                 echo && \
69                 exit 1; \
70         fi
71         $(MAKE) -C $(BENCH_DIR)
72
73 PHONY += pdfs
74 pdfs: $(patsubst %.dot,%.pdf,$(wildcard *.dot))
75
76 .PHONY: $(PHONY)