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 override.conf file.
51 # If empty, suppress compiler warnings.
52 # Otherwise, print warnings.
53 # This variable is ineffective in your override.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=c11 -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
173 ######### asn1c #########
177 # asn1c include search flag
179 #ASN1C_INC=-I$(HOME)/include
182 ######### libetpan #########
183 # libetpan library search flag
184 ETPAN_LIB=-L$(PREFIX)/lib
186 # libetpan include search flag
187 ETPAN_INC=-I$(PREFIX)/include
190 ######### sqlite3 #########
191 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
192 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
193 SQLITE3_FROM_OS=placeholder
196 ######### OpenPGP #########
198 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
200 # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
203 # Path of libGPGME binary
204 ifeq ($(BUILD_FOR),Linux)
205 LIBGPGME=libgpgme.so.11
206 else ifeq ($(BUILD_FOR),Darwin)
207 LIBGPGME=libgpgme.dylib
210 # libGPGME library search flag
211 ifeq ($(BUILD_FOR),Linux)
213 else ifeq ($(BUILD_FOR),Darwin)
214 GPGME_LIB=-L$(HOME)/lib
217 # libGPGME include search flag
218 ifeq ($(BUILD_FOR),Linux)
220 else ifeq ($(BUILD_FOR),Darwin)
221 GPGME_INC=-I$(HOME)/include
224 # NETPGP library search flag
226 #NETPGP_LIB=-L$(PREFIX)/lib
228 # libGPGME include search flag
230 #NETPGP_INC=-I$(PREFIX)/include
233 ######### Engine internals #########
234 # C macros (not environment variables) that can be overridden:
235 # DEFAULT_KEYSERVER - string with default keyserver
236 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
238 # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
242 ######### Misc #########
243 # FIXME Maybe include these variables here.
244 # Check how they are used throughout the project before setting them here
248 -include $(HERE)/local.conf
251 -include $(BUILD_CONFIG)