Fix snapshot code
[model-checker.git] / Makefile
index 2acdbc7dff8a7738c6f99349421aa66bc97b5d5b..eb84076dcae075324dc3353d52d72617c578fcfe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,56 +1,92 @@
 include common.mk
 
-OBJECTS = libthreads.o schedule.o model.o threads.o librace.o action.o \
-         nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
-         datarace.o impatomic.o cmodelint.o \
-         snapshot.o malloc.o mymemory.o
+SCFENCE_DIR := scfence
 
-CPPFLAGS += -Iinclude -I.
-LDFLAGS=-ldl -lrt
-SHARED=-shared
+OBJECTS := libthreads.o schedule.o model.o threads.o librace.o action.o \
+          nodestack.o clockvector.o main.o snapshot-interface.o cyclegraph.o \
+          datarace.o impatomic.o cmodelint.o \
+          snapshot.o malloc.o mymemory.o common.o mutex.o promise.o conditionvariable.o \
+          context.o scanalysis.o execution.o plugins.o libannotate.o
 
-TESTS=test
+CPPFLAGS += -Iinclude -I. -I$(SCFENCE_DIR)
+LDFLAGS := -ldl -lrt -rdynamic
+SHARED := -shared
 
-program_H_SRCS := $(wildcard *.h) $(wildcard include/*.h)
-program_C_SRCS := $(wildcard *.c) $(wildcard *.cc)
-DEPS = make.deps
+# Mac OSX options
+ifeq ($(UNAME), Darwin)
+LDFLAGS := -ldl
+SHARED := -Wl,-undefined,dynamic_lookup -dynamiclib
+endif
 
-all: $(LIB_SO) $(DEPS) tests
+TESTS_DIR := test
 
-$(DEPS): $(program_C_SRCS) $(program_H_SRCS)
-       $(CXX) $(CPPFLAGS) -MM $(program_C_SRCS) > $(DEPS)
+MARKDOWN := doc/Markdown/Markdown.pl
 
-include $(DEPS)
+all: $(LIB_SO) tests README.html
 
 debug: CPPFLAGS += -DCONFIG_DEBUG
 debug: all
 
-mac: CPPFLAGS += -D_XOPEN_SOURCE -DMAC
-mac: LDFLAGS=-ldl
-mac: SHARED=-Wl,-undefined,dynamic_lookup -dynamiclib
-mac: all
-
-docs: *.c *.cc *.h
+PHONY += docs
+docs: *.c *.cc *.h README.html
        doxygen
 
-$(LIB_SO): $(OBJECTS)
-       $(CXX) $(SHARED) -o $(LIB_SO) $(OBJECTS) $(LDFLAGS)
+README.html: README.md
+       $(MARKDOWN) $< > $@
+
 
 malloc.o: malloc.c
-       $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES $(CPPFLAGS)
+       $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES -DHAVE_MMAP=0 $(CPPFLAGS) -Wno-unused-variable
+
+%.o : %.cc
+       $(CXX) -MMD -MF .$@.d -fPIC -c $< $(CPPFLAGS)
+
+include $(SCFENCE_DIR)/Makefile
+
+-include $(wildcard $(SCFENCE_DIR)/.*.d)
+
+$(LIB_SO): $(OBJECTS)
+       $(CXX) $(SHARED) -o $(LIB_SO) $+ $(LDFLAGS)
+
+%.pdf: %.dot
+       dot -Tpdf $< -o $@
 
-%.o: %.cc
-       $(CXX) -fPIC -c $< $(CPPFLAGS)
+-include $(OBJECTS:%=.%.d)
 
+PHONY += clean
 clean:
-       rm -f *.o *.so
-       $(MAKE) -C $(TESTS) clean
+       rm -f *.o *.so .*.d *.pdf *.dot $(SCFENCE_DIR)/.*.d $(SCFENCE_DIR)/*.o
+       $(MAKE) -C $(TESTS_DIR) clean
 
+PHONY += mrclean
 mrclean: clean
        rm -rf docs
 
-tags::
+PHONY += tags
+tags:
        ctags -R
 
-tests:: $(LIB_SO)
-       $(MAKE) -C $(TESTS)
+PHONY += tests
+tests: $(LIB_SO)
+       $(MAKE) -C $(TESTS_DIR)
+
+BENCH_DIR := benchmarks
+
+PHONY += benchmarks
+benchmarks: $(LIB_SO)
+       @if ! test -d $(BENCH_DIR); then \
+               echo "Directory $(BENCH_DIR) does not exist" && \
+               echo "Please clone the benchmarks repository" && \
+               echo && \
+               exit 1; \
+       fi
+       $(MAKE) -C $(BENCH_DIR)
+
+PHONY += pdfs
+pdfs: $(patsubst %.dot,%.pdf,$(wildcard *.dot))
+
+.PHONY: $(PHONY)
+
+# A 1-inch margin PDF generated by 'pandoc'
+%.pdf: %.md
+       pandoc -o $@ $< -V header-includes='\usepackage[margin=1in]{geometry}'