Mercurial > hg > aimc
changeset 585:b8a961149499
seemingly mingw likes tabs for makefiles ...?
+ some restructure and automatic execution of unittests after build...
author | Ulf.Hammarqvist@gmail.com |
---|---|
date | Thu, 11 Oct 2012 19:37:10 +0000 |
parents | b4650540cb24 |
children | f3dde307f4b8 |
files | branches/carfac_cpp/makefile |
diffstat | 1 files changed, 28 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/branches/carfac_cpp/makefile Wed Oct 10 19:30:59 2012 +0000 +++ b/branches/carfac_cpp/makefile Thu Oct 11 19:37:10 2012 +0000 @@ -8,12 +8,16 @@ # If you intend to test a class including instanciated members, you need to # make a explicit rule to link properly. See example "CARFAC_unittest". +# settings +GTEST_DIR = ../../../googletest +LIB_EXTENSION = .dll +EXE_EXTENSION = .exe +# end settings + SRC_HEADERDIR = include SRC_DIR = src SRC_TESTDIR = unittest -GTEST_DIR = ../../../googletest - SRC_HEADERS = $(SRC_HEADERDIR)/*.h CPPFLAGS += -I$(SRC_HEADERDIR) -I$(GTEST_DIR)/include @@ -27,38 +31,45 @@ GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS) -all : - CARFAC_unittest AGC_unittest #make some other "main" target +all : libcarfac unittest + +libcarfac : $(SRC_DIR)/CARFAC.o $(SRC_OBJ) + $(CXX) -shared $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@.$(LIB_EXTENSION) -fPIC + +example_program : libcarfac + # likely some example executable that runs the whole thing... + +unittest: CARFAC_unittest AGC_unittest + $(foreach binary, $^, ./$(addsuffix $(EXE_EXTENSION), $(binary));) + +CARFAC_unittest : $(SRC_TESTDIR)/CARFAC_unittest.o $(SRC_OBJ) clean : - rm -f *.o *.a src/*.o unittest/*.o *_unittest.exe - -CARFAC_unittest : $(SRC_TESTDIR)/CARFAC_unittest.o $(SRC_OBJ) + rm -f *.o *.a src/*.o unittest/*.o *_unittest* *.dll *.exe # pattern magic $(SRC_DIR)/%.o : %.cpp $(SRC_HEADERS) #normal source - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE) $(SRC_TESTDIR)/%.o : %.cpp $(SRC_HEADERS) $(GTEST_HEADERS) # unittest - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE) %_unittest : $(SRC_DIR)/%.o $(SRC_TESTDIR)/%_unittest.o gtest_main.a #unittest - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ -# ./$@.exe # launches the test - disabled, as failing tests stops the build + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@ # end pattern magic # gtest stuff gtest-all.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest-all.cc + $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ + $(GTEST_DIR)/src/gtest-all.cc gtest_main.o : $(GTEST_SRCS_) - $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ - $(GTEST_DIR)/src/gtest_main.cc + $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \ + $(GTEST_DIR)/src/gtest_main.cc gtest.a : gtest-all.o - $(AR) $(ARFLAGS) $@ $^ + $(AR) $(ARFLAGS) $@ $^ gtest_main.a : gtest-all.o gtest_main.o - $(AR) $(ARFLAGS) $@ $^ + $(AR) $(ARFLAGS) $@ $^ # end gtest stuff \ No newline at end of file