From: Brian Norris Date: Fri, 10 Aug 2012 18:52:36 +0000 (-0700) Subject: Makefile: rewrite header dependencies X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=fec9254c3747d5dde5d45e1ef81f7261c74bd5a7 Makefile: rewrite header dependencies We shouldn't need to add new files in 3 different places. Automatically generate most of this using GCC's '-MM' option. --- diff --git a/.gitignore b/.gitignore index c5c3e71d..2ac6f537 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ # files in this directory /tags /docs +/make.deps diff --git a/Makefile b/Makefile index 2d90c16b..9812ab47 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,9 @@ include common.mk -MODEL_CC=libthreads.cc schedule.cc model.cc threads.cc librace.cc action.cc nodestack.cc clockvector.cc main.cc snapshot-interface.cc cyclegraph.cc datarace.cc impatomic.cc cmodelint.cc promise.cc -MODEL_O=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 promise.o -MODEL_H=libthreads.h schedule.h common.h model.h threads.h librace.h action.h nodestack.h clockvector.h snapshot-interface.h cyclegraph.h hashtable.h datarace.h config.h include/impatomic.h include/cstdatomic include/stdatomic.h cmodelint.h promise.h - -SHMEM_CC=snapshot.cc malloc.c mymemory.cc -SHMEM_O=snapshot.o malloc.o mymemory.o -SHMEM_H=snapshot.h snapshotimp.h mymemory.h config.h +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 promise.o \ + snapshot.o malloc.o mymemory.o CPPFLAGS += -Iinclude -I. LDFLAGS=-ldl -lrt @@ -14,7 +11,16 @@ SHARED=-shared TESTS=test -all: $(LIB_SO) tests +program_H_SRCS := $(wildcard *.h) $(wildcard include/*.h) +program_C_SRCS := $(wildcard *.c) $(wildcard *.cc) +DEPS = make.deps + +all: $(LIB_SO) $(DEPS) tests + +$(DEPS): $(program_C_SRCS) $(program_H_SRCS) + $(CXX) $(CPPFLAGS) -MM $(program_C_SRCS) > $(DEPS) + +include $(DEPS) debug: CPPFLAGS += -DCONFIG_DEBUG debug: all @@ -27,19 +33,13 @@ mac: all docs: *.c *.cc *.h doxygen -$(LIB_SO): $(MODEL_O) $(MODEL_H) $(SHMEM_O) $(SHMEM_H) - $(CXX) $(SHARED) -o $(LIB_SO) $(MODEL_O) $(SHMEM_O) $(LDFLAGS) +$(LIB_SO): $(OBJECTS) + $(CXX) $(SHARED) -o $(LIB_SO) $(OBJECTS) $(LDFLAGS) malloc.o: malloc.c $(CC) -fPIC -c malloc.c -DMSPACES -DONLY_MSPACES $(CPPFLAGS) -mymemory.o: mymemory.h snapshotimp.h snapshot.h mymemory.cc config.h - $(CXX) -fPIC -c mymemory.cc $(CPPFLAGS) - -snapshot.o: mymemory.h snapshot.h snapshotimp.h snapshot.cc config.h - $(CXX) -fPIC -c snapshot.cc $(CPPFLAGS) - -%.o: %.cc $(MODEL_H) +%.o: %.cc $(CXX) -fPIC -c $< $(CPPFLAGS) clean: