p≡p JSON adapter
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.

149 lines
4.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
4 years ago
4 years ago
  1. # Copyright 2017 pEp Security SA
  2. #
  3. # This file is part of pEp JSON Server Adapter.
  4. #
  5. # pEp JSON Server Adapter is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation.
  6. #
  7. # pEp JSON Server Adapter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  8. #
  9. # You should have received a copy of the GNU General Public License along with pEp JSON Server Adapter. If not, see <http://www.gnu.org/licenses/>.
  10. include Makefile.conf
  11. ifneq ($(wildcard local.conf),)
  12. $(info ================================================)
  13. $(info Overrides in \`local.conf\` are used.)
  14. $(info ================================================)
  15. endif
  16. ifdef BUILD_CONFIG
  17. $(info ================================================)
  18. $(info Overrides in \`$(BUILD_CONFIG)\` are used.)
  19. $(info ================================================)
  20. endif
  21. NO_SOURCE=main.cc servertest.cc unittest_json.cc
  22. ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard json_spirit/*.cpp))
  23. ALL_SOURCE+= prefix-config.cc
  24. ALL_SOURCE+= $(filter-out $(NO_SOURCE),$(wildcard *.cc))
  25. DEPENDS0=$(subst .cpp,.d,$(ALL_SOURCE))
  26. DEPENDS=$(subst .cc,.d,$(DEPENDS0))
  27. ALL_OBJECTS0=$(subst .cpp,.o,$(ALL_SOURCE))
  28. ALL_OBJECTS=$(subst .cc,.o,$(ALL_OBJECTS0))
  29. ifeq ($(BUILD_FOR),Linux)
  30. LIBPATH=LD_LIBRARY_PATH
  31. else
  32. LIBPATH=DYLD_LIBRARY_PATH
  33. endif
  34. ifeq ($(BUILD_FOR),Linux)
  35. LD_EAGER_VAR=LD_BIND_NOW=placeholder
  36. else
  37. LD_EAGER_VAR=DYLD_BIND_AT_LAUNCH=placeholder
  38. endif
  39. # Create a list of the extra library paths for the loader.
  40. # Note that += can not be used here, as it changes the amount of whitespace
  41. EXTRA_LIB_PATHS=$(PREFIX)/lib:
  42. ifdef BOOST_LIB
  43. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(BOOST_LIB)):
  44. endif
  45. ifdef ENGINE_LIB
  46. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ENGINE_LIB)):
  47. endif
  48. ifdef ETPAN_LIB
  49. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
  50. endif
  51. ifdef EVENT_LIB
  52. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(EVENT_LIB)):
  53. endif
  54. ifdef GPGME_LIB
  55. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
  56. endif
  57. ifdef UUID_LIB
  58. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(UUID_LIB)):
  59. endif
  60. # Remove trailing ':'
  61. EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
  62. CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
  63. ifdef DEBUG
  64. CMD_PFX+= $(LD_EAGER_VAR)
  65. endif
  66. .PHONY: all
  67. all: $(TARGET) $(TARGET_TEST) $(TARGET_GTEST)
  68. $(TARGET): main.o libjson-adapter.a
  69. $(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
  70. $(TARGET)-static: main.o libjson-adapter.a
  71. $(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -static -o $@
  72. $(TARGET_TEST): servertest.o libjson-adapter.a
  73. $(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
  74. $(TARGET_GTEST): unittest_json.o gtest-all.o gtest_main.o libjson-adapter.a
  75. $(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
  76. libjson-adapter.a: $(ALL_OBJECTS)
  77. ar rcs $@ $^
  78. prefix-config.cc:
  79. echo '// This file is generated by make. Edit the Makefile, not this file!\n#include "prefix-config.hh" \nconst char* const html_directory = "'$(HTML_DIRECTORY)'";\n' > $@
  80. gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc
  81. $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -o $@ -c $<
  82. gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc
  83. $(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -o $@ -c $<
  84. %.o: %.cc %.hh
  85. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<
  86. %.d: %.cpp
  87. @set -e; rm -f $@; \
  88. $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
  89. sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
  90. rm -f $@.$$$$
  91. %.d: %.cc
  92. @set -e; rm -f $@; \
  93. $(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
  94. sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
  95. rm -f $@.$$$$
  96. # If only the goal 'clean' is given, do not generate and include the '%.d' files.
  97. ifneq ($(MAKECMDGOALS),clean)
  98. -include $(DEPENDS)
  99. endif
  100. .PHONY: install
  101. install: all
  102. mkdir -v -p $(PREFIX)/bin $(PREFIX)/lib
  103. mkdir -v -p $(HTML_DIRECTORY)
  104. cp -v ../html/* $(HTML_DIRECTORY)
  105. cp -v libjson-adapter.a $(PREFIX)/lib
  106. cp -v pep-json-server servertest $(PREFIX)/bin
  107. .PHONY: clean
  108. clean:
  109. rm -vf pep-json-server servertest
  110. rm -vf *.o json_spirit/*.o
  111. rm -vf *.a json_spirit/*.a
  112. rm -vf *.d json_spirit/*.d
  113. rm -vf prefix-config.cc
  114. .PHONY: run
  115. run: | install
  116. @echo "The adapter must be installed for $< to work"
  117. $(CMD_PFX) "$(PREFIX)/bin/$(TARGET)"
  118. .PHONY: test
  119. test: | install
  120. @echo "The adapter must be installed for $< to work"
  121. $(CMD_PFX) "$(PREFIX)/bin/$(TARGET_TEST)"
  122. $(CMD_PFX) "$(PREFIX)/bin/$(TARGET_GTEST)"