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 gives an overview over all the parameters that can be easily customized for a build.
7 # There are three ways in which you can customize your build:
8 # 1) Edit the variable assignments in this file
9 # 2) Create `local.conf` and fill it with variable assignments.
10 # These `local.conf` takes precedence over the assignments below.
11 # 3) Set the environment variable `BUILD_CONFIG` to an absolute path.
12 # The variable assignments found at the path indicated by `BUILD_CONFIG` take precedence over the assignments below and the assignments in `local.conf`.
13 # If nothing is changed according to these 3 methods, a default configuration for your platform will be used for the build.
15 HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
17 ######### General #########
18 # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
19 # All the *_INC and *_LIB variables are command line flags, not paths.
20 # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
22 BUILD_ON:=$(shell uname)
24 # This variable specifies the platform that the engine should be cross-compiled for.
27 # Cross-compiling is currently not supported.
28 # Maybe you can hack something with `local.conf`.
29 ifneq ($(BUILD_ON),$(BUILD_FOR))
30 $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
33 # Installation path prefix for libraries and binaries, except for system.db
36 # Installation path for system.db
37 SYSTEM_DB=/usr/local/share/pEp/system.db
39 # Filename of the pEpEngine library
40 ifeq ($(BUILD_FOR),Linux)
41 TARGET=libpEpEngine.so
42 else ifeq ($(BUILD_FOR),Darwin)
43 TARGET=libpEpEngine.dylib
46 # If empty, create a release build.
47 # Otherwise, create a debug build.
48 # This variable is ineffective in your local.conf file.
51 # If empty, suppress compiler warnings.
52 # Otherwise, print warnings.
53 # This variable is ineffective in your local.conf file.
57 ######### C and C++ #########
59 # The following two variables will be appended to.
60 # You can thus not set them to a fixed value here.
61 ifeq ($(BUILD_FOR),Linux)
63 else ifeq ($(BUILD_FOR),Darwin)
64 # "-bind_at_load" helps find symbol resolution errors faster
72 ifeq ($(BUILD_FOR),Linux)
73 CC=gcc -std=c99 -pthread
74 else ifeq ($(BUILD_FOR),Darwin)
75 # clang issues a warning when "-pthread" is used for linking.
76 # So, include it in CFLAGS, and not in CC
80 ifeq ($(BUILD_FOR),Linux)
81 CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
82 else ifeq ($(BUILD_FOR),Darwin)
83 CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
88 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
89 # The tests do not work properly, if compiled with -DNDEBUG
90 ifeq ($(BUILD_FOR),Linux)
92 CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
97 CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
101 else ifeq ($(BUILD_FOR),Darwin)
103 # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
104 CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
109 CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
111 CFLAGS+= -O3 -DNDEBUG
115 # Additional CFLAGS used for compiling ASN1C-generated code
116 ifeq ($(BUILD_FOR),Linux)
117 # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
118 # _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
119 # otherwise printed during the compilation of every asn1c-generated C file.
120 # It's a glibc specific warning, only present in few versions around ~2.19.
121 # See https://lwn.net/Articles/590381/ for a discussion.
122 CFLAGS_GENERATED=-D_DEFAULT_SOURCE
123 else ifeq ($(BUILD_FOR),Darwin)
128 ######### C++ #########
129 ifeq ($(BUILD_FOR),Linux)
130 CXX=g++ -std=gnu++11 -pthread
131 else ifeq ($(BUILD_FOR),Darwin)
132 # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
136 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
137 # The tests do not work properly, if compiled with -DNDEBUG
138 ifeq ($(BUILD_FOR),Linux)
139 CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
148 CXXFLAGS+= -O3 -DNDEBUG
150 else ifeq ($(BUILD_FOR),Darwin)
151 CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
160 CXXFLAGS+= -O3 -DNDEBUG
165 ######### YML2 #########
166 YML2_PATH=$(HOME)/yml2
168 YML2_PROC=$(YML2_PATH)/yml2proc
170 YML2_OPTS=--encoding=utf8
172 export YML_PATH=$(YML2_PATH)
174 ######### asn1c #########
178 # asn1c include search flag
180 #ASN1C_INC=-I$(HOME)/include
183 ######### libetpan #########
184 # libetpan library search flag
185 ETPAN_LIB=-L$(PREFIX)/lib
187 # libetpan include search flag
188 ETPAN_INC=-I$(PREFIX)/include
191 ######### sqlite3 #########
192 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
193 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
194 SQLITE3_FROM_OS=placeholder
197 ######### OpenPGP #########
199 # 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.
200 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
202 # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
205 # Path of libGPGME binary
206 ifeq ($(BUILD_FOR),Linux)
207 LIBGPGME=libgpgme.so.11
208 else ifeq ($(BUILD_FOR),Darwin)
209 LIBGPGME=libgpgme.dylib
212 # libGPGME library search flag
213 ifeq ($(BUILD_FOR),Linux)
215 else ifeq ($(BUILD_FOR),Darwin)
216 GPGME_LIB=-L$(HOME)/lib
219 # libGPGME include search flag
220 ifeq ($(BUILD_FOR),Linux)
222 else ifeq ($(BUILD_FOR),Darwin)
223 GPGME_INC=-I$(HOME)/include
226 # NETPGP library search flag
228 #NETPGP_LIB=-L$(PREFIX)/lib
230 # libGPGME include search flag
232 #NETPGP_INC=-I$(PREFIX)/include
235 ######### Engine internals #########
236 # C macros (not environment variables) that can be overridden:
237 # DEFAULT_KEYSERVER - string with default keyserver
238 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
240 # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
244 ######### Misc #########
245 # FIXME Maybe include these variables here.
246 # Check how they are used throughout the project before setting them here
250 -include $(HERE)/local.conf
253 -include $(BUILD_CONFIG)