test/Makefile
author Krista Bennett <krista@pep-project.org>
Tue, 01 May 2018 14:40:18 +0200
branchlocal_cpptest
changeset 2639 60be0da624a6
parent 2638 d52e41da942e
child 2642 7dbfc6c3f3c8
permissions -rw-r--r--
Bug fixes, shelving to fix another bug
     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 HERE:=$(CURDIR)
    10 TEST_HOME=$(HERE)/pEp_test_home
    11 
    12 TARGET=TestDriver
    13 
    14 SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
    15 OBJS := $(addsuffix .o,$(basename $(SRCS)))
    16 DEPS := $(OBJS:.o=.d)
    17 
    18 INC_DIRS := ./include /usr/local/include  
    19 INC_FLAGS := $(addprefix -I,$(INC_DIRS))
    20 
    21 LDFLAGS += -L/usr/local/lib
    22 
    23 CFLAGS += -Wno-deprecated
    24 CXXFLAGS += -Wno-deprecated
    25 
    26 LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
    27 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    28 
    29 ifeq ($(BUILD_FOR),Linux)
    30 	LDLIBS+= -luuid
    31 endif
    32 
    33 ifeq ($(OPENPGP),NETPGP)
    34 	LDLIBS+= -lnetpgp
    35 endif
    36 
    37 ifdef SQLITE3_FROM_OS
    38 	LDLIBS+= -lsqlite3
    39 endif
    40 
    41 ifeq ($(shell uname),Darwin)
    42 	LIBPATH=DYLD_LIBRARY_PATH
    43 	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    44 else
    45 	LIBPATH=LD_LIBRARY_PATH
    46 	LLDB_BIN=lldb
    47 endif
    48 
    49 LDLIBS += -lcpptest
    50 
    51 
    52 # 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.
    53 # Note that += can not be used here, as it changes the amount of whitespace
    54 EXTRA_LIB_PATHS=../src:
    55 ifdef ETPAN_LIB
    56 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    57 endif
    58 ifdef GPGME_LIB
    59 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    60 endif
    61 ifdef NETPGP_LIB
    62 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    63 endif
    64 
    65 # Remove trailing ':'
    66 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    67 
    68 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    69 ifneq ($(MAKECMDGOALS),clean)
    70 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    71 		$(error The macro NDEBUG must not be defined for test compilation.)
    72 	endif
    73 endif
    74 
    75 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    76 ifneq ($(MAKECMDGOALS),clean)
    77 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
    78 		$(error The macro NDEBUG must not be defined for test compilation.)
    79 	endif
    80 endif
    81 
    82 CPPFLAGS += $(INC_FLAGS) -MMD -MP
    83 
    84 all: $(TARGET) test_home_
    85 	
    86 $(TARGET): $(OBJS)
    87 	$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
    88 
    89 .PHONY: test_home_
    90 test_home_: 
    91 	mkdir -p $(TEST_HOME)
    92 
    93 TEST_CMD_=$(TARGET)
    94 
    95 .PHONY: test
    96 test: all
    97 	./$(TARGET) $(TEST_CMD_)
    98 	
    99 .PHONY: clean
   100 clean:
   101 	$(RM) $(TARGET) $(OBJS) $(DEPS)
   102 
   103 
   104 
   105 -include $(DEPS)
   106