model: rename last_seq_cst -> last_sc_write
[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
8 CPPFLAGS += -Iinclude -I.
9 LDFLAGS = -ldl -lrt -rdynamic
10 SHARED = -shared
11
12 # Mac OSX options
13 ifeq ($(UNAME), Darwin)
14 LDFLAGS = -ldl
15 SHARED = -Wl,-undefined,dynamic_lookup -dynamiclib
16 endif
17
18 TESTS_DIR = test
19
20 program_H_SRCS := $(wildcard *.h) $(wildcard include/*.h)
21 program_C_SRCS := $(wildcard *.c) $(wildcard *.cc)
22 DEPS = make.deps
23
24 all: $(LIB_SO) tests
25
26 $(DEPS): build_deps := 1
27 $(DEPS): $(program_C_SRCS) $(program_H_SRCS)
28         $(CXX) -MM $(program_C_SRCS) $(CPPFLAGS) > $(DEPS)
29
30 ifeq ($(build_deps),1)
31 include $(DEPS)
32 endif
33
34 debug: CPPFLAGS += -DCONFIG_DEBUG
35 debug: all
36
37 PHONY += docs
38 docs: *.c *.cc *.h
39         doxygen
40
41 $(LIB_SO): $(OBJECTS)
42         $(CXX) $(SHARED) -o $(LIB_SO) $(OBJECTS) $(LDFLAGS)
43
44 malloc.o: malloc.c
45         $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
46
47 %.o: %.cc $(DEPS)
48         $(CXX) -fPIC -c $< $(CPPFLAGS)
49
50 PHONY += clean
51 clean:
52         rm -f *.o *.so
53         $(MAKE) -C $(TESTS_DIR) clean
54
55 PHONY += mrclean
56 mrclean: clean
57         rm -rf docs
58
59 PHONY += tags
60 tags:
61         ctags -R
62
63 PHONY += tests
64 tests: $(LIB_SO)
65         $(MAKE) -C $(TESTS_DIR)
66
67 BENCHMARKS := benchmarks
68
69 PHONY += benchmarks
70 benchmarks: $(LIB_SO)
71         @if ! test -d $(BENCHMARKS); then \
72                 echo "Directory $(BENCHMARKS) does not exist" && \
73                 echo "Please clone the benchmarks repository" && \
74                 echo && \
75                 exit 1; \
76         fi
77         $(MAKE) -C $(BENCHMARKS)
78
79 .PHONY: $(PHONY)