test/Makefile
author Jorg Knobloch
Thu, 30 Jul 2020 22:50:42 +0200
branchENGINE-780-take2
changeset 4910 347f8b793204
parent 4235 1daffdbc64aa
child 4912 22ee7f551838
permissions -rw-r--r--
ENGINE-780, take 2: After normalizing to UTC, forget the offset.
krista@4015
     1
# Copyright 2019, pEp Foundation
damiano@1958
     2
# This file is part of pEpEngine
damiano@1958
     3
# This file may be used under the terms of the GNU General Public License version 3
vb@1517
     4
# see LICENSE.txt
vb@1517
     5
damiano@3202
     6
HERE:=$(CURDIR)
damiano@3202
     7
krista@4170
     8
GTEST_SRC_DIR:=/usr/src/gtest
krista@4170
     9
GTEST_INC_DIR:=$(GTEST_SRC_DIR)/include
krista@4170
    10
GTEST_PL:=$(HOME)/src/gtest-parallel/gtest_parallel.py
krista@4024
    11
krista@4170
    12
include ../Makefile.conf # This should import changed values for the above from
krista@4170
    13
                         # local.conf
vb@1422
    14
damiano@3202
    15
SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
damiano@3202
    16
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
damiano@3202
    17
DEPS:=$(OBJS:.o=.d)
damiano@1970
    18
krista@4015
    19
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
krista@2637
    20
krista@4170
    21
TARGET:=EngineTests
krista@4170
    22
krista@4170
    23
GTEST_SUITE_SYM:=test_suite_name
krista@4170
    24
krista@4170
    25
ifeq ($(shell grep -c $(GTEST_SUITE_SYM) $(GTEST_SRC_DIR)/src/gtest.cc),0)
krista@4170
    26
    GTEST_SUITE_SYM=test_case_name
krista@4170
    27
endif
krista@4170
    28
krista@4170
    29
CXXFLAGS+= -DGTEST_SUITE_SYM=$(GTEST_SUITE_SYM)
krista@2637
    30
damiano@3202
    31
ifeq ($(OPENPGP),GPG)
damiano@3202
    32
    LDFLAGS+= $(GPGME_LIB)
damiano@3202
    33
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    34
    LDFLAGS+= $(NETGPG_LIB)
krista@1989
    35
endif
damiano@1970
    36
krista@4015
    37
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
damiano@1970
    38
krista@1989
    39
ifeq ($(BUILD_FOR),Linux)
damiano@3202
    40
    LDLIBS+= -luuid
Edouard@178
    41
endif
Edouard@178
    42
neal@3191
    43
ifeq ($(OPENPGP),SEQUOIA)
damiano@3236
    44
    LDFLAGS+= $(SEQUOIA_LDFLAGS)
damiano@3236
    45
    LDLIBS+= $(SEQUOIA_LIB)
krista@3538
    46
    CXXFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
damiano@3236
    47
    INC_FLAGS+= $(SEQUOIA_INC)
neal@3191
    48
endif
neal@3191
    49
damiano@2002
    50
ifdef SQLITE3_FROM_OS
damiano@3202
    51
    LDLIBS+= -lsqlite3
damiano@2002
    52
endif
damiano@2002
    53
damiano@3202
    54
ifeq ($(OPENPGP),GPG)
damiano@3202
    55
    #LDLIBS+= -lgpgme
damiano@3202
    56
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    57
    LDLIBS+= -lnetpgp
damiano@3202
    58
    ifeq ($(BUILD_FOR),Linux)
damiano@3202
    59
        LDLIBS+= -ltre
damiano@3202
    60
    endif
Edouard@178
    61
endif
Edouard@178
    62
krista@4030
    63
CXXFLAGS:=-I$(GTEST_INC_DIR) $(filter-out -DNDEBUG,$(CXXFLAGS))
damiano@3202
    64
damiano@3202
    65
# FIXME Possibly missing incdirs: ASN1C_INC
krista@4153
    66
CXXFLAGS+= -I./src -I../sync $(CPPUNIT_INC) $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
damiano@3202
    67
damiano@3202
    68
ifeq ($(OPENPGP),GPG)
damiano@3202
    69
    CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
damiano@3202
    70
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    71
    CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
damiano@2075
    72
endif
krista@2637
    73
damiano@3208
    74
EXTRA_LIB_PATHS=.:../src:
damiano@1970
    75
ifdef ETPAN_LIB
damiano@3206
    76
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
damiano@1970
    77
endif
damiano@1970
    78
ifdef GPGME_LIB
damiano@3206
    79
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
damiano@1970
    80
endif
damiano@1970
    81
ifdef NETPGP_LIB
damiano@3206
    82
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
damiano@3206
    83
endif
damiano@3206
    84
ifdef CPPUNIT_LIB
damiano@3206
    85
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
damiano@1970
    86
endif
krista@2637
    87
damiano@1970
    88
# Remove trailing ':'
damiano@1970
    89
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
damiano@1970
    90
damiano@3206
    91
ifeq ($(BUILD_FOR),Darwin)
damiano@3206
    92
    LIBPATH=DYLD_LIBRARY_PATH
damiano@3206
    93
else
damiano@3206
    94
    LIBPATH=LD_LIBRARY_PATH
damiano@2062
    95
endif
damiano@2062
    96
krista@3427
    97
# FIXME: this forces a path on execution which overrides system paths for
krista@3427
    98
#        libraries like iconv and causes runtime errors.
krista@3427
    99
#TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
krista@3427
   100
TEST_CMD_PFX=
damiano@3206
   101
vb@3456
   102
.PHONY: all clean test
damiano@2075
   103
vb@3466
   104
all:
krista@4015
   105
	make $(TARGET)
roker@1659
   106
damiano@3202
   107
%.d: %.cc
damiano@3202
   108
	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
krista@3170
   109
krista@4170
   110
$(TARGET): $(OBJS)
krista@4170
   111
	${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ -lpEpEngine -lgtest -lgtest_main -lsequoia_openpgp_ffi $(LDLIBS)
krista@2703
   112
edouard@1844
   113
krista@2639
   114
test: all
krista@4170
   115
	$(RM) -rf ./pEp_test_home/*
neal@4235
   116
	$(TEST_CMD_PFX) $(TEST_DEBUGGER) GTEST_COLOR=no python3 $(GTEST_PL) --gtest_color=no ./$(TARGET)
vb@2
   117
clean:
krista@3436
   118
	$(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
krista@4066
   119
	$(RM) -rf ./pEp_test_home/*
damiano@3202
   120
# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
damiano@3202
   121
ifneq ($(MAKECMDGOALS),clean)
damiano@3202
   122
    -include $(DEPS)
damiano@3202
   123
endif