]> git.saurik.com Git - apt.git/blob - test/libapt/makefile
0f8df291fcaa30a279f79ecbe62c994ec706a738
[apt.git] / test / libapt / makefile
1 # -*- make -*-
2 BASE=../..
3 SUBDIR=test/libapt
4 BASENAME=_libapt_test
5 APT_DOMAIN=none
6
7 # Bring in the default rules
8 include ../../buildlib/defaults.mak
9
10 .PHONY: test
11 ifeq (file-okay,$(shell $(CC) -M gtest_runner.cc >/dev/null 2>&1 && echo 'file-okay'))
12 test: $(BIN)/gtest$(BASENAME)
13 MALLOC_PERTURB_=21 MALLOC_CHECK_=2 LD_LIBRARY_PATH=$(LIB) $(BIN)/gtest$(BASENAME)
14
15 $(BIN)/gtest$(BASENAME): $(LIB)/gtest.a
16
17 PROGRAM = gtest${BASENAME}
18 SLIBS = -lapt-pkg -lapt-private -pthread $(LIB)/gtest.a
19 LIB_MAKES = apt-pkg/makefile apt-private/makefile
20 SOURCE = gtest_runner.cc $(wildcard *-helpers.cc *_test.cc)
21 include $(PROGRAM_H)
22
23
24 MKDIRS += $(OBJ) $(LIB)
25 LOCAL=gtest
26 SOURCE=gtest-all
27 gtest-OBJS := $(addprefix $(OBJ)/,$(addsuffix .o,$(SOURCE)))
28
29 # The rest of the file is based on the example found in
30 # /usr/share/doc/libgtest-dev/examples/make/Makefile
31 GTEST_DIR = /usr/src/gtest
32
33 # Flags passed to the preprocessor.
34 # Set Google Test's header directory as a system directory, such that
35 # the compiler doesn't generate warnings in Google Test headers.
36 CPPFLAGS += -isystem $(GTEST_DIR)/include
37
38 # Flags passed to the C++ compiler.
39 CXXFLAGS += -pthread
40 # disable some flags for gtest again
41 CXXFLAGS+= -Wno-missing-declarations
42 CXXFLAGS+= -Wno-missing-field-initializers
43 CXXFLAGS+= -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wno-suggest-attribute=noreturn
44
45 # All Google Test headers. Usually you shouldn't change this definition.
46 GTEST_HEADERS = /usr/include/gtest/*.h \
47 /usr/include/gtest/internal/*.h
48
49 # House-keeping build targets.
50 .PHONY: clean/gtest veryclean/gtest
51 clean: clean/gtest
52 clean/gtest:
53 rm -f $(gtest-OBJS)
54 veryclean: veryclean/gtest
55 veryclean/gtest: clean/gtest
56 rm -f $(LIB)/gtest.a
57
58 # Usually you shouldn't tweak such internal variables, indicated by a
59 # trailing _.
60 GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
61
62 # Builds gtest.a
63 # For simplicity and to avoid depending on Google Test's
64 # implementation details, the dependencies specified below are
65 # conservative and not optimized. This is fine as Google Test
66 # compiles fast and for ordinary users its source rarely changes.
67 $(gtest-OBJS): $(GTEST_SRCS_)
68 echo Compiling $@
69 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c -o $@ $(GTEST_DIR)/src/$(notdir $(basename $@)).cc
70
71 $(LIB)/gtest.a: $(OBJ)/gtest-all.o
72 echo Building static library $@
73 -rm -f $@
74 $(AR) $(ARFLAGS) $@ $^
75
76 else
77 test:
78 @echo "APT uses Googles C++ testing framework for its unit tests"
79 @echo "On Debian systems this is available in the 'libgtest-dev' package."
80 @echo "Please install it before attempting to run the unit tests."
81 exit 100
82 endif