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