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
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.
18 ######### Header #########
19 HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
22 ######### General #########
23 # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
24 # All the *_INC and *_LIB variables are command line flags, not paths.
25 # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
27 BUILD_ON:=$(shell uname)
29 # This variable specifies the platform that the engine should be cross-compiled for.
32 # Cross-compiling is currently not supported.
33 # Maybe you can hack something with `local.conf`.
34 ifneq ($(BUILD_ON),$(BUILD_FOR))
35 $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
38 # Installation path prefix for libraries and binaries, except for system.db
41 # Installation path for system.db
42 SYSTEM_DB=/usr/local/share/pEp/system.db
44 # Filename of the pEpEngine library
45 ifeq ($(BUILD_FOR),Linux)
46 TARGET=libpEpEngine.so
47 else ifeq ($(BUILD_FOR),Darwin)
48 TARGET=libpEpEngine.dylib
51 # If empty, create a release build.
52 # Otherwise, create a debug build.
53 # This variable is ineffective in your local.conf file.
56 # If empty, suppress compiler warnings.
57 # Otherwise, print warnings.
58 # This variable is ineffective in your local.conf file.
62 ######### C and C++ #########
64 # The following two variables will be appended to.
65 # You can thus not set them to a fixed value here.
66 ifeq ($(BUILD_FOR),Linux)
68 else ifeq ($(BUILD_FOR),Darwin)
69 # "-bind_at_load" helps find symbol resolution errors faster
77 ifeq ($(BUILD_FOR),Linux)
78 CC=gcc -std=c99 -pthread
79 else ifeq ($(BUILD_FOR),Darwin)
80 # clang issues a warning when "-pthread" is used for linking.
81 # So, include it in CFLAGS, and not in CC
85 ifeq ($(BUILD_FOR),Linux)
86 CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
87 else ifeq ($(BUILD_FOR),Darwin)
88 CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
93 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
94 # The tests do not work properly, if compiled with -DNDEBUG
95 ifeq ($(BUILD_FOR),Linux)
97 CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
102 CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
104 CFLAGS+= -O3 -DNDEBUG
106 else ifeq ($(BUILD_FOR),Darwin)
108 # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
109 CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
114 CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
116 CFLAGS+= -O3 -DNDEBUG
120 # Additional CFLAGS used for compiling ASN1C-generated code
121 ifeq ($(BUILD_FOR),Linux)
122 # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
123 # _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
124 # otherwise printed during the compilation of every asn1c-generated C file.
125 # It's a glibc specific warning, only present in few versions around ~2.19.
126 # See https://lwn.net/Articles/590381/ for a discussion.
127 CFLAGS_GENERATED=-D_DEFAULT_SOURCE
128 else ifeq ($(BUILD_FOR),Darwin)
133 ######### C++ #########
134 ifeq ($(BUILD_FOR),Linux)
135 CXX=g++ -std=gnu++11 -pthread
136 else ifeq ($(BUILD_FOR),Darwin)
137 # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
141 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
142 # The tests do not work properly, if compiled with -DNDEBUG
143 ifeq ($(BUILD_FOR),Linux)
144 CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
153 CXXFLAGS+= -O3 -DNDEBUG
155 else ifeq ($(BUILD_FOR),Darwin)
156 CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
165 CXXFLAGS+= -O3 -DNDEBUG
170 ######### YML2 #########
171 YML2_PATH=$(HOME)/yml2
173 YML2_PROC=$(YML2_PATH)/yml2proc
175 YML2_OPTS=--encoding=utf8
178 ######### asn1c #########
182 # asn1c include search flag
184 #ASN1C_INC=-I$(HOME)/include
187 ######### libetpan #########
188 # libetpan library search flag
189 ETPAN_LIB=-L$(PREFIX)/lib
191 # libetpan include search flag
192 ETPAN_INC=-I$(PREFIX)/include
195 ######### sqlite3 #########
196 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
197 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
198 SQLITE3_FROM_OS=placeholder
201 ######### OpenPGP #########
203 # 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.
204 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
206 # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
209 # Path of libGPGME binary
210 ifeq ($(BUILD_FOR),Linux)
211 LIBGPGME=libgpgme.so.11
212 else ifeq ($(BUILD_FOR),Darwin)
213 LIBGPGME=libgpgme.dylib
216 # libGPGME library search flag
217 ifeq ($(BUILD_FOR),Linux)
219 else ifeq ($(BUILD_FOR),Darwin)
220 GPGME_LIB=-L$(HOME)/lib
223 # libGPGME include search flag
224 ifeq ($(BUILD_FOR),Linux)
226 else ifeq ($(BUILD_FOR),Darwin)
227 GPGME_INC=-I$(HOME)/include
230 # NETPGP library search flag
232 #NETPGP_LIB=-L$(PREFIX)/lib
234 # libGPGME include search flag
236 #NETPGP_INC=-I$(PREFIX)/include
239 ######### Engine internals #########
240 # C macros (not environment variables) that can be overridden:
241 # DEFAULT_KEYSERVER - string with default keyserver
242 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
244 # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
248 ######### Misc #########
249 # FIXME Maybe include these variables here.
250 # Check how they are used throughout the project before setting them here
254 ######### Footer #########
255 include $(HERE)/Makefile.conf
257 -include $(HERE)/local.conf
260 include $(BUILD_CONFIG)
263 # YML_PATH is needed in the environment of every call to a program of the YML2 distribution
264 export YML_PATH=$(YML2_PATH)