annotate branches/carfac_cpp/makefile @ 564:9c4c3675c3f8

* Added class Ear, and moved the CARFAC members AGC CAR IHC into Ear. CARFAC now holds an array of Ear. TBD what is best. * Moved the files around, and introduced a makefile that builds unittests using GTest. (Note, GTest path is configured in makefile atm.). - two moronic tests implemented. :)
author Ulf.Hammarqvist@gmail.com
date Sun, 20 May 2012 22:36:47 +0000
parents
children b4650540cb24
rev   line source
Ulf@564 1 # How to use:
Ulf@564 2 # Add your cpp code to the list in UNITS.
Ulf@564 3 #
Ulf@564 4 # Unit test:
Ulf@564 5 # If you want to add a test build target for that cpp file ONLY, please see
Ulf@564 6 # example "AGC_unittest". (no need to add explicit build rule)
Ulf@564 7 #
Ulf@564 8 # If you intend to test a class including instanciated members, you need to
Ulf@564 9 # make a explicit rule to link properly. See example "CARFAC_unittest".
Ulf@564 10
Ulf@564 11 SRC_HEADERDIR = include
Ulf@564 12 SRC_DIR = src
Ulf@564 13 SRC_TESTDIR = unittest
Ulf@564 14
Ulf@564 15 GTEST_DIR = ../../../googletest
Ulf@564 16
Ulf@564 17 SRC_HEADERS = $(SRC_HEADERDIR)/*.h
Ulf@564 18
Ulf@564 19 CPPFLAGS += -I$(SRC_HEADERDIR) -I$(GTEST_DIR)/include
Ulf@564 20 CXXFLAGS += -g -Wall -Wextra -std=gnu++0x #IMPORTANT note gnu++0x
Ulf@564 21
Ulf@564 22 UNITS = AGC CAR CARFAC Ear IHC #Add build units here (without the .cpp)
Ulf@564 23 SRC_OBJ = $(addprefix $(SRC_DIR)/, $(addsuffix .o, $(UNITS)))
Ulf@564 24
Ulf@564 25 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
Ulf@564 26 $(GTEST_DIR)/include/gtest/internal/*.h
Ulf@564 27
Ulf@564 28 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
Ulf@564 29
Ulf@564 30 all : CARFAC_unittest AGC_unittest #make some other "main" target
Ulf@564 31
Ulf@564 32 clean :
Ulf@564 33 rm -f *.o *.a src/*.o unittest/*.o *_unittest.exe
Ulf@564 34
Ulf@564 35 CARFAC_unittest : $(SRC_TESTDIR)/CARFAC_unittest.o $(SRC_OBJ)
Ulf@564 36
Ulf@564 37 # pattern magic
Ulf@564 38 $(SRC_DIR)/%.o : %.cpp $(SRC_HEADERS) #normal source
Ulf@564 39 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE)
Ulf@564 40
Ulf@564 41 $(SRC_TESTDIR)/%.o : %.cpp $(SRC_HEADERS) $(GTEST_HEADERS) # unittest
Ulf@564 42 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE)
Ulf@564 43
Ulf@564 44 %_unittest : $(SRC_DIR)/%.o $(SRC_TESTDIR)/%_unittest.o gtest_main.a #unittest
Ulf@564 45 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
Ulf@564 46 # ./$@.exe # launches the test - disabled, as failing tests stops the build
Ulf@564 47 # end pattern magic
Ulf@564 48
Ulf@564 49 # gtest stuff
Ulf@564 50 gtest-all.o : $(GTEST_SRCS_)
Ulf@564 51 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
Ulf@564 52 $(GTEST_DIR)/src/gtest-all.cc
Ulf@564 53
Ulf@564 54 gtest_main.o : $(GTEST_SRCS_)
Ulf@564 55 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
Ulf@564 56 $(GTEST_DIR)/src/gtest_main.cc
Ulf@564 57
Ulf@564 58 gtest.a : gtest-all.o
Ulf@564 59 $(AR) $(ARFLAGS) $@ $^
Ulf@564 60
Ulf@564 61 gtest_main.a : gtest-all.o gtest_main.o
Ulf@564 62 $(AR) $(ARFLAGS) $@ $^
Ulf@564 63 # end gtest stuff