]> git.saurik.com Git - apt.git/blame - test/libapt/makefile
accept ../ on the cmdline as start for a deb file as well
[apt.git] / test / libapt / makefile
CommitLineData
45df0ad2
DK
1# -*- make -*-
2BASE=../..
3SUBDIR=test/libapt
4BASENAME=_libapt_test
57da1b4b 5APT_DOMAIN=none
45df0ad2
DK
6
7# Bring in the default rules
8include ../../buildlib/defaults.mak
9
92d5a40d 10.PHONY: test
f492283b 11ifeq (file-okay,$(shell $(CC) -I $(BASE)/build/include -M gtest_runner.cc >/dev/null 2>&1 && echo 'file-okay'))
f00832cc
DK
12test: $(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
17PROGRAM = gtest${BASENAME}
992a1e83
JAK
18SLIBS = -lapt-pkg -lapt-private -lapt-inst -pthread $(LIB)/gtest.a
19LIB_MAKES = apt-pkg/makefile apt-private/makefile apt-inst/makefile
f00832cc
DK
20SOURCE = gtest_runner.cc $(wildcard *-helpers.cc *_test.cc)
21include $(PROGRAM_H)
22
23
24MKDIRS += $(OBJ) $(LIB)
25LOCAL=gtest
26SOURCE=gtest-all
27gtest-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
31GTEST_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.
c3392a9f 36#CPPFLAGS += -isystem $(GTEST_DIR)/include
f00832cc
DK
37
38# Flags passed to the C++ compiler.
39CXXFLAGS += -pthread
40# disable some flags for gtest again
41CXXFLAGS+= -Wno-missing-declarations
42CXXFLAGS+= -Wno-missing-field-initializers
43CXXFLAGS+= -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wno-suggest-attribute=noreturn
c3392a9f 44CXXFLAGS+= -Wno-undef
f00832cc
DK
45
46# All Google Test headers. Usually you shouldn't change this definition.
47GTEST_HEADERS = /usr/include/gtest/*.h \
48 /usr/include/gtest/internal/*.h
49
50# House-keeping build targets.
51.PHONY: clean/gtest veryclean/gtest
52clean: clean/gtest
53clean/gtest:
54 rm -f $(gtest-OBJS)
55veryclean: veryclean/gtest
56veryclean/gtest: clean/gtest
57 rm -f $(LIB)/gtest.a
58
59# Usually you shouldn't tweak such internal variables, indicated by a
60# trailing _.
61GTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)
62
63# Builds gtest.a
64# For simplicity and to avoid depending on Google Test's
65# implementation details, the dependencies specified below are
66# conservative and not optimized. This is fine as Google Test
67# compiles fast and for ordinary users its source rarely changes.
68$(gtest-OBJS): $(GTEST_SRCS_)
69 echo Compiling $@
70 $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c -o $@ $(GTEST_DIR)/src/$(notdir $(basename $@)).cc
71
72$(LIB)/gtest.a: $(OBJ)/gtest-all.o
73 echo Building static library $@
74 -rm -f $@
75 $(AR) $(ARFLAGS) $@ $^
42fab5fb
DK
76
77else
78test:
79 @echo "APT uses Googles C++ testing framework for its unit tests"
80 @echo "On Debian systems this is available in the 'libgtest-dev' package."
81 @echo "Please install it before attempting to run the unit tests."
f492283b 82 $(CC) -I $(BASE)/build/include -M gtest_runner.cc
42fab5fb
DK
83 exit 100
84endif