test/Makefile
author Damiano Boppart <damiano.boppart@pep.security>
Sat, 22 Dec 2018 01:34:30 +0100
branchmake-cleanup
changeset 3204 fa2e7ead0f4e
parent 3203 47bb3a01f2e1
child 3205 eb1093486582
permissions -rw-r--r--
Minor makefile fixes
     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 # This should actually be done with a built-in rule
    73 #	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
    74 
    75 .PHONY: suitemaker
    76 suitemaker:
    77 ifndef PY_ENV
    78 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
    79 else
    80 ifndef EXCLUDE
    81 	$(PY_ENV) gensuitemaker.py
    82 else
    83 	# Comma-separated list, no spaces
    84 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
    85 endif
    86 endif
    87 
    88 .PHONY: scripts
    89 scripts:
    90 ifdef PY_ENV
    91 	$(PY_ENV) genscripts.py
    92 endif
    93 
    94 .PHONY: test
    95 test: all
    96 	$(TEST_DEBUGGER) ./$(TARGET)
    97 
    98 .PHONY: clean
    99 clean:
   100 	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   101 	$(RM) $(HERE)/*Tests msg_2.0.asc
   102 
   103 # If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   104 ifneq ($(MAKECMDGOALS),clean)
   105     -include $(DEPS)
   106 endif