test/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 10 May 2019 14:07:57 +0200
branchsync
changeset 3660 5baccf081566
parent 3538 cd36d9701749
child 3648 f7f07e2825d1
child 3653 b00047c994f6
child 3677 51c4944d6257
child 4015 37ef8c764f83
permissions -rw-r--r--
Upgraded to cpptest 2.0.0 compatibility - pre 2.0.0 cpptest will no longer compile! (There's no define to operate on for conditional compilation here, so I am just unilaterally upgrading, since the release is from January, and the previous release is more than 2 years old...
     1 # Copyright 2017, pEp Foundation
     2 # This file is part of pEpEngine
     3 # This file may be used under the terms of the GNU General Public License version 3
     4 # see LICENSE.txt
     5 
     6 HERE:=$(CURDIR)
     7 
     8 include ../Makefile.conf
     9 
    10 # User's without python3 will skip the generated parts of the test suite. That's OK.
    11 PY_ENV:=$(shell command -v python3 2> /dev/null)
    12 
    13 TEST_HOME=$(HERE)/pEp_test_home
    14 
    15 TARGET=TestDriver
    16 
    17 SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
    18 OBJS:=$(addsuffix .o,$(basename $(SRCS)))
    19 DEPS:=$(OBJS:.o=.d)
    20 
    21 
    22 LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
    23 
    24 ifeq ($(OPENPGP),GPG)
    25     LDFLAGS+= $(GPGME_LIB)
    26 else ifeq ($(OPENPGP),NETPGP)
    27     LDFLAGS+= $(NETGPG_LIB)
    28 endif
    29 
    30 
    31 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
    32 
    33 ifeq ($(BUILD_FOR),Linux)
    34     LDLIBS+= -luuid
    35 endif
    36 
    37 ifeq ($(OPENPGP),SEQUOIA)
    38     LDFLAGS+= $(SEQUOIA_LDFLAGS)
    39     LDLIBS+= $(SEQUOIA_LIB)
    40     CXXFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
    41     INC_FLAGS+= $(SEQUOIA_INC)
    42 endif
    43 
    44 ifdef SQLITE3_FROM_OS
    45     LDLIBS+= -lsqlite3
    46 endif
    47 
    48 ifeq ($(OPENPGP),GPG)
    49     #LDLIBS+= -lgpgme
    50 else ifeq ($(OPENPGP),NETPGP)
    51     LDLIBS+= -lnetpgp
    52     ifeq ($(BUILD_FOR),Linux)
    53         LDLIBS+= -ltre
    54     endif
    55 endif
    56 
    57 
    58 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    59 
    60 # FIXME Possibly missing incdirs: ASN1C_INC
    61 CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) $(INC_FLAGS) -Wno-deprecated
    62 
    63 ifeq ($(OPENPGP),GPG)
    64     CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
    65 else ifeq ($(OPENPGP),NETPGP)
    66     CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
    67 endif
    68 
    69 
    70 EXTRA_LIB_PATHS=.:../src:
    71 ifdef ETPAN_LIB
    72     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    73 endif
    74 ifdef GPGME_LIB
    75     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    76 endif
    77 ifdef NETPGP_LIB
    78     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    79 endif
    80 ifdef CPPUNIT_LIB
    81     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
    82 endif
    83 
    84 # Remove trailing ':'
    85 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    86 
    87 ifeq ($(BUILD_FOR),Darwin)
    88     LIBPATH=DYLD_LIBRARY_PATH
    89 else
    90     LIBPATH=LD_LIBRARY_PATH
    91 endif
    92 
    93 # FIXME: this forces a path on execution which overrides system paths for
    94 #        libraries like iconv and causes runtime errors.
    95 #TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
    96 TEST_CMD_PFX=
    97 
    98 .PHONY: all clean test
    99 
   100 all:
   101 	make .suitemaker
   102 	make $(TARGET) .scripts
   103 	touch .suitemaker
   104 
   105 %.d: %.cc
   106 	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
   107 
   108 .suitemaker: src
   109 ifndef PY_ENV
   110 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
   111 else
   112 ifndef EXCLUDE
   113 	$(PY_ENV) gensuitemaker.py
   114 else
   115 	# Comma-separated list, no spaces
   116 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
   117 endif
   118 endif
   119 
   120 $(TARGET): $(OBJS)
   121 	$(LINK.cc) $(OBJS) $(LOADLIBES) $(LDLIBS) -o $@
   122 
   123 .scripts:
   124 ifdef PY_ENV
   125 	$(PY_ENV) genscripts.py
   126 	touch .scripts
   127 endif
   128 
   129 test: all
   130 	$(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
   131 
   132 clean:
   133 	$(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   134 	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home .scripts .suitemaker
   135 
   136 # If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   137 ifneq ($(MAKECMDGOALS),clean)
   138     -include $(DEPS)
   139 endif