test/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 23 Jan 2019 11:59:43 +0100
branchmake-cleanup
changeset 3235 7633eeee2cd4
parent 3208 204ff09a2787
parent 3234 538a03bab6b8
child 3236 efb3aff10882
permissions -rw-r--r--
Merged in sync
     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 	CFLAGS+= $(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) -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 TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
    94 
    95 
    96 .PHONY: all
    97 all: suitemaker $(TARGET) scripts
    98 
    99 %.d: %.cc
   100 	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
   101 
   102 $(TARGET): $(OBJS)
   103 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
   104 
   105 .PHONY: suitemaker
   106 suitemaker:
   107 ifndef PY_ENV
   108 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
   109 else
   110 ifndef EXCLUDE
   111 	$(PY_ENV) gensuitemaker.py
   112 else
   113 	# Comma-separated list, no spaces
   114 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
   115 endif
   116 endif
   117 
   118 .PHONY: scripts
   119 scripts:
   120 ifdef PY_ENV
   121 	$(PY_ENV) genscripts.py
   122 endif
   123 
   124 .PHONY: test
   125 test: all
   126     $(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
   127 
   128 .PHONY: clean
   129 clean:
   130 	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   131 	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home
   132 
   133 # If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   134 ifneq ($(MAKECMDGOALS),clean)
   135     -include $(DEPS)
   136 endif