test/Makefile
author Krista Bennett <krista@pep-project.org>
Mon, 30 Apr 2018 15:33:54 +0200
branchlocal_cpptest
changeset 2638 d52e41da942e
parent 2637 30db80f1a874
child 2639 60be0da624a6
permissions -rw-r--r--
forgot target
     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 SRC_DIRS := ./src ./src/util ./src/engine_tests
    15 SRCS := src/EngineTestSuite.cc src/EngineTestIndividualSuite.cc src/EngineTestSessionSuite.cc $(wildcard src/*/*.cc) src/SuiteMaker.cc src/TestDriver.cc
    16 OBJS := $(addsuffix .o,$(basename $(SRCS)))
    17 DEPS := $(OBJS:.o=.d)
    18 
    19 INC_DIRS := ./include /usr/local/include #$(shell find $(SRC_DIRS) -type d) 
    20 INC_FLAGS := $(addprefix -I,$(INC_DIRS))
    21 
    22 LDFLAGS += -L/usr/local/lib
    23 
    24 CFLAGS += -Wno-deprecated
    25 CXXFLAGS += -Wno-deprecated
    26 
    27 LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
    28 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    29 
    30 ifeq ($(BUILD_FOR),Linux)
    31 	LDLIBS+= -luuid
    32 endif
    33 
    34 ifeq ($(OPENPGP),NETPGP)
    35 	LDLIBS+= -lnetpgp
    36 endif
    37 
    38 ifdef SQLITE3_FROM_OS
    39 	LDLIBS+= -lsqlite3
    40 endif
    41 
    42 ifeq ($(shell uname),Darwin)
    43 	LIBPATH=DYLD_LIBRARY_PATH
    44 	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    45 else
    46 	LIBPATH=LD_LIBRARY_PATH
    47 	LLDB_BIN=lldb
    48 endif
    49 
    50 LDLIBS += -lcpptest
    51 
    52 
    53 # 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.
    54 # Note that += can not be used here, as it changes the amount of whitespace
    55 EXTRA_LIB_PATHS=../src:
    56 ifdef ETPAN_LIB
    57 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    58 endif
    59 ifdef GPGME_LIB
    60 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    61 endif
    62 ifdef NETPGP_LIB
    63 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    64 endif
    65 
    66 # Remove trailing ':'
    67 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    68 
    69 CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    70 ifneq ($(MAKECMDGOALS),clean)
    71 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    72 		$(error The macro NDEBUG must not be defined for test compilation.)
    73 	endif
    74 endif
    75 
    76 CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    77 ifneq ($(MAKECMDGOALS),clean)
    78 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
    79 		$(error The macro NDEBUG must not be defined for test compilation.)
    80 	endif
    81 endif
    82 
    83 
    84 CPPFLAGS += $(INC_FLAGS) -MMD -MP
    85 
    86 $(TARGET): $(OBJS)
    87 	$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)
    88 
    89 .PHONY: clean
    90 clean:
    91 	$(RM) $(TARGET) $(OBJS) $(DEPS)
    92 
    93 -include $(DEPS)
    94 
    95 
    96 # 
    97 # TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) #HOME=$(TEST_HOME) GNUPGHOME=$(TEST_GNUPGHOME)
    98 # 
    99 # 
   100 # CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
   101 # ifneq ($(MAKECMDGOALS),clean)
   102 # 	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
   103 # 		$(error The macro NDEBUG must not be defined for test compilation.)
   104 # 	endif
   105 # endif
   106 # 
   107 # CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
   108 # ifneq ($(MAKECMDGOALS),clean)
   109 # 	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
   110 # 		$(error The macro NDEBUG must not be defined for test compilation.)
   111 # 	endif
   112 # endif
   113 # 
   114 # # .PHONY: all
   115 # # all: main
   116 # 
   117 # # don't delete .o files!
   118 # .PRECIOUS: %.o
   119 # 
   120 # 
   121 # SRC_DIRS ?= ./src
   122 # 
   123 # SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
   124 # OBJS := $(addsuffix .o,$(basename $(SRCS)))
   125 # DEPS := $(OBJS:.o=.d)
   126 # 
   127 # CPPFLAGS += -I./include -MMD -MP
   128 # 
   129 # #	$(CC) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)
   130 # $(TARGET): $(OBJS)
   131 # 	$(CXX) $(CXXFLAGS) $^ $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
   132 # 
   133 # 
   134 # .PHONY: test_home_
   135 # test_home_: 
   136 # 	mkdir -p $(TEST_HOME)
   137 # 
   138 # # .PHONY: clean
   139 # # clean:
   140 # # 	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) msg4.asc msg_encrypt_for_self.asc
   141 # 
   142 # 
   143 # .PHONY: clean
   144 # clean:
   145 # 	$(RM) $(TARGET) $(OBJS) $(DEPS)
   146 # 
   147 # -include $(DEPS)
   148 # 
   149 # # .PHONY: main
   150 # # main: TestDriver
   151 # # 	
   152 # # TestDriver : src/TestDriver
   153 # # 	$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) $(LDLIBS) $(TESTOBJ) $(SUITEOBJ) -o TestDriver
   154 # # 
   155 # # .PHONY: testfiles
   156 # # testfiles : $(TESTOBJ)
   157 # # 	$(CXX) -c $(CXXFLAGS) $^ $(LDFLAGS) $(LDLIBS)
   158 # # 
   159 # # .PHONY: suitefiles	
   160 # # suitefiles : $(SUITEOBJ)
   161 # # 	$(CXX) -c $(CXXFLAGS) $^ $(LDFLAGS) $(LDLIBS)
   162 # #  
   163 # # # %_test : %_test.o test_util.o
   164 # # # 	$(CXX) $^ $(LDFLAGS) $(LDLIBS) -o $@
   165 # # # 
   166 # # # %_run : % test_home_
   167 # # # 	$(TEST_CMD_PFX) ./$<
   168 # # # 
   169 # # # %_lldb : % test_home_
   170 # # # 	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
   171 # # # 
   172 # # # %_valgrind : % test_home_
   173 # # # 	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
   174 # # # 
   175 # # # %_gdb : % test_home_
   176 # # # 	$(TEST_CMD_PFX) gdb ./$<
   177 # # 
   178 # # # .PHONY: unit_tests
   179 # # # unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
   180 # # 
   181 # # # .PHONY: compile
   182 # # # compile: $(UNIT_TESTS) $(TARGET)
   183 # # 
   184 # # # Installs the engine, not the test binaries
   185 # # .PHONY: install
   186 # # install:
   187 # # 	$(MAKE) -C .. install