test/Makefile
author Krista Bennett <krista@pep-project.org>
Mon, 03 Dec 2018 12:26:02 +0100
changeset 3170 5cb1f7917d5a
parent 3164 5c4b1bd2c638
child 3180 f7ce02c58571
child 3228 0d6ffda184f7
permissions -rw-r--r--
Changes in build to make NETPGP work in the tests.
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@2645
     9
PY_ENV := $(shell command -v python3 2> /dev/null)
krista@2642
    10
krista@2637
    11
HERE:=$(CURDIR)
krista@2639
    12
TEST_HOME=$(HERE)/pEp_test_home
damiano@1970
    13
krista@2638
    14
TARGET=TestDriver
krista@2638
    15
krista@2639
    16
SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
krista@2637
    17
OBJS := $(addsuffix .o,$(basename $(SRCS)))
krista@2637
    18
DEPS := $(OBJS:.o=.d)
krista@2637
    19
krista@3170
    20
INC_DIRS := ./include /usr/local/include ../src ../sync ../asn.1
damiano@2975
    21
INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
krista@2637
    22
krista@2637
    23
LDFLAGS += -L/usr/local/lib
krista@2637
    24
krista@2637
    25
CFLAGS += -Wno-deprecated
krista@2637
    26
CXXFLAGS += -Wno-deprecated
krista@3170
    27
CFLAGS:=$(filter-out -Wall,$(CFLAGS))
damiano@1970
    28
damiano@2975
    29
LDFLAGS+= $(ETPAN_LIB) $(CPPUNIT_LIB) -L../asn.1 -L../src
damiano@1970
    30
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
damiano@1970
    31
krista@1989
    32
ifeq ($(BUILD_FOR),Linux)
krista@2637
    33
	LDLIBS+= -luuid
Edouard@178
    34
endif
Edouard@178
    35
damiano@1972
    36
ifeq ($(OPENPGP),NETPGP)
krista@2637
    37
	LDLIBS+= -lnetpgp
krista@3170
    38
	CFLAGS+= -DUSE_NETPGP
krista@3164
    39
ifeq ($(BUILD_FOR),Linux)
krista@3164
    40
	LDLIBS+= -ltre
krista@3164
    41
endif
edouard@1939
    42
endif
edouard@1939
    43
damiano@2002
    44
ifdef SQLITE3_FROM_OS
krista@2637
    45
	LDLIBS+= -lsqlite3
damiano@2002
    46
endif
damiano@2002
    47
damiano@1970
    48
ifeq ($(shell uname),Darwin)
krista@2637
    49
	LIBPATH=DYLD_LIBRARY_PATH
krista@2637
    50
	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
damiano@1970
    51
else
krista@2637
    52
	LIBPATH=LD_LIBRARY_PATH
krista@2637
    53
	LLDB_BIN=lldb
damiano@1970
    54
endif
damiano@1970
    55
krista@2637
    56
LDLIBS += -lcpptest
krista@2637
    57
krista@2637
    58
damiano@1972
    59
# 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
    60
# Note that += can not be used here, as it changes the amount of whitespace
damiano@1970
    61
EXTRA_LIB_PATHS=../src:
damiano@1970
    62
ifdef ETPAN_LIB
krista@2637
    63
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
damiano@1970
    64
endif
damiano@1970
    65
ifdef GPGME_LIB
krista@2637
    66
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
damiano@1970
    67
endif
damiano@1970
    68
ifdef NETPGP_LIB
krista@2637
    69
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
damiano@1970
    70
endif
krista@2637
    71
damiano@1970
    72
# Remove trailing ':'
damiano@1970
    73
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
damiano@1970
    74
damiano@2074
    75
CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
damiano@2063
    76
ifneq ($(MAKECMDGOALS),clean)
krista@2637
    77
	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
krista@2637
    78
		$(error The macro NDEBUG must not be defined for test compilation.)
krista@2637
    79
	endif
damiano@2062
    80
endif
damiano@2062
    81
damiano@2075
    82
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
damiano@2075
    83
ifneq ($(MAKECMDGOALS),clean)
krista@2637
    84
	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
krista@2637
    85
		$(error The macro NDEBUG must not be defined for test compilation.)
krista@2637
    86
	endif
damiano@2075
    87
endif
damiano@2075
    88
krista@2637
    89
CPPFLAGS += $(INC_FLAGS) -MMD -MP
roker@1659
    90
krista@2696
    91
all: suitemaker $(TARGET) test_home_ scripts
krista@2639
    92
	
krista@3170
    93
%.o: %.cc
krista@3170
    94
	$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
krista@3170
    95
krista@2637
    96
$(TARGET): $(OBJS)
krista@3170
    97
	$(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
edouard@1844
    98
krista@2642
    99
.PHONY: suitemaker
krista@2642
   100
suitemaker:
krista@2642
   101
ifndef PY_ENV
krista@2642
   102
	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
krista@2642
   103
else
krista@2941
   104
ifndef EXCLUDE
krista@2642
   105
	$(PY_ENV) gensuitemaker.py
krista@2941
   106
else
krista@2941
   107
	# Comma-separated list, no spaces
krista@2941
   108
	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
krista@2941
   109
endif
krista@2642
   110
endif
krista@2642
   111
		
krista@2639
   112
.PHONY: test_home_
krista@2639
   113
test_home_: 
krista@2696
   114
	
krista@2696
   115
vb@2750
   116
.PHONY: scripts
krista@2696
   117
scripts: 
krista@2696
   118
ifdef PY_ENV
krista@2696
   119
	$(PY_ENV) genscripts.py
krista@2696
   120
endif
krista@2639
   121
krista@2639
   122
.PHONY: test
krista@2639
   123
test: all
vb@2750
   124
	$(TEST_DEBUGGER) ./$(TARGET)
krista@2639
   125
	
damiano@1970
   126
.PHONY: clean
vb@2
   127
clean:
krista@2637
   128
	$(RM) $(TARGET) $(OBJS) $(DEPS)
krista@2696
   129
	$(RM) $(HERE)/*Tests
vb@2
   130
krista@2639
   131
krista@2639
   132
krista@2637
   133
-include $(DEPS)
krista@2639
   134