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.

276 lines
7.8 KiB

  1. # Copyright 2017, 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. # See `doc/build-<your platform>.md` for documentation on how to build, and customize your build.
  6. # This file sets all the make variables that allow you to customize a build.
  7. # There are 4 ways in which you can customize your build:
  8. # 1) Edit the variable assignments in this file (this is a tracked file, so your repository will be dirty)
  9. # 2) Edit the variable assignments in `Makefile.conf` (which is a tracked file, so your repository will be dirty)
  10. # 3) Create `local.conf` and fill it with variable assignments.
  11. # 4) Set the environment variable `BUILD_CONFIG` to an absolute path.
  12. # The variable assignments found in the make file at the path indicated by `BUILD_CONFIG` will be evaluated.
  13. # Customization options are applied in the order given above. Later variable assignments take precedence over earlier ones.
  14. # It is possible to use multiple variants simultaniously.
  15. # If nothing is changed according to these 4 methods, a default configuration for your platform (specified below) will be used for the build.
  16. ######### Header #########
  17. HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
  18. ######### General #########
  19. # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
  20. # All the *_INC and *_LIB variables are command line flags, not paths.
  21. # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
  22. BUILD_ON:=$(shell uname)
  23. # This variable specifies the platform that the engine should be cross-compiled for.
  24. BUILD_FOR=$(BUILD_ON)
  25. # Cross-compiling is currently not supported.
  26. # Maybe you can hack something with `local.conf`.
  27. ifneq ($(BUILD_ON),$(BUILD_FOR))
  28. $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
  29. endif
  30. # Installation path prefix for libraries and binaries, except for system.db
  31. PREFIX=$(HOME)
  32. # Installation path for system.db
  33. SYSTEM_DB=/usr/local/share/pEp/system.db
  34. # Filename of the pEpEngine library
  35. ifeq ($(BUILD_FOR),Linux)
  36. TARGET=libpEpEngine.so
  37. else ifeq ($(BUILD_FOR),Darwin)
  38. TARGET=libpEpEngine.dylib
  39. endif
  40. # If empty, create a release build.
  41. # Otherwise, create a debug build.
  42. # This variable is ineffective in your local.conf file.
  43. DEBUG=placeholder
  44. # If empty, suppress compiler warnings.
  45. # Otherwise, print warnings.
  46. # This variable is ineffective in your local.conf file.
  47. WARN=placeholder
  48. ######### C and C++ #########
  49. TARGET_ARCH=
  50. # The following two variables will be appended to.
  51. # You can thus not set them to a fixed value here.
  52. ifeq ($(BUILD_FOR),Linux)
  53. LDFLAGS=
  54. else ifeq ($(BUILD_FOR),Darwin)
  55. # "-bind_at_load" helps find symbol resolution errors faster
  56. LDFLAGS=-bind_at_load
  57. endif
  58. LDLIBS=
  59. ######### C #########
  60. ifeq ($(BUILD_FOR),Linux)
  61. CC=gcc -std=c99 -pthread
  62. else ifeq ($(BUILD_FOR),Darwin)
  63. # clang issues a warning when "-pthread" is used for linking.
  64. # So, include it in CFLAGS, and not in CC
  65. CC=clang -std=c99
  66. endif
  67. ifeq ($(BUILD_FOR),Linux)
  68. CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
  69. else ifeq ($(BUILD_FOR),Darwin)
  70. CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
  71. endif
  72. CPPFLAGS=
  73. # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
  74. # The tests do not work properly, if compiled with -DNDEBUG
  75. ifeq ($(BUILD_FOR),Linux)
  76. ifdef WARN
  77. CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
  78. else
  79. CFLAGS+= -w
  80. endif
  81. ifdef DEBUG
  82. CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
  83. else
  84. CFLAGS+= -O3 -DNDEBUG
  85. endif
  86. else ifeq ($(BUILD_FOR),Darwin)
  87. ifdef WARN
  88. # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
  89. CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
  90. else
  91. CFLAGS+= -w
  92. endif
  93. ifdef DEBUG
  94. CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
  95. else
  96. CFLAGS+= -O3 -DNDEBUG
  97. endif
  98. endif
  99. # Additional CFLAGS used for compiling ASN1C-generated code
  100. ifeq ($(BUILD_FOR),Linux)
  101. # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
  102. # _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
  103. # otherwise printed during the compilation of every asn1c-generated C file.
  104. # It's a glibc specific warning, only present in few versions around ~2.19.
  105. # See https://lwn.net/Articles/590381/ for a discussion.
  106. CFLAGS_GENERATED=-D_DEFAULT_SOURCE
  107. else ifeq ($(BUILD_FOR),Darwin)
  108. CFLAGS_GENERATED=
  109. endif
  110. ######### C++ #########
  111. ifeq ($(BUILD_FOR),Linux)
  112. CXX=g++ -std=gnu++11 -pthread
  113. else ifeq ($(BUILD_FOR),Darwin)
  114. # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
  115. CXX=clang -std=c++11
  116. endif
  117. # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
  118. # The tests do not work properly, if compiled with -DNDEBUG
  119. ifeq ($(BUILD_FOR),Linux)
  120. CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
  121. ifdef WARN
  122. CXXFLAGS+=
  123. else
  124. CXXFLAGS+= -w
  125. endif
  126. ifdef DEBUG
  127. CXXFLAGS+= -g -ggdb
  128. else
  129. CXXFLAGS+= -O3 -DNDEBUG
  130. endif
  131. else ifeq ($(BUILD_FOR),Darwin)
  132. CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
  133. ifdef WARN
  134. CXXFLAGS+=
  135. else
  136. CXXFLAGS+= -w
  137. endif
  138. ifdef DEBUG
  139. CXXFLAGS+= -O0 -g
  140. else
  141. CXXFLAGS+= -O3 -DNDEBUG
  142. endif
  143. endif
  144. ######### YML2 #########
  145. YML2_PATH=$(HOME)/yml2
  146. YML2_PROC=$(YML2_PATH)/yml2proc
  147. YML2_OPTS=--encoding=utf8
  148. ######### asn1c #########
  149. # asn1c binary
  150. ASN1C=asn1c
  151. # asn1c include search flag
  152. ASN1C_INC=
  153. #ASN1C_INC=-I$(HOME)/include
  154. ######### libetpan #########
  155. # libetpan library search flag
  156. ETPAN_LIB=-L$(PREFIX)/lib
  157. # libetpan include search flag
  158. ETPAN_INC=-I$(PREFIX)/include
  159. ######### sqlite3 #########
  160. # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
  161. # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
  162. SQLITE3_FROM_OS=placeholder
  163. ######### OpenPGP #########
  164. # Path of GPG binary
  165. # gpgconf is not available for old version of GPG, for example GPG 2.0.30. Override this variable, if you compile the engine for such an old version.
  166. GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
  167. # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
  168. OPENPGP=GPG
  169. # Path of libGPGME binary
  170. ifeq ($(BUILD_FOR),Linux)
  171. LIBGPGME=libgpgme.so.11
  172. else ifeq ($(BUILD_FOR),Darwin)
  173. LIBGPGME=libgpgme.11.dylib
  174. endif
  175. # libGPGME library search flag
  176. ifeq ($(BUILD_FOR),Linux)
  177. GPGME_LIB=
  178. else ifeq ($(BUILD_FOR),Darwin)
  179. GPGME_LIB=-L$(HOME)/lib
  180. endif
  181. # libGPGME include search flag
  182. ifeq ($(BUILD_FOR),Linux)
  183. GPGME_INC=
  184. else ifeq ($(BUILD_FOR),Darwin)
  185. GPGME_INC=-I$(HOME)/include
  186. endif
  187. # NETPGP library search flag
  188. NETPGP_LIB=
  189. #NETPGP_LIB=-L$(PREFIX)/lib
  190. # libGPGME include search flag
  191. NETPGP_INC=
  192. #NETPGP_INC=-I$(PREFIX)/include
  193. ######### OpenPGP #########
  194. # CppUnit library search flag
  195. CPPUNIT_LIB=
  196. #CPPUNIT_LIB=-L$(HOME)/local/lib
  197. # CppUnit include search flag
  198. CPPUNIT_INC=
  199. #CPPUNIT_INC=-I$(HOME)/local/inc
  200. ######### Engine internals #########
  201. # C macros (not environment variables) that can be overridden:
  202. # DEFAULT_KEYSERVER - string with default keyserver
  203. # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
  204. # Example:
  205. # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
  206. EXTRA_MACROS=
  207. ######### Misc #########
  208. # FIXME Maybe include these variables here.
  209. # Check how they are used throughout the project before setting them here
  210. #LLDB_BIN
  211. ######### Footer #########
  212. include $(HERE)/Makefile.conf
  213. -include $(HERE)/local.conf
  214. ifdef BUILD_CONFIG
  215. include $(BUILD_CONFIG)
  216. endif
  217. # YML_PATH is needed in the environment of every call to a program of the YML2 distribution
  218. export YML_PATH=$(YML2_PATH)