p≡p engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.3 KiB

3 years ago
  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. HERE:=$(CURDIR)
  6. GTEST_SRC_DIR:=/usr/src/gtest
  7. GTEST_INC_DIR:=$(GTEST_SRC_DIR)/include
  8. GTEST_PL:=$(HOME)/src/gtest-parallel/gtest_parallel.py
  9. include ../Makefile.conf # This should import changed values for the above from
  10. # local.conf
  11. SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
  12. OBJS:=$(addsuffix .o,$(basename $(SRCS)))
  13. DEPS:=$(OBJS:.o=.d)
  14. ifeq ($(BUILD_ON),OS/390)
  15. OBJS+=../src/libpEpEngine.a
  16. OBJS+=/usr/lib/GSKCMS64.x
  17. OBJS+=/usr/lib/CSNPCA64.x
  18. OBJS+=/user/lev/lib/libetpan-no-mt.a
  19. endif
  20. #endif
  21. LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(GTEST_LDFLAGS)
  22. TARGET:=EngineTests
  23. GTEST_SUITE_SYM:=test_suite_name
  24. ifeq ($(shell grep -c $(GTEST_SUITE_SYM) $(GTEST_SRC_DIR)/src/gtest.cc),0)
  25. GTEST_SUITE_SYM=test_case_name
  26. endif
  27. CPPFLAGS+= -DGTEST_SUITE_SYM=$(GTEST_SUITE_SYM)
  28. ifdef PEP_MIME
  29. LDLIBS+= -lpEpMIME
  30. else
  31. ifneq ($(BUILD_ON),OS/390)
  32. LDLIBS+= -letpan -lpEpEngine -lstdc++
  33. endif
  34. endif
  35. LDLIBS+= -lasn1
  36. ifeq ($(BUILD_FOR),Linux)
  37. LDLIBS+= -luuid -lpthread
  38. endif
  39. ifeq ($(OPENPGP),SEQUOIA)
  40. LDFLAGS+= $(SEQUOIA_LDFLAGS)
  41. LDLIBS+= $(SEQUOIA_LIB)
  42. CXXFLAGS+= $(SEQUOIA_CFLAGS)
  43. CPPFLAGS+= -DUSE_SEQUOIA
  44. INC_FLAGS+= $(SEQUOIA_INC)
  45. endif
  46. ifdef SQLITE3_FROM_OS
  47. LDLIBS+= -lsqlite3
  48. endif
  49. ifeq ($(OPENPGP),GPG)
  50. LDLIBS+= -lgpgme
  51. else ifeq ($(OPENPGP),NETPGP)
  52. LDLIBS+=$(NETPGP_LIB)
  53. ifeq ($(BUILD_FOR),Linux)
  54. LDLIBS+= -ltre
  55. endif
  56. endif
  57. CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
  58. # FIXME Possibly missing incdirs: ASN1C_INC
  59. CXXFLAGS+= -I$(GTEST_INC_DIR) -I./src -I../sync $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
  60. CXXFLAGS+= -I./src -I../src -I ../asn.1 -I../sync $(INC_FLAGS)
  61. CXXFLAGS+= -Wno-deprecated -Wno-unused-variable
  62. EXTRA_LIB_PATHS=.:../src:
  63. ifndef PEP_MIME
  64. ifdef ETPAN_LIB
  65. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
  66. endif
  67. endif
  68. # Remove trailing ':'
  69. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
  70. ifeq ($(BUILD_FOR),Darwin)
  71. LIBPATH=DYLD_LIBRARY_PATH
  72. else
  73. LIBPATH=LD_LIBRARY_PATH
  74. endif
  75. # The LIBPATH variable, whatever it is, should have the value of EXTRA_LIB_PATHS
  76. # *prepended* to it -- without the rest of the path being lost. This allows the
  77. # user to use manually-installed version of some dependency libraries rather
  78. # than system libraries.
  79. TEST_CMD_PFX=$(LIBPATH)="$(EXTRA_LIB_PATHS):$$$(LIBPATH)"
  80. ifeq ($(TEST_CMD_PFX),)
  81. TEST_CMD_PFX=
  82. endif
  83. .PHONY: all clean test
  84. all:
  85. make $(TARGET)
  86. %.d: %.cc
  87. $(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< \
  88. | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
  89. LDLIBS+=-lgtest -lgtest_main
  90. ifeq ($(BUILD_ON),OS/390)
  91. LDLIBS+=-lzz
  92. endif
  93. ifeq ($(OPENPGP),SEQUOIA)
  94. LDLIBS+=-lsequoia_openpgp_ffi
  95. endif
  96. $(TARGET): $(OBJS)
  97. ${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ $(LDLIBS)
  98. test: all
  99. $(RM) -rf ./pEp_test_home/*
  100. $(TEST_CMD_PFX) $(TEST_DEBUGGER) GTEST_COLOR=no python3 $(GTEST_PL) \
  101. --gtest_color=no ./$(TARGET)
  102. clean:
  103. $(RM) $(TARGET) $(TARGET).o $(TARGET).d $(OBJS) \
  104. $(notdir $(basename $(OBJS))) $(DEPS)
  105. $(RM) -rf ./pEp_test_home/*
  106. # If only the target 'clean' is given, do not generate and include the
  107. # '%.d' files.¬
  108. ifneq ($(MAKECMDGOALS),clean)
  109. -include $(DEPS)
  110. endif