test/Makefile
author Damiano Boppart <damiano.boppart@pep.security>
Sat, 22 Dec 2018 01:53:50 +0100
branchmake-cleanup
changeset 3205 eb1093486582
parent 3204 fa2e7ead0f4e
child 3206 48f8fec4b7d1
permissions -rw-r--r--
Actually use the c++ linker when linking c++ objects files
damiano@1960
     1
# Copyright 2017, 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
damiano@3201
     8
include ../Makefile.conf
vb@1422
     9
damiano@3205
    10
#VPATH=src
damiano@3204
    11
damiano@3202
    12
# User's without python3 will skip the generated parts of the test suite. That's OK.
krista@3200
    13
PY_ENV:=$(shell command -v python3 2> /dev/null)
krista@2642
    14
krista@2639
    15
TEST_HOME=$(HERE)/pEp_test_home
krista@2637
    16
krista@2638
    17
TARGET=TestDriver
krista@2638
    18
damiano@3202
    19
SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
damiano@3202
    20
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
damiano@3202
    21
DEPS:=$(OBJS:.o=.d)
damiano@1970
    22
krista@2637
    23
damiano@3202
    24
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
damiano@1970
    25
damiano@3202
    26
ifeq ($(OPENPGP),GPG)
damiano@3202
    27
    LDFLAGS+= $(GPGME_LIB)
damiano@3202
    28
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    29
    LDFLAGS+= $(NETGPG_LIB)
krista@1989
    30
endif
krista@1988
    31
damiano@3202
    32
damiano@3202
    33
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
damiano@3202
    34
krista@3164
    35
ifeq ($(BUILD_FOR),Linux)
damiano@3202
    36
    LDLIBS+= -luuid
Edouard@178
    37
endif
Edouard@178
    38
damiano@2002
    39
ifdef SQLITE3_FROM_OS
damiano@3202
    40
    LDLIBS+= -lsqlite3
Edouard@178
    41
endif
Edouard@178
    42
damiano@3202
    43
ifeq ($(OPENPGP),GPG)
damiano@3202
    44
    #LDLIBS+= -lgpgme
damiano@3202
    45
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    46
    LDLIBS+= -lnetpgp
damiano@3202
    47
    ifeq ($(BUILD_FOR),Linux)
damiano@3202
    48
        LDLIBS+= -ltre
damiano@3202
    49
    endif
damiano@1970
    50
endif
krista@2637
    51
damiano@2062
    52
damiano@2075
    53
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
damiano@3202
    54
damiano@3202
    55
# FIXME Possibly missing incdirs: ASN1C_INC
damiano@3202
    56
CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) -Wno-deprecated
damiano@3202
    57
damiano@3202
    58
ifeq ($(OPENPGP),GPG)
damiano@3202
    59
    CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
damiano@3202
    60
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    61
    CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
damiano@2075
    62
endif
damiano@2075
    63
roker@1659
    64
damiano@3202
    65
.PHONY: all
damiano@3202
    66
all: suitemaker $(TARGET) scripts
damiano@3202
    67
damiano@3202
    68
%.d: %.cc
damiano@3202
    69
	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
krista@3170
    70
krista@2637
    71
$(TARGET): $(OBJS)
damiano@3205
    72
	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
krista@2639
    73
krista@2642
    74
.PHONY: suitemaker
krista@2642
    75
suitemaker:
krista@2642
    76
ifndef PY_ENV
krista@2642
    77
	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
krista@2642
    78
else
krista@2941
    79
ifndef EXCLUDE
krista@2642
    80
	$(PY_ENV) gensuitemaker.py
krista@2941
    81
else
krista@2941
    82
	# Comma-separated list, no spaces
krista@2941
    83
	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
krista@2941
    84
endif
krista@2642
    85
endif
krista@2703
    86
vb@2750
    87
.PHONY: scripts
damiano@3202
    88
scripts:
krista@2703
    89
ifdef PY_ENV
krista@2703
    90
	$(PY_ENV) genscripts.py
krista@2703
    91
endif
edouard@1844
    92
krista@2639
    93
.PHONY: test
krista@2639
    94
test: all
vb@2750
    95
	$(TEST_DEBUGGER) ./$(TARGET)
damiano@3202
    96
damiano@1970
    97
.PHONY: clean
vb@2
    98
clean:
damiano@3204
    99
	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
damiano@3205
   100
	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home
vb@2
   101
damiano@3202
   102
# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
damiano@3202
   103
ifneq ($(MAKECMDGOALS),clean)
damiano@3202
   104
    -include $(DEPS)
damiano@3202
   105
endif