7 # Bring in the default rules
8 include ../../buildlib/defaults.mak
11 test: $(BIN)/gtest$(BASENAME)
12 MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=$(LIB) $(BIN)/gtest$(BASENAME)
14 $(BIN)/gtest$(BASENAME): $(LIB)/gtest.a
16 PROGRAM = gtest${BASENAME}
17 SLIBS = -lapt-pkg -pthread $(LIB)/gtest.a
18 LIB_MAKES = apt-pkg/makefile
19 SOURCE = gtest_runner.cc $(wildcard *-helpers.cc *_test.cc)
23 MKDIRS += $(OBJ) $(LIB)
26 gtest-OBJS := $(addprefix $(OBJ)/,$(addsuffix .o,$(SOURCE)))
28 # The rest of the file is based on the example found in
29 # /usr/share/doc/libgtest-dev/examples/make/Makefile
30 GTEST_DIR = /usr/src/gtest
32 # Flags passed to the preprocessor.
33 # Set Google Test's header directory as a system directory, such that
34 # the compiler doesn't generate warnings in Google Test headers.
35 CPPFLAGS += -isystem $(GTEST_DIR)/include
37 # Flags passed to the C++ compiler.
39 # disable some flags for gtest again
40 CXXFLAGS+= -Wno-missing-declarations
41 CXXFLAGS+= -Wno-missing-field-initializers
42 CXXFLAGS+= -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wno-suggest-attribute=noreturn
44 # All Google Test headers. Usually you shouldn't change this definition.
45 GTEST_HEADERS = /usr/include/gtest/*.h \
46 /usr/include/gtest/internal/*.h
48 # House-keeping build targets.
49 .PHONY: clean/gtest veryclean/gtest
53 veryclean: veryclean/gtest
54 veryclean/gtest: clean/gtest
57 # Usually you shouldn't tweak such internal variables, indicated by a
59 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
62 # For simplicity and to avoid depending on Google Test's
63 # implementation details, the dependencies specified below are
64 # conservative and not optimized. This is fine as Google Test
65 # compiles fast and for ordinary users its source rarely changes.
66 $(gtest-OBJS): $(GTEST_SRCS_)
68 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c -o $@ $(GTEST_DIR)/src/$(notdir $(basename $@)).cc
70 $(LIB)/gtest.a: $(OBJ)/gtest-all.o
71 echo Building static library $@
73 $(AR) $(ARFLAGS) $@ $^