annotate makefile @ 503:83cd5bbf2a3e carfac_cpp

* 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 e4285e69a73d
rev   line source
Ulf@503 1 # How to use:
Ulf@503 2 # Add your cpp code to the list in UNITS.
Ulf@503 3 #
Ulf@503 4 # Unit test:
Ulf@503 5 # If you want to add a test build target for that cpp file ONLY, please see
Ulf@503 6 # example "AGC_unittest". (no need to add explicit build rule)
Ulf@503 7 #
Ulf@503 8 # If you intend to test a class including instanciated members, you need to
Ulf@503 9 # make a explicit rule to link properly. See example "CARFAC_unittest".
Ulf@503 10
Ulf@503 11 SRC_HEADERDIR = include
Ulf@503 12 SRC_DIR = src
Ulf@503 13 SRC_TESTDIR = unittest
Ulf@503 14
Ulf@503 15 GTEST_DIR = ../../../googletest
Ulf@503 16
Ulf@503 17 SRC_HEADERS = $(SRC_HEADERDIR)/*.h
Ulf@503 18
Ulf@503 19 CPPFLAGS += -I$(SRC_HEADERDIR) -I$(GTEST_DIR)/include
Ulf@503 20 CXXFLAGS += -g -Wall -Wextra -std=gnu++0x #IMPORTANT note gnu++0x
Ulf@503 21
Ulf@503 22 UNITS = AGC CAR CARFAC Ear IHC #Add build units here (without the .cpp)
Ulf@503 23 SRC_OBJ = $(addprefix $(SRC_DIR)/, $(addsuffix .o, $(UNITS)))
Ulf@503 24
Ulf@503 25 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
Ulf@503 26 $(GTEST_DIR)/include/gtest/internal/*.h
Ulf@503 27
Ulf@503 28 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
Ulf@503 29
Ulf@503 30 all : CARFAC_unittest AGC_unittest #make some other "main" target
Ulf@503 31
Ulf@503 32 clean :
Ulf@503 33 rm -f *.o *.a src/*.o unittest/*.o *_unittest.exe
Ulf@503 34
Ulf@503 35 CARFAC_unittest : $(SRC_TESTDIR)/CARFAC_unittest.o $(SRC_OBJ)
Ulf@503 36
Ulf@503 37 # pattern magic
Ulf@503 38 $(SRC_DIR)/%.o : %.cpp $(SRC_HEADERS) #normal source
Ulf@503 39 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE)
Ulf@503 40
Ulf@503 41 $(SRC_TESTDIR)/%.o : %.cpp $(SRC_HEADERS) $(GTEST_HEADERS) # unittest
Ulf@503 42 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE)
Ulf@503 43
Ulf@503 44 %_unittest : $(SRC_DIR)/%.o $(SRC_TESTDIR)/%_unittest.o gtest_main.a #unittest
Ulf@503 45 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
Ulf@503 46 # ./$@.exe # launches the test - disabled, as failing tests stops the build
Ulf@503 47 # end pattern magic
Ulf@503 48
Ulf@503 49 # gtest stuff
Ulf@503 50 gtest-all.o : $(GTEST_SRCS_)
Ulf@503 51 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
Ulf@503 52 $(GTEST_DIR)/src/gtest-all.cc
Ulf@503 53
Ulf@503 54 gtest_main.o : $(GTEST_SRCS_)
Ulf@503 55 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
Ulf@503 56 $(GTEST_DIR)/src/gtest_main.cc
Ulf@503 57
Ulf@503 58 gtest.a : gtest-all.o
Ulf@503 59 $(AR) $(ARFLAGS) $@ $^
Ulf@503 60
Ulf@503 61 gtest_main.a : gtest-all.o gtest_main.o
Ulf@503 62 $(AR) $(ARFLAGS) $@ $^
Ulf@503 63 # end gtest stuff