test/Makefile
author Krista Bennett <krista@pep-project.org>
Wed, 06 Jun 2018 20:21:24 +0200
branchENGINE-422
changeset 2742 cd06139cb7fc
parent 2696 54689953f3bd
child 2749 147e3b5d461f
permissions -rw-r--r--
close branch
     1 
     2 # Copyright 2017, pEp Foundation
     3 # This file is part of pEpEngine
     4 # This file may be used under the terms of the GNU General Public License version 3
     5 # see LICENSE.txt
     6 
     7 include ../default.conf
     8 
     9 PY_ENV := $(shell command -v python3 2> /dev/null)
    10 
    11 HERE:=$(CURDIR)
    12 TEST_HOME=$(HERE)/pEp_test_home
    13 
    14 TARGET=TestDriver
    15 
    16 SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
    17 OBJS := $(addsuffix .o,$(basename $(SRCS)))
    18 DEPS := $(OBJS:.o=.d)
    19 
    20 INC_DIRS := ./include /usr/local/include  
    21 INC_FLAGS := $(addprefix -I,$(INC_DIRS))
    22 
    23 LDFLAGS += -L/usr/local/lib
    24 
    25 CFLAGS += -Wno-deprecated
    26 CXXFLAGS += -Wno-deprecated
    27 
    28 LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
    29 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    30 
    31 ifeq ($(BUILD_FOR),Linux)
    32 	LDLIBS+= -luuid
    33 endif
    34 
    35 ifeq ($(OPENPGP),NETPGP)
    36 	LDLIBS+= -lnetpgp
    37 endif
    38 
    39 ifdef SQLITE3_FROM_OS
    40 	LDLIBS+= -lsqlite3
    41 endif
    42 
    43 ifeq ($(shell uname),Darwin)
    44 	LIBPATH=DYLD_LIBRARY_PATH
    45 	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    46 else
    47 	LIBPATH=LD_LIBRARY_PATH
    48 	LLDB_BIN=lldb
    49 endif
    50 
    51 LDLIBS += -lcpptest
    52 
    53 
    54 # Create a list of the extra library paths for the loader. I do not assume that the engine (and its dependencies) are installed for testing.
    55 # Note that += can not be used here, as it changes the amount of whitespace
    56 EXTRA_LIB_PATHS=../src:
    57 ifdef ETPAN_LIB
    58 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    59 endif
    60 ifdef GPGME_LIB
    61 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    62 endif
    63 ifdef NETPGP_LIB
    64 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    65 endif
    66 
    67 # Remove trailing ':'
    68 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    69 
    70 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    71 ifneq ($(MAKECMDGOALS),clean)
    72 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    73 		$(error The macro NDEBUG must not be defined for test compilation.)
    74 	endif
    75 endif
    76 
    77 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    78 ifneq ($(MAKECMDGOALS),clean)
    79 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
    80 		$(error The macro NDEBUG must not be defined for test compilation.)
    81 	endif
    82 endif
    83 
    84 CPPFLAGS += $(INC_FLAGS) -MMD -MP
    85 
    86 all: suitemaker $(TARGET) test_home_ scripts
    87 	
    88 $(TARGET): $(OBJS)
    89 	$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
    90 
    91 .PHONY: suitemaker
    92 suitemaker:
    93 ifndef PY_ENV
    94 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
    95 else
    96 	$(PY_ENV) gensuitemaker.py
    97 endif
    98 		
    99 .PHONY: test_home_
   100 test_home_: 
   101 	
   102 
   103 .PHONY: test_home_
   104 scripts: 
   105 ifdef PY_ENV
   106 	$(PY_ENV) genscripts.py
   107 endif
   108 
   109 .PHONY: test
   110 test: all
   111 	./$(TARGET)
   112 	
   113 .PHONY: clean
   114 clean:
   115 	$(RM) $(TARGET) $(OBJS) $(DEPS)
   116 	$(RM) $(HERE)/*Tests
   117 
   118 
   119 
   120 -include $(DEPS)
   121