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