test/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 23 Jan 2019 11:23:09 +0100
branchsync
changeset 3234 538a03bab6b8
parent 3210 206d68617cf8
parent 3229 6d555032f84c
child 3235 7633eeee2cd4
child 3244 bf242e94441c
permissions -rw-r--r--
merged in default
     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 ../src ../sync ../asn.1
    21 INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
    22 
    23 LDFLAGS += -L/usr/local/lib
    24 
    25 CFLAGS += -Wno-deprecated
    26 CXXFLAGS += -Wno-deprecated
    27 CFLAGS:=$(filter-out -Wall,$(CFLAGS))
    28 
    29 LDFLAGS+= $(ETPAN_LIB) $(CPPUNIT_LIB) -L../asn.1 -L../src
    30 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    31 
    32 ifeq ($(BUILD_FOR),Linux)
    33 	LDLIBS+= -luuid
    34 endif
    35 
    36 ifeq ($(OPENPGP),NETPGP)
    37 	LDLIBS+= -lnetpgp
    38 	CFLAGS+= -DUSE_NETPGP
    39 ifeq ($(BUILD_FOR),Linux)
    40 	LDLIBS+= -ltre
    41 endif
    42 endif
    43 
    44 ifeq ($(OPENPGP),SEQUOIA)
    45 	LDFLAGS+= $(SEQUOIA_LDFLAGS)
    46 	LDLIBS+= $(SEQUOIA_LIB)
    47 	CFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
    48 	INC_FLAGS+= $(SEQUOIA_INC)
    49 endif
    50 
    51 ifdef SQLITE3_FROM_OS
    52 	LDLIBS+= -lsqlite3
    53 endif
    54 
    55 ifeq ($(shell uname),Darwin)
    56 	LIBPATH=DYLD_LIBRARY_PATH
    57 	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    58 else
    59 	LIBPATH=LD_LIBRARY_PATH
    60 	LLDB_BIN=lldb
    61 endif
    62 
    63 LDLIBS+= -lcpptest
    64 
    65 
    66 # 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.
    67 # Note that += can not be used here, as it changes the amount of whitespace
    68 EXTRA_LIB_PATHS=../src:
    69 ifdef ETPAN_LIB
    70 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    71 endif
    72 ifdef GPGME_LIB
    73 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    74 endif
    75 ifdef NETPGP_LIB
    76 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    77 endif
    78 
    79 # Remove trailing ':'
    80 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    81 
    82 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    83 ifneq ($(MAKECMDGOALS),clean)
    84 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    85 		$(error The macro NDEBUG must not be defined for test compilation.)
    86 	endif
    87 endif
    88 
    89 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    90 ifneq ($(MAKECMDGOALS),clean)
    91 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
    92 		$(error The macro NDEBUG must not be defined for test compilation.)
    93 	endif
    94 endif
    95 
    96 CPPFLAGS += $(INC_FLAGS) -MMD -MP
    97 
    98 all: suitemaker $(TARGET) test_home_ scripts
    99 	
   100 %.o: %.cc
   101 	$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
   102 
   103 $(TARGET): $(OBJS)
   104 	$(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
   105 
   106 .PHONY: suitemaker
   107 suitemaker:
   108 ifndef PY_ENV
   109 	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
   110 else
   111 ifndef EXCLUDE
   112 	$(PY_ENV) gensuitemaker.py
   113 else
   114 	# Comma-separated list, no spaces
   115 	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
   116 endif
   117 endif
   118 		
   119 .PHONY: test_home_
   120 test_home_: 
   121 	
   122 
   123 .PHONY: scripts
   124 scripts: 
   125 ifdef PY_ENV
   126 	$(PY_ENV) genscripts.py
   127 endif
   128 
   129 .PHONY: test
   130 test: all
   131 	ulimit -n 20000; $(TEST_DEBUGGER) ./$(TARGET)
   132 
   133 .PHONY: clean
   134 clean:
   135 	$(RM) $(TARGET) $(OBJS) $(DEPS)
   136 	$(RM) $(HERE)/*Tests msg_2.0.asc
   137 
   138 
   139 
   140 -include $(DEPS)
   141