1#!/usr/bin/make -f
2
3#define variables
4GTEST_INCLUDE_DIR = ../../ext
5TEST_INSTALL_DIR = $(epidinstalldir)/test/
6
7COMMON_TESTHELPER_INCLUDE_DIR = ../..
8COMMON_TESTHELPER_11_INCLUDE_DIR = ../../1.1
9COMMON_TESTHELPER_SRC = $(wildcard ./*.cc)
10COMMON_TESTHELPER_SRC += $(wildcard ./1.1/*.cc)
11COMMON_TESTHELPER_UTEST_SRC = $(wildcard ./unittests/*.cc)
12COMMON_TESTHELPER_OBJ = $(COMMON_TESTHELPER_SRC:.cc=.o)
13COMMON_TESTHELPER_UTEST_OBJ = $(COMMON_TESTHELPER_UTEST_SRC:.cc=.o)
14COMMON_TESTHELPER_LIB = ./libcommon-testhelper.a
15COMMON_TESTHELPER_UTEST_EXE = ./unittests/common-testhelper-utest$(EXE_EXTENSION)
16
17LIB_COMMON_TESTHELPER_DIR = .
18LIB_COMMON_DIR = ../common
19LIB_IPPCP_DIR = ../../ext/ipp/sources/ippcp/src
20
21#set flags for linker
22LDFLAGS += -L$(GTEST_INCLUDE_DIR)/gtest -L$(LIB_COMMON_TESTHELPER_DIR) \
23	-L$(LIB_COMMON_DIR) -L$(LIB_IPPCP_DIR) \
24	-lgtest -lcommon-testhelper -lcommon -lippcp
25
26ifneq ($(TSS_PATH),)
27	CXXFLAGS += -DTPM_TSS
28endif
29
30#target part
31$(COMMON_TESTHELPER_LIB): $(COMMON_TESTHELPER_OBJ)
32	$(AR) rc $(COMMON_TESTHELPER_LIB) $(COMMON_TESTHELPER_OBJ)
33	$(RANLIB) $(COMMON_TESTHELPER_LIB)
34
35$(COMMON_TESTHELPER_OBJ): %.o: %.cc
36	$(CXX) -o $@ $(CXXFLAGS) -I$(COMMON_TESTHELPER_INCLUDE_DIR) -c $^
37
38$(COMMON_TESTHELPER_UTEST_EXE): $(COMMON_TESTHELPER_UTEST_OBJ)
39	$(CXX) -o $@ $^ $(LDFLAGS)
40
41$(COMMON_TESTHELPER_UTEST_OBJ): %.o: %.cc
42	$(CXX) -o $@ $(CXXFLAGS) $(GTEST_DEFINES) -I$(COMMON_TESTHELPER_INCLUDE_DIR) \
43	-I$(COMMON_TESTHELPER_11_INCLUDE_DIR) -I$(GTEST_INCLUDE_DIR) -c $^
44
45build: all
46
47all: $(COMMON_TESTHELPER_LIB)
48
49install:
50#install tests if they exist
51ifneq (,$(wildcard $(COMMON_TESTHELPER_UTEST_EXE)))
52	mkdir -p '$(TEST_INSTALL_DIR)'
53	cp $(COMMON_TESTHELPER_UTEST_EXE) '$(TEST_INSTALL_DIR)'
54endif
55
56utest:	$(COMMON_TESTHELPER_UTEST_EXE)
57
58run_utest:
59	$(COMMON_TESTHELPER_UTEST_EXE) $(GTEST_FLAGS)
60
61check:  utest run_utest
62
63clean:
64	rm -f  $(COMMON_TESTHELPER_OBJ) \
65		$(COMMON_TESTHELPER_LIB) \
66		$(COMMON_TESTHELPER_UTEST_OBJ) \
67		$(COMMON_TESTHELPER_UTEST_EXE) \
68		*.xml
69