2016-12-04 07:28:25 -06:00
|
|
|
GTESTFLAG := -lgtest -lgtest_main
|
|
|
|
RPATH := -Wl,-rpath
|
2016-12-11 03:58:49 -06:00
|
|
|
EXTRAFLAGS := -lyosys -pthreads
|
2016-12-04 07:28:25 -06:00
|
|
|
|
|
|
|
OBJTEST := objtest
|
|
|
|
BINTEST := bintest
|
|
|
|
|
2016-12-10 14:21:56 -06:00
|
|
|
ALLTESTFILE := $(shell find -name '*Test.cc' -printf '%P ')
|
|
|
|
TESTDIRS := $(sort $(dir $(ALLTESTFILE)))
|
|
|
|
TESTS := $(addprefix $(BINTEST)/, $(basename $(ALLTESTFILE:%Test.cc=%Test.o)))
|
2016-12-04 07:28:25 -06:00
|
|
|
|
2016-12-10 14:21:56 -06:00
|
|
|
# Prevent make from removing our .o files
|
|
|
|
.SECONDARY:
|
|
|
|
|
|
|
|
all: prepare $(TESTS) run-tests
|
|
|
|
|
|
|
|
$(BINTEST)/%: $(OBJTEST)/%.o
|
|
|
|
$(CXX) -L$(ROOTPATH) $(RPATH)=$(ROOTPATH) -o $@ $^ $(LDLIBS) \
|
2016-12-04 07:28:25 -06:00
|
|
|
$(GTESTFLAG) $(EXTRAFLAGS)
|
2016-12-10 14:21:56 -06:00
|
|
|
|
|
|
|
$(OBJTEST)/%.o: $(basename $(subst $(OBJTEST),.,%)).cc
|
|
|
|
$(CXX) -o $@ -c -I$(ROOTPATH) $(CPPFLAGS) $(CXXFLAGS) $^
|
|
|
|
|
2016-12-04 07:28:25 -06:00
|
|
|
.PHONY: prepare run-tests clean
|
|
|
|
|
2016-12-10 14:21:56 -06:00
|
|
|
run-tests: $(TESTS)
|
|
|
|
$(subst Test ,Test; ,$^)
|
2016-12-04 07:28:25 -06:00
|
|
|
|
|
|
|
prepare:
|
2016-12-10 14:21:56 -06:00
|
|
|
mkdir -p $(addprefix $(BINTEST)/,$(TESTDIRS))
|
|
|
|
mkdir -p $(addprefix $(OBJTEST)/,$(TESTDIRS))
|
2016-12-04 07:28:25 -06:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJTEST)
|
|
|
|
rm -rf $(BINTEST)
|