test/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 01 Apr 2019 21:16:34 +0200
branchmake-cleanup
changeset 3427 be87288f5391
parent 3282 92ec8ba7bc3c
child 3436 bf27fae218c5
permissions -rw-r--r--
Commented out TEST_CMD_PFX - it was forcing overrides of the system libraries libiconv was linked against. In general, not the best idea IMHO to force the library path at runtime like this
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@1513
     4
# see LICENSE.txt
vb@1513
     5
damiano@3202
     6
HERE:=$(CURDIR)
vb@2
     7
damiano@3201
     8
include ../Makefile.conf
krista@2642
     9
damiano@3202
    10
# User's without python3 will skip the generated parts of the test suite. That's OK.
krista@3200
    11
PY_ENV:=$(shell command -v python3 2> /dev/null)
krista@3180
    12
krista@2639
    13
TEST_HOME=$(HERE)/pEp_test_home
damiano@1970
    14
krista@2638
    15
TARGET=TestDriver
krista@2638
    16
damiano@3202
    17
SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
damiano@3202
    18
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
damiano@3202
    19
DEPS:=$(OBJS:.o=.d)
krista@2637
    20
krista@2637
    21
damiano@3202
    22
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
damiano@1970
    23
damiano@3202
    24
ifeq ($(OPENPGP),GPG)
damiano@3202
    25
    LDFLAGS+= $(GPGME_LIB)
damiano@3202
    26
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    27
    LDFLAGS+= $(NETGPG_LIB)
krista@3180
    28
endif
krista@3234
    29
damiano@3202
    30
damiano@3202
    31
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
damiano@1970
    32
krista@1989
    33
ifeq ($(BUILD_FOR),Linux)
damiano@3202
    34
    LDLIBS+= -luuid
edouard@1939
    35
endif
edouard@1939
    36
neal@3191
    37
ifeq ($(OPENPGP),SEQUOIA)
damiano@3236
    38
    LDFLAGS+= $(SEQUOIA_LDFLAGS)
damiano@3236
    39
    LDLIBS+= $(SEQUOIA_LIB)
damiano@3236
    40
    CFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
damiano@3236
    41
    INC_FLAGS+= $(SEQUOIA_INC)
neal@3191
    42
endif
neal@3191
    43
damiano@2002
    44
ifdef SQLITE3_FROM_OS
damiano@3202
    45
    LDLIBS+= -lsqlite3
damiano@2002
    46
endif
damiano@2002
    47
damiano@3202
    48
ifeq ($(OPENPGP),GPG)
damiano@3202
    49
    #LDLIBS+= -lgpgme
damiano@3202
    50
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    51
    LDLIBS+= -lnetpgp
damiano@3202
    52
    ifeq ($(BUILD_FOR),Linux)
damiano@3202
    53
        LDLIBS+= -ltre
damiano@3202
    54
    endif
damiano@1970
    55
endif
damiano@1970
    56
krista@2637
    57
damiano@3202
    58
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
krista@2637
    59
damiano@3202
    60
# FIXME Possibly missing incdirs: ASN1C_INC
damiano@3202
    61
CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) -Wno-deprecated
damiano@3202
    62
damiano@3202
    63
ifeq ($(OPENPGP),GPG)
damiano@3202
    64
    CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
damiano@3202
    65
else ifeq ($(OPENPGP),NETPGP)
damiano@3202
    66
    CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
krista@3180
    67
endif
krista@3180
    68
krista@3180
    69
damiano@3208
    70
EXTRA_LIB_PATHS=.:../src:
damiano@1970
    71
ifdef ETPAN_LIB
damiano@3206
    72
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
damiano@1970
    73
endif
damiano@1970
    74
ifdef GPGME_LIB
damiano@3206
    75
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
damiano@1970
    76
endif
damiano@1970
    77
ifdef NETPGP_LIB
damiano@3206
    78
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
damiano@3206
    79
endif
damiano@3206
    80
ifdef CPPUNIT_LIB
damiano@3206
    81
    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
damiano@1970
    82
endif
krista@2637
    83
damiano@1970
    84
# Remove trailing ':'
damiano@1970
    85
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
damiano@1970
    86
damiano@3206
    87
ifeq ($(BUILD_FOR),Darwin)
damiano@3206
    88
    LIBPATH=DYLD_LIBRARY_PATH
damiano@3206
    89
else
damiano@3206
    90
    LIBPATH=LD_LIBRARY_PATH
damiano@2062
    91
endif
damiano@2062
    92
krista@3427
    93
# FIXME: this forces a path on execution which overrides system paths for
krista@3427
    94
#        libraries like iconv and causes runtime errors.
krista@3427
    95
#TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
krista@3427
    96
TEST_CMD_PFX=
damiano@2075
    97
roker@1659
    98
damiano@3202
    99
.PHONY: all
damiano@3202
   100
all: suitemaker $(TARGET) scripts
krista@3180
   101
damiano@3202
   102
%.d: %.cc
damiano@3202
   103
	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
krista@3170
   104
krista@2637
   105
$(TARGET): $(OBJS)
damiano@3205
   106
	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
edouard@1844
   107
krista@2642
   108
.PHONY: suitemaker
krista@2642
   109
suitemaker:
krista@2642
   110
ifndef PY_ENV
krista@2642
   111
	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
krista@2642
   112
else
krista@2941
   113
ifndef EXCLUDE
krista@2642
   114
	$(PY_ENV) gensuitemaker.py
krista@2941
   115
else
krista@2941
   116
	# Comma-separated list, no spaces
krista@2941
   117
	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
krista@2941
   118
endif
krista@2642
   119
endif
krista@2696
   120
vb@2750
   121
.PHONY: scripts
damiano@3202
   122
scripts:
krista@2696
   123
ifdef PY_ENV
krista@2696
   124
	$(PY_ENV) genscripts.py
krista@2696
   125
endif
krista@2639
   126
krista@2639
   127
.PHONY: test
krista@2639
   128
test: all
damiano@3236
   129
	$(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
neal@3191
   130
damiano@1970
   131
.PHONY: clean
vb@2
   132
clean:
damiano@3204
   133
	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
damiano@3205
   134
	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home
vb@2
   135
damiano@3202
   136
# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
damiano@3202
   137
ifneq ($(MAKECMDGOALS),clean)
damiano@3202
   138
    -include $(DEPS)
damiano@3202
   139
endif