# Copyright 2017, pEp Foundation # This file is part of pEpEngine # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt # See `doc/build-.md` for documentation on how to build, and customize your build. # This file sets all the make variables that allow you to customize a build. # There are 4 ways in which you can customize your build: # 1) Edit the variable assignments in this file (this is a tracked file, so your repository will be dirty) # 2) Edit the variable assignments in `Makefile.conf` (which is a tracked file, so your repository will be dirty) # 3) Create `local.conf` and fill it with variable assignments. # 4) Set the environment variable `BUILD_CONFIG` to an absolute path. # The variable assignments found in the make file at the path indicated by `BUILD_CONFIG` will be evaluated. # Customization options are applied in the order given above. Later variable assignments take precedence over earlier ones. # It is possible to use multiple variants simultaniously. # If nothing is changed according to these 4 methods, a default configuration for your platform (specified below) will be used for the build. ######### Header ######### HERE:=$(dir $(lastword $(MAKEFILE_LIST))) ######### General ######### # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string. # All the *_INC and *_LIB variables are command line flags, not paths. # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L". BUILD_ON:=$(shell uname) # This variable specifies the platform that the engine should be cross-compiled for. BUILD_FOR=$(BUILD_ON) # Cross-compiling is currently not supported. # Maybe you can hack something with `local.conf`. ifneq ($(BUILD_ON),$(BUILD_FOR)) $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).) endif # Installation path prefix for libraries and binaries, except for system.db PREFIX=$(HOME) # Installation path for system.db SYSTEM_DB=/usr/local/share/pEp/system.db # Filename of the pEpEngine library ifeq ($(BUILD_FOR),Linux) TARGET=libpEpEngine.so else ifeq ($(BUILD_FOR),Darwin) TARGET=libpEpEngine.dylib endif # If empty, create a release build. # Otherwise, create a debug build. # This variable is ineffective in your local.conf file. DEBUG=placeholder # If empty, suppress compiler warnings. # Otherwise, print warnings. # This variable is ineffective in your local.conf file. WARN=placeholder ######### C and C++ ######### TARGET_ARCH= # The following two variables will be appended to. # You can thus not set them to a fixed value here. ifeq ($(BUILD_FOR),Linux) LDFLAGS= else ifeq ($(BUILD_FOR),Darwin) # "-bind_at_load" helps find symbol resolution errors faster LDFLAGS=-bind_at_load endif LDLIBS= ######### C ######### ifeq ($(BUILD_FOR),Linux) CC=gcc -std=c99 -pthread else ifeq ($(BUILD_FOR),Darwin) # clang issues a warning when "-pthread" is used for linking. # So, include it in CFLAGS, and not in CC CC=clang -std=c99 endif ifeq ($(BUILD_FOR),Linux) CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always else ifeq ($(BUILD_FOR),Darwin) CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics endif CPPFLAGS= # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests. # The tests do not work properly, if compiled with -DNDEBUG ifeq ($(BUILD_FOR),Linux) ifdef WARN CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3 else CFLAGS+= -w endif ifdef DEBUG CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK else CFLAGS+= -O3 -DNDEBUG endif else ifeq ($(BUILD_FOR),Darwin) ifdef WARN # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed. CFLAGS+= -Wall -pedantic -Wno-extended-offsetof else CFLAGS+= -w endif ifdef DEBUG CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK else CFLAGS+= -O3 -DNDEBUG endif endif # Additional CFLAGS used for compiling ASN1C-generated code ifeq ($(BUILD_FOR),Linux) # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning # _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE # otherwise printed during the compilation of every asn1c-generated C file. # It's a glibc specific warning, only present in few versions around ~2.19. # See https://lwn.net/Articles/590381/ for a discussion. CFLAGS_GENERATED=-D_DEFAULT_SOURCE else ifeq ($(BUILD_FOR),Darwin) CFLAGS_GENERATED= endif ######### C++ ######### ifeq ($(BUILD_FOR),Linux) CXX=g++ -std=gnu++11 -pthread else ifeq ($(BUILD_FOR),Darwin) # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX CXX=clang -std=c++11 endif # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests. # The tests do not work properly, if compiled with -DNDEBUG ifeq ($(BUILD_FOR),Linux) CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC) ifdef WARN CXXFLAGS+= else CXXFLAGS+= -w endif ifdef DEBUG CXXFLAGS+= -g -ggdb else CXXFLAGS+= -O3 -DNDEBUG endif else ifeq ($(BUILD_FOR),Darwin) CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC) ifdef WARN CXXFLAGS+= else CXXFLAGS+= -w endif ifdef DEBUG CXXFLAGS+= -O0 -g else CXXFLAGS+= -O3 -DNDEBUG endif endif ######### YML2 ######### YML2_PATH=$(HOME)/yml2 YML2_PROC=$(YML2_PATH)/yml2proc YML2_OPTS=--encoding=utf8 ######### asn1c ######### # asn1c binary ASN1C=asn1c # asn1c include search flag ASN1C_INC= #ASN1C_INC=-I$(HOME)/include ######### libetpan ######### # libetpan library search flag ETPAN_LIB=-L$(PREFIX)/lib # libetpan include search flag ETPAN_INC=-I$(PREFIX)/include ######### sqlite3 ######### # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution. # Otherwise, use an sqlite3 implementation found in the OS's include/library paths. SQLITE3_FROM_OS=placeholder ######### OpenPGP ######### # Path of GPG binary # 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. GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }') # Selects OpenPGP implementation. must be either `GPG` or `NETPGP` OPENPGP=GPG # Path of libGPGME binary ifeq ($(BUILD_FOR),Linux) LIBGPGME=libgpgme.so.11 else ifeq ($(BUILD_FOR),Darwin) LIBGPGME=libgpgme.11.dylib endif # libGPGME library search flag ifeq ($(BUILD_FOR),Linux) GPGME_LIB= else ifeq ($(BUILD_FOR),Darwin) GPGME_LIB=-L$(HOME)/lib endif # libGPGME include search flag ifeq ($(BUILD_FOR),Linux) GPGME_INC= else ifeq ($(BUILD_FOR),Darwin) GPGME_INC=-I$(HOME)/include endif # NETPGP library search flag NETPGP_LIB= #NETPGP_LIB=-L$(PREFIX)/lib # libGPGME include search flag NETPGP_INC= #NETPGP_INC=-I$(PREFIX)/include ######### OpenPGP ######### # CppUnit library search flag CPPUNIT_LIB= #CPPUNIT_LIB=-L$(HOME)/local/lib # CppUnit include search flag CPPUNIT_INC= #CPPUNIT_INC=-I$(HOME)/local/inc ######### Engine internals ######### # C macros (not environment variables) that can be overridden: # DEFAULT_KEYSERVER - string with default keyserver # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps # Example: # EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23 EXTRA_MACROS= ######### Misc ######### # FIXME Maybe include these variables here. # Check how they are used throughout the project before setting them here #LLDB_BIN ######### Footer ######### include $(HERE)/Makefile.conf -include $(HERE)/local.conf ifdef BUILD_CONFIG include $(BUILD_CONFIG) endif # YML_PATH is needed in the environment of every call to a program of the YML2 distribution export YML_PATH=$(YML2_PATH)