test/Makefile
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 17 Sep 2019 16:21:57 +0200
branchsync
changeset 4066 6d4d7ea7823e
parent 4030 ba2eed4caacf
child 4153 f4e9a99c1123
permissions -rw-r--r--
added clean to test makefile
     1 # Copyright 2019, pEp Foundation
     2 # This file is part of pEpEngine
     3 # This file may be used under the terms of the GNU General Public License version 3
     4 # see LICENSE.txt
     5 
     6 HERE:=$(CURDIR)
     7 
     8 # Presumably can be changed in local.conf by putting this here?
     9 GTEST_DIR:=googletest/googletest
    10 GTEST_PL_DIR:=googletest/gtest-parallel
    11 GTEST_INC_DIR:=$(GTEST_DIR)/include
    12 
    13 include ../Makefile.conf
    14 
    15 SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
    16 OBJS:=$(addsuffix .o,$(basename $(SRCS)))
    17 DEPS:=$(OBJS:.o=.d)
    18 
    19 LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
    20 
    21 TARGET:=EngineTests 
    22 
    23 ifeq ($(OPENPGP),GPG)
    24     LDFLAGS+= $(GPGME_LIB)
    25 else ifeq ($(OPENPGP),NETPGP)
    26     LDFLAGS+= $(NETGPG_LIB)
    27 endif
    28 
    29 LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    30 
    31 ifeq ($(BUILD_FOR),Linux)
    32     LDLIBS+= -luuid
    33 endif
    34 
    35 ifeq ($(OPENPGP),SEQUOIA)
    36     LDFLAGS+= $(SEQUOIA_LDFLAGS)
    37     LDLIBS+= $(SEQUOIA_LIB)
    38     CXXFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
    39     INC_FLAGS+= $(SEQUOIA_INC)
    40 endif
    41 
    42 ifdef SQLITE3_FROM_OS
    43     LDLIBS+= -lsqlite3
    44 endif
    45 
    46 ifeq ($(OPENPGP),GPG)
    47     #LDLIBS+= -lgpgme
    48 else ifeq ($(OPENPGP),NETPGP)
    49     LDLIBS+= -lnetpgp
    50     ifeq ($(BUILD_FOR),Linux)
    51         LDLIBS+= -ltre
    52     endif
    53 endif
    54 
    55 CXXFLAGS:=-I$(GTEST_INC_DIR) $(filter-out -DNDEBUG,$(CXXFLAGS))
    56 
    57 # FIXME Possibly missing incdirs: ASN1C_INC
    58 CXXFLAGS+= -I./src -I../sync $(CPPUNIT_INC) $(INC_FLAGS) -Wno-deprecated
    59 
    60 ifeq ($(OPENPGP),GPG)
    61     CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
    62 else ifeq ($(OPENPGP),NETPGP)
    63     CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
    64 endif
    65 
    66 EXTRA_LIB_PATHS=.:../src:
    67 ifdef ETPAN_LIB
    68     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    69 endif
    70 ifdef GPGME_LIB
    71     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    72 endif
    73 ifdef NETPGP_LIB
    74     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    75 endif
    76 ifdef CPPUNIT_LIB
    77     EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
    78 endif
    79 
    80 # Remove trailing ':'
    81 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    82 
    83 ifeq ($(BUILD_FOR),Darwin)
    84     LIBPATH=DYLD_LIBRARY_PATH
    85 else
    86     LIBPATH=LD_LIBRARY_PATH
    87 endif
    88 
    89 # FIXME: this forces a path on execution which overrides system paths for
    90 #        libraries like iconv and causes runtime errors.
    91 #TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
    92 TEST_CMD_PFX=
    93 
    94 .PHONY: all clean test
    95 
    96 all:
    97 	make $(TARGET)
    98 
    99 %.d: %.cc
   100 	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
   101 
   102 $(TARGET): $(OBJS) gtest-all.o gtest_main.o
   103 #	$(LINK.cc) $(OBJS) $(LOADLIBES) $(LDLIBS) -o $@
   104 	${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ -lpEpEngine $(LDLIBS)
   105 
   106 gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc
   107 	${CXX} ${CXXFLAGS} $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -isystem $(GTEST_DIR)/include -o $@ -c $<
   108 
   109 gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc
   110 	${CXX} ${CXXFLAGS} $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -isystem $(GTEST_DIR)/include -o $@ -c $<
   111 
   112 test: all
   113 	$(TEST_CMD_PFX) $(TEST_DEBUGGER) python3 $(GTEST_PL_DIR)/gtest_parallel.py ./$(TARGET)
   114 
   115 clean:
   116 	$(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   117 	$(RM) gtest_main.o gtest-all.o
   118 	$(RM) -rf ./pEp_test_home/*
   119 # If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   120 ifneq ($(MAKECMDGOALS),clean)
   121     -include $(DEPS)
   122 endif