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.
16 ######### Header #########
17 HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
19 ######### General #########
20 # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
21 # All the *_INC and *_LIB variables are command line flags, not paths.
22 # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
24 BUILD_ON:=$(shell uname)
26 # This variable specifies the platform that the engine should be cross-compiled for.
29 # Cross-compiling is currently not supported.
30 # Maybe you can hack something with `local.conf`.
31 ifneq ($(BUILD_ON),$(BUILD_FOR))
32 $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
35 # Installation path prefix for libraries and binaries, except for system.db
38 # Installation path for system.db
39 SYSTEM_DB=/usr/local/share/pEp/system.db
41 # Filename of the pEpEngine library
42 ifeq ($(BUILD_FOR),Linux)
43 TARGET=libpEpEngine.so
44 else ifeq ($(BUILD_FOR),Darwin)
45 TARGET=libpEpEngine.dylib
48 # If empty, create a release build.
49 # Otherwise, create a debug build.
50 # This variable is ineffective in your local.conf file.
53 # If empty, suppress compiler warnings.
54 # Otherwise, print warnings.
55 # This variable is ineffective in your local.conf file.
59 ######### C and C++ #########
61 # The following two variables will be appended to.
62 # You can thus not set them to a fixed value here.
63 ifeq ($(BUILD_FOR),Linux)
65 else ifeq ($(BUILD_FOR),Darwin)
66 # "-bind_at_load" helps find symbol resolution errors faster
74 ifeq ($(BUILD_FOR),Linux)
75 CC=gcc -std=c99 -pthread
76 else ifeq ($(BUILD_FOR),Darwin)
77 # clang issues a warning when "-pthread" is used for linking.
78 # So, include it in CFLAGS, and not in CC
82 ifeq ($(BUILD_FOR),Linux)
83 CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
84 else ifeq ($(BUILD_FOR),Darwin)
85 CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
90 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
91 # The tests do not work properly, if compiled with -DNDEBUG
92 ifeq ($(BUILD_FOR),Linux)
94 CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
99 CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
101 CFLAGS+= -O3 -DNDEBUG
103 else ifeq ($(BUILD_FOR),Darwin)
105 # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
106 CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
111 CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
113 CFLAGS+= -O3 -DNDEBUG
117 # Additional CFLAGS used for compiling ASN1C-generated code
118 ifeq ($(BUILD_FOR),Linux)
119 # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
120 # _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
121 # otherwise printed during the compilation of every asn1c-generated C file.
122 # It's a glibc specific warning, only present in few versions around ~2.19.
123 # See https://lwn.net/Articles/590381/ for a discussion.
124 CFLAGS_GENERATED=-D_DEFAULT_SOURCE
125 else ifeq ($(BUILD_FOR),Darwin)
130 ######### C++ #########
131 ifeq ($(BUILD_FOR),Linux)
132 CXX=g++ -std=gnu++11 -pthread
133 else ifeq ($(BUILD_FOR),Darwin)
134 # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
138 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
139 # The tests do not work properly, if compiled with -DNDEBUG
140 ifeq ($(BUILD_FOR),Linux)
141 CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
150 CXXFLAGS+= -O3 -DNDEBUG
152 else ifeq ($(BUILD_FOR),Darwin)
153 CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
162 CXXFLAGS+= -O3 -DNDEBUG
167 ######### YML2 #########
168 YML2_PATH=$(HOME)/yml2
170 YML2_PROC=$(YML2_PATH)/yml2proc
172 YML2_OPTS=--encoding=utf8
174 # YML_PATH is needed in the environment of every call to a program of the YML2 distribution
175 export YML_PATH=$(YML2_PATH)
177 ######### asn1c #########
181 # asn1c include search flag
183 #ASN1C_INC=-I$(HOME)/include
186 ######### libetpan #########
187 # libetpan library search flag
188 ETPAN_LIB=-L$(PREFIX)/lib
190 # libetpan include search flag
191 ETPAN_INC=-I$(PREFIX)/include
194 ######### sqlite3 #########
195 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
196 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
197 SQLITE3_FROM_OS=placeholder
200 ######### OpenPGP #########
202 # 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.
203 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
205 # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
208 # Path of libGPGME binary
209 ifeq ($(BUILD_FOR),Linux)
210 LIBGPGME=libgpgme.so.11
211 else ifeq ($(BUILD_FOR),Darwin)
212 LIBGPGME=libgpgme.dylib
215 # libGPGME library search flag
216 ifeq ($(BUILD_FOR),Linux)
218 else ifeq ($(BUILD_FOR),Darwin)
219 GPGME_LIB=-L$(HOME)/lib
222 # libGPGME include search flag
223 ifeq ($(BUILD_FOR),Linux)
225 else ifeq ($(BUILD_FOR),Darwin)
226 GPGME_INC=-I$(HOME)/include
229 # NETPGP library search flag
231 #NETPGP_LIB=-L$(PREFIX)/lib
233 # libGPGME include search flag
235 #NETPGP_INC=-I$(PREFIX)/include
238 ######### Engine internals #########
239 # C macros (not environment variables) that can be overridden:
240 # DEFAULT_KEYSERVER - string with default keyserver
241 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
243 # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
247 ######### Misc #########
248 # FIXME Maybe include these variables here.
249 # Check how they are used throughout the project before setting them here
253 ######### Footer #########
254 include $(HERE)/Makefile.conf
256 -include $(HERE)/local.conf
259 include $(BUILD_CONFIG)