-BASE = ..
+BASE := ..
+
+OBJECTS := $(patsubst %.c, %.o, $(wildcard *.c))
+OBJECTS += $(patsubst %.cc, %.o, $(wildcard *.cc))
include $(BASE)/common.mk
-CPPFLAGS += -I$(BASE) -I$(BASE)/include
+DIR := litmus
+include $(DIR)/Makefile
-SRCS = $(wildcard *.c)
-CPSRCS = $(wildcard *.cc)
-OBJS = $(patsubst %.c,%.o,$(SRCS)) $(patsubst %.cc,%.o,$(CPSRCS))
+DEPS := $(join $(addsuffix ., $(dir $(OBJECTS))), $(addsuffix .d, $(notdir $(OBJECTS))))
+
+CPPFLAGS += -I$(BASE) -I$(BASE)/include
-all: $(OBJS) litmus-tests
+all: $(OBJECTS)
-litmus-tests::
- $(MAKE) -C litmus
+-include $(DEPS)
%.o: %.c
- $(CC) -o $@ $< $(CPPFLAGS) -L$(BASE) -l$(LIB_NAME)
+ $(CC) -MMD -MF $(@D)/.$(@F).d -o $@ $< $(CPPFLAGS) -L$(BASE) -l$(LIB_NAME)
%.o: %.cc
- $(CXX) -o $@ $< $(CPPFLAGS) -L$(BASE) -l$(LIB_NAME)
+ $(CXX) -MMD -MF $(@D)/.$(@F).d -o $@ $< $(CPPFLAGS) -L$(BASE) -l$(LIB_NAME)
clean::
- rm -f *.o
- $(MAKE) -C litmus clean
+ rm -f $(OBJECTS) $(DEPS)