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)))
20 ######### General #########
21 # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
22 # All the *_INC and *_LIB variables are command line flags, not paths.
23 # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
25 BUILD_ON:=$(shell uname)
27 # This variable specifies the platform that the engine should be cross-compiled for.
30 # Cross-compiling is currently not supported.
31 # Maybe you can hack something with `local.conf`.
32 ifneq ($(BUILD_ON),$(BUILD_FOR))
33 $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
36 # Installation path prefix for libraries and binaries, except for system.db
39 # Installation path for system.db
40 SYSTEM_DB=/usr/local/share/pEp/system.db
42 # Filename of the pEpEngine library
43 ifeq ($(BUILD_FOR),Linux)
44 TARGET=libpEpEngine.so
45 else ifeq ($(BUILD_FOR),Darwin)
46 TARGET=libpEpEngine.dylib
49 # If empty, create a release build.
50 # Otherwise, create a debug build.
51 # This variable is ineffective in your local.conf file.
54 # If empty, suppress compiler warnings.
55 # Otherwise, print warnings.
56 # This variable is ineffective in your local.conf file.
60 ######### C and C++ #########
62 # The following two variables will be appended to.
63 # You can thus not set them to a fixed value here.
64 ifeq ($(BUILD_FOR),Linux)
66 else ifeq ($(BUILD_FOR),Darwin)
67 # "-bind_at_load" helps find symbol resolution errors faster
75 ifeq ($(BUILD_FOR),Linux)
76 CC=gcc -std=c99 -pthread
77 else ifeq ($(BUILD_FOR),Darwin)
78 # clang issues a warning when "-pthread" is used for linking.
79 # So, include it in CFLAGS, and not in CC
83 ifeq ($(BUILD_FOR),Linux)
84 CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
85 else ifeq ($(BUILD_FOR),Darwin)
86 CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
91 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
92 # The tests do not work properly, if compiled with -DNDEBUG
93 ifeq ($(BUILD_FOR),Linux)
95 CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
100 CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
102 CFLAGS+= -O3 -DNDEBUG
104 else ifeq ($(BUILD_FOR),Darwin)
106 # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
107 CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
112 CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
114 CFLAGS+= -O3 -DNDEBUG
118 # Additional CFLAGS used for compiling ASN1C-generated code
119 ifeq ($(BUILD_FOR),Linux)
120 # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
121 # _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
122 # otherwise printed during the compilation of every asn1c-generated C file.
123 # It's a glibc specific warning, only present in few versions around ~2.19.
124 # See https://lwn.net/Articles/590381/ for a discussion.
125 CFLAGS_GENERATED=-D_DEFAULT_SOURCE
126 else ifeq ($(BUILD_FOR),Darwin)
131 ######### C++ #########
132 ifeq ($(BUILD_FOR),Linux)
133 CXX=g++ -std=gnu++11 -pthread
134 else ifeq ($(BUILD_FOR),Darwin)
135 # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
139 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
140 # The tests do not work properly, if compiled with -DNDEBUG
141 ifeq ($(BUILD_FOR),Linux)
142 CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
151 CXXFLAGS+= -O3 -DNDEBUG
153 else ifeq ($(BUILD_FOR),Darwin)
154 CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
163 CXXFLAGS+= -O3 -DNDEBUG
168 ######### YML2 #########
169 YML2_PATH=$(HOME)/yml2
171 YML2_PROC=$(YML2_PATH)/yml2proc
173 YML2_OPTS=--encoding=utf8
176 ######### asn1c #########
180 # asn1c include search flag
182 #ASN1C_INC=-I$(HOME)/include
185 ######### libetpan #########
186 # libetpan library search flag
187 ETPAN_LIB=-L$(PREFIX)/lib
189 # libetpan include search flag
190 ETPAN_INC=-I$(PREFIX)/include
193 ######### sqlite3 #########
194 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
195 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
196 SQLITE3_FROM_OS=placeholder
199 ######### OpenPGP #########
201 # 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.
202 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
204 # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
207 # Path of libGPGME binary
208 ifeq ($(BUILD_FOR),Linux)
209 LIBGPGME=libgpgme.so.11
210 else ifeq ($(BUILD_FOR),Darwin)
211 LIBGPGME=libgpgme.dylib
214 # libGPGME library search flag
215 ifeq ($(BUILD_FOR),Linux)
217 else ifeq ($(BUILD_FOR),Darwin)
218 GPGME_LIB=-L$(HOME)/lib
221 # libGPGME include search flag
222 ifeq ($(BUILD_FOR),Linux)
224 else ifeq ($(BUILD_FOR),Darwin)
225 GPGME_INC=-I$(HOME)/include
228 # NETPGP library search flag
230 #NETPGP_LIB=-L$(PREFIX)/lib
232 # libGPGME include search flag
234 #NETPGP_INC=-I$(PREFIX)/include
237 ######### Engine internals #########
238 # C macros (not environment variables) that can be overridden:
239 # DEFAULT_KEYSERVER - string with default keyserver
240 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
242 # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
246 ######### Misc #########
247 # FIXME Maybe include these variables here.
248 # Check how they are used throughout the project before setting them here
252 ######### Footer #########
253 include $(HERE)/Makefile.conf
255 -include $(HERE)/local.conf
258 include $(BUILD_CONFIG)
261 # YML_PATH is needed in the environment of every call to a program of the YML2 distribution
262 export YML_PATH=$(YML2_PATH)