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
     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 #VPATH=src
    11 
    12 # User's without python3 will skip the generated parts of the test suite. That's OK.
    13 PY_ENV:=$(shell command -v python3 2> /dev/null)
    14 
    15 TEST_HOME=$(HERE)/pEp_test_home
    16 
    17 TARGET=TestDriver
    18 
    19 SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
    20 OBJS:=$(addsuffix .o,$(basename $(SRCS)))
    21 DEPS:=$(OBJS:.o=.d)
    22 
    23 
    24 LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
    25 
    26 ifeq ($(OPENPGP),GPG)
    27     LDFLAGS+= $(GPGME_LIB)
    28 else ifeq ($(OPENPGP),NETPGP)
    29     LDFLAGS+= $(NETGPG_LIB)
    30 endif
    31 
    32 
    33 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
    34 
    35 ifeq ($(BUILD_FOR),Linux)
    36     LDLIBS+= -luuid
    37 endif
    38 
    39 ifdef SQLITE3_FROM_OS
    40     LDLIBS+= -lsqlite3
    41 endif
    42 
    43 ifeq ($(OPENPGP),GPG)
    44     #LDLIBS+= -lgpgme
    45 else ifeq ($(OPENPGP),NETPGP)
    46     LDLIBS+= -lnetpgp
    47     ifeq ($(BUILD_FOR),Linux)
    48         LDLIBS+= -ltre
    49     endif
    50 endif
    51 
    52 
    53 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    54 
    55 # FIXME Possibly missing incdirs: ASN1C_INC
    56 CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) -Wno-deprecated
    57 
    58 ifeq ($(OPENPGP),GPG)
    59     CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
    60 else ifeq ($(OPENPGP),NETPGP)
    61     CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
    62 endif
    63 
    64 
    65 .PHONY: all
    66 all: suitemaker $(TARGET) scripts
    67 
    68 %.d: %.cc
    69 	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
    70 
    71 $(TARGET): $(OBJS)
    72 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
    73 
    74 .PHONY: suitemaker
    75 suitemaker:
    76 ifndef PY_ENV
    77 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
    78 else
    79 ifndef EXCLUDE
    80 	$(PY_ENV) gensuitemaker.py
    81 else
    82 	# Comma-separated list, no spaces
    83 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
    84 endif
    85 endif
    86 
    87 .PHONY: scripts
    88 scripts:
    89 ifdef PY_ENV
    90 	$(PY_ENV) genscripts.py
    91 endif
    92 
    93 .PHONY: test
    94 test: all
    95 	$(TEST_DEBUGGER) ./$(TARGET)
    96 
    97 .PHONY: clean
    98 clean:
    99 	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   100 	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home
   101 
   102 # If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   103 ifneq ($(MAKECMDGOALS),clean)
   104     -include $(DEPS)
   105 endif