annotate branches/carfac_cpp/makefile @ 584:b4650540cb24

(none)
author Ulf.Hammarqvist@gmail.com
date Wed, 10 Oct 2012 19:30:59 +0000
parents 9c4c3675c3f8
children b8a961149499
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@584 22 UNITS = CARFAC AGC CAR 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@584 30 all :
Ulf@584 31 CARFAC_unittest AGC_unittest #make some other "main" target
Ulf@564 32
Ulf@564 33 clean :
Ulf@584 34 rm -f *.o *.a src/*.o unittest/*.o *_unittest.exe
Ulf@564 35
Ulf@564 36 CARFAC_unittest : $(SRC_TESTDIR)/CARFAC_unittest.o $(SRC_OBJ)
Ulf@564 37
Ulf@564 38 # pattern magic
Ulf@564 39 $(SRC_DIR)/%.o : %.cpp $(SRC_HEADERS) #normal source
Ulf@584 40 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE)
Ulf@564 41
Ulf@564 42 $(SRC_TESTDIR)/%.o : %.cpp $(SRC_HEADERS) $(GTEST_HEADERS) # unittest
Ulf@584 43 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(.SOURCE)
Ulf@564 44
Ulf@564 45 %_unittest : $(SRC_DIR)/%.o $(SRC_TESTDIR)/%_unittest.o gtest_main.a #unittest
Ulf@584 46 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@
Ulf@564 47 # ./$@.exe # launches the test - disabled, as failing tests stops the build
Ulf@564 48 # end pattern magic
Ulf@564 49
Ulf@564 50 # gtest stuff
Ulf@564 51 gtest-all.o : $(GTEST_SRCS_)
Ulf@584 52 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
Ulf@564 53 $(GTEST_DIR)/src/gtest-all.cc
Ulf@564 54
Ulf@564 55 gtest_main.o : $(GTEST_SRCS_)
Ulf@584 56 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \
Ulf@564 57 $(GTEST_DIR)/src/gtest_main.cc
Ulf@564 58
Ulf@564 59 gtest.a : gtest-all.o
Ulf@584 60 $(AR) $(ARFLAGS) $@ $^
Ulf@564 61
Ulf@564 62 gtest_main.a : gtest-all.o gtest_main.o
Ulf@584 63 $(AR) $(ARFLAGS) $@ $^
Ulf@564 64 # end gtest stuff