# SYNOPSIS:
#
# make [all] - makes everything.
# make run - run all unit tests
# make clean - removes all files generated by make.
include Makefile.files
include Makefile.rules
all: run-tests
# clean targets
clean: clean-src clean-deploy clean-test
clean-src:
rm -f $(LibObj)
clean-deploy:
rm -f $(WavepacketLib)
clean-test:
rm -f $(GtestLib)
rm -f $(TestProg)
rm -f $(TestObj)
# Build and deploy the library
$(WavepacketLib): $(LibObj)
ar rv $@ $^
$(LibObj):%.o:%.cpp
$(CXX) -c $(CPPFLAGS) -I$(IncludeDir) $(CXXFLAGS) -o $@ $^
# Build and run the tests.
# Note that there are two ways:
# 1. run-tests first builds all tests, then runs them
# 2. Specifying one or more test names relative to $(TestDir) builds and runs only
# these tests. Useful for skipping the relatively slow linking against
# googletest for unused tests. This is the $(RunTests) rule
run-tests: $(TestProg)
cd $(TestDir); for mytest in $(RunTests); do $$mytest; done
$(RunTests):%:$(TestDir)/%
cd $(TestDir) && $@
$(TestProg):%:%.o $(GtestLib) $(WavepacketLib)
$(CXX) -o $@ $(LDFLAGS) $^
$(TestObj):%.o:%.cpp
$(CXX) -c $(CPPFLAGS) -I$(IncludeDir) -I$(TestDir) -I$(GTEST_DIR)/include $(CXXFLAGS) -o $@ $^
$(GtestLib):
$(CXX) -o $(TestDir)/gtest-all.o -I$(GTEST_DIR)/include -I$(GTEST_DIR) -c $(GTEST_DIR)/src/gtest-all.cc
ar -rv $(GtestLib) $(TestDir)/gtest-all.o && rm -f $(TestDir)/gtest-all.o
.PHONY: clean clean-src clean-deploy clean-test run-tests $(RunTests)