test/Makefile
author Krista Bennett <krista@pep-project.org>
Wed, 02 May 2018 16:59:14 +0200
branchlocal_cpptest
changeset 2642 7dbfc6c3f3c8
parent 2639 60be0da624a6
child 2644 271d7a25c8d3
permissions -rw-r--r--
working on autogen of test suite object builders
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@2642
     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@2639
    20
INC_DIRS := ./include /usr/local/include  
krista@2637
    21
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
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
damiano@1970
    27
damiano@1970
    28
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
damiano@1970
    29
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
damiano@1970
    30
krista@1989
    31
ifeq ($(BUILD_FOR),Linux)
krista@2637
    32
	LDLIBS+= -luuid
Edouard@178
    33
endif
Edouard@178
    34
damiano@1972
    35
ifeq ($(OPENPGP),NETPGP)
krista@2637
    36
	LDLIBS+= -lnetpgp
edouard@1939
    37
endif
edouard@1939
    38
damiano@2002
    39
ifdef SQLITE3_FROM_OS
krista@2637
    40
	LDLIBS+= -lsqlite3
damiano@2002
    41
endif
damiano@2002
    42
damiano@1970
    43
ifeq ($(shell uname),Darwin)
krista@2637
    44
	LIBPATH=DYLD_LIBRARY_PATH
krista@2637
    45
	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
damiano@1970
    46
else
krista@2637
    47
	LIBPATH=LD_LIBRARY_PATH
krista@2637
    48
	LLDB_BIN=lldb
damiano@1970
    49
endif
damiano@1970
    50
krista@2637
    51
LDLIBS += -lcpptest
krista@2637
    52
krista@2637
    53
damiano@1972
    54
# 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
    55
# Note that += can not be used here, as it changes the amount of whitespace
damiano@1970
    56
EXTRA_LIB_PATHS=../src:
damiano@1970
    57
ifdef ETPAN_LIB
krista@2637
    58
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
damiano@1970
    59
endif
damiano@1970
    60
ifdef GPGME_LIB
krista@2637
    61
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
damiano@1970
    62
endif
damiano@1970
    63
ifdef NETPGP_LIB
krista@2637
    64
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
damiano@1970
    65
endif
krista@2637
    66
damiano@1970
    67
# Remove trailing ':'
damiano@1970
    68
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
damiano@1970
    69
damiano@2074
    70
CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
damiano@2063
    71
ifneq ($(MAKECMDGOALS),clean)
krista@2637
    72
	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
krista@2637
    73
		$(error The macro NDEBUG must not be defined for test compilation.)
krista@2637
    74
	endif
damiano@2062
    75
endif
damiano@2062
    76
damiano@2075
    77
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
damiano@2075
    78
ifneq ($(MAKECMDGOALS),clean)
krista@2637
    79
	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
krista@2637
    80
		$(error The macro NDEBUG must not be defined for test compilation.)
krista@2637
    81
	endif
damiano@2075
    82
endif
damiano@2075
    83
krista@2637
    84
CPPFLAGS += $(INC_FLAGS) -MMD -MP
roker@1659
    85
krista@2642
    86
all: suitemaker $(TARGET) test_home_
krista@2639
    87
	
krista@2637
    88
$(TARGET): $(OBJS)
krista@2639
    89
	$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
edouard@1844
    90
krista@2642
    91
.PHONY: suitemaker
krista@2642
    92
suitemaker:
krista@2642
    93
ifndef PY_ENV
krista@2642
    94
	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
krista@2642
    95
else
krista@2642
    96
	$(PY_ENV) gensuitemaker.py
krista@2642
    97
endif
krista@2642
    98
		
krista@2639
    99
.PHONY: test_home_
krista@2639
   100
test_home_: 
krista@2639
   101
	mkdir -p $(TEST_HOME)
krista@2639
   102
krista@2639
   103
TEST_CMD_=$(TARGET)
krista@2639
   104
krista@2639
   105
.PHONY: test
krista@2639
   106
test: all
krista@2639
   107
	./$(TARGET) $(TEST_CMD_)
krista@2639
   108
	
damiano@1970
   109
.PHONY: clean
vb@2
   110
clean:
krista@2637
   111
	$(RM) $(TARGET) $(OBJS) $(DEPS)
vb@2
   112
krista@2639
   113
krista@2639
   114
krista@2637
   115
-include $(DEPS)
krista@2639
   116