• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# A Makefile for fusing Google Test and building a sample test against it.
2#
3# SYNOPSIS:
4#
5#   make [all]  - makes everything.
6#   make TARGET - makes the given target.
7#   make check  - makes everything and runs the built sample test.
8#   make clean  - removes all files generated by make.
9
10# Points to the root of fused Google Test, relative to where this file is.
11FUSED_GTEST_DIR = output
12
13# Paths to the fused gtest files.
14FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h
15FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
16
17# Where to find the sample test.
18SAMPLE_DIR = ../../samples
19
20# Where to find gtest_main.cc.
21GTEST_MAIN_CC = ../../src/gtest_main.cc
22
23# Flags passed to the preprocessor.
24# We have no idea here whether pthreads is available in the system, so
25# disable its use.
26CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0
27
28# Flags passed to the C++ compiler.
29CXXFLAGS += -g
30
31all : sample1_unittest
32
33check : all
34	./sample1_unittest
35
36clean :
37	rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o
38
39$(FUSED_GTEST_H) :
40	../fuse_gtest_files.py $(FUSED_GTEST_DIR)
41
42$(FUSED_GTEST_ALL_CC) :
43	../fuse_gtest_files.py $(FUSED_GTEST_DIR)
44
45gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)
46	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc
47
48gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)
49	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)
50
51sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h
52	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc
53
54sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \
55                     $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)
56	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc
57
58sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o
59	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
60