Move all build configuration into Makefile.conf ENGINE-261
authorDamiano Boppart <damiano@pep-security.net>
Wed, 20 Sep 2017 17:53:25 +0200
branchENGINE-261
changeset 20811593ebbb7f31
parent 2080 530051a7d3ea
child 2082 253f13cdf056
child 2083 361a6dc2c075
Move all build configuration into Makefile.conf
Makefile.conf
build-config/Darwin.conf
build-config/Linux.conf
build-config/common.conf
     1.1 --- a/Makefile.conf	Wed Sep 20 11:57:26 2017 +0200
     1.2 +++ b/Makefile.conf	Wed Sep 20 17:53:25 2017 +0200
     1.3 @@ -3,22 +3,237 @@
     1.4  # This file may be used under the terms of the GNU General Public License version 3
     1.5  # see LICENSE.txt
     1.6  
     1.7 -# This file assembles all the make variables that a maintainer or dev may want to adapt for a distribution.
     1.8 +# This file gives an overview over all the parameters that can be easily customized for a build.
     1.9 +# If you want to customized the build configuration without making the working copy unclean, create an addional makefile at `local.conf`.
    1.10 +# `local.conf` will be included at the end of this file, and thus allows overriding any of the variables here.
    1.11 +# If nothing is changed here (or in `local.conf`) a default configuration for your platform will be used.
    1.12  
    1.13 -# To use custom build configuration variables, put them in a new file with the path `build-config/<name>.conf`.
    1.14 -# Execute `export PLATFORM_OVERRIDE=<name>` before running make.
    1.15 -# If this environment variable is not set, make will load a default configuration for your platform.
    1.16 +HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
    1.17  
    1.18 -BUILD_CONFIG:=$(dir $(lastword $(MAKEFILE_LIST)))build-config
    1.19 +######### General #########
    1.20 +# To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
    1.21 +# All the *_INC and *_LIB variables are command line flags, not paths.
    1.22 +# Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
    1.23  
    1.24 -include $(BUILD_CONFIG)/common.conf
    1.25 +BUILD_ON:=$(shell uname)
    1.26 +
    1.27 +# This variable specifies the platform that the engine should be cross-compiled for.
    1.28 +BUILD_FOR=$(BUILD_ON)
    1.29 +
    1.30  # Cross-compiling is currently not supported.
    1.31 -# Maybe you can hack something with `PLATFORM_OVERRIDE`
    1.32 -ifeq ($(BUILD_ON),$(BUILD_FOR))
    1.33 -    include $(BUILD_CONFIG)/$(BUILD_ON).conf
    1.34 -else
    1.35 -    $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON))
    1.36 +# Maybe you can hack something with `local.conf`.
    1.37 +ifneq ($(BUILD_ON),$(BUILD_FOR))
    1.38 +    $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
    1.39  endif
    1.40 -ifdef PLATFORM_OVERRIDE
    1.41 -    include $(BUILD_CONFIG)/$(PLATFORM_OVERRIDE).conf
    1.42 +
    1.43 +# Installation path prefix for libraries and binaries, except for system.db
    1.44 +PREFIX=$(HOME)
    1.45 +
    1.46 +# Installation path for system.db
    1.47 +SYSTEM_DB=/usr/local/share/pEp/system.db
    1.48 +
    1.49 +# Filename of the pEpEngine library
    1.50 +ifeq ($(BUILD_FOR),Linux)
    1.51 +    TARGET=libpEpEngine.so
    1.52 +else ifeq ($(BUILD_FOR),Darwin)
    1.53 +    TARGET=libpEpEngine.dylib
    1.54  endif
    1.55 +
    1.56 +# If empty, create a release build.
    1.57 +# Otherwise, create a debug build.
    1.58 +# This variable is ineffective in your override.conf file.
    1.59 +DEBUG=
    1.60 +
    1.61 +# If empty, suppress compiler warnings.
    1.62 +# Otherwise, print warnings.
    1.63 +# This variable is ineffective in your override.conf file.
    1.64 +WARN=placeholder
    1.65 +
    1.66 +
    1.67 +######### C and C++ #########
    1.68 +TARGET_ARCH=
    1.69 +# The following two variables will be appended to.
    1.70 +# You can thus not set them to a fixed value here.
    1.71 +ifeq ($(BUILD_FOR),Linux)
    1.72 +    LDFLAGS=
    1.73 +else ifeq ($(BUILD_FOR),Darwin)
    1.74 +    # "-bind_at_load" helps find symbol resolution errors faster
    1.75 +    LDFLAGS=-bind_at_load
    1.76 +endif
    1.77 +
    1.78 +LDLIBS=
    1.79 +
    1.80 +
    1.81 +######### C #########
    1.82 +ifeq ($(BUILD_FOR),Linux)
    1.83 +    CC=gcc -std=c99 -pthread
    1.84 +else ifeq ($(BUILD_FOR),Darwin)
    1.85 +    # clang issues a warning when "-pthread" is used for linking. So, include it in CFLAGS, and not in CC
    1.86 +    CC=clang -std=c99
    1.87 +endif
    1.88 +
    1.89 +ifeq ($(BUILD_FOR),Linux)
    1.90 +    CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    1.91 +else ifeq ($(BUILD_FOR),Darwin)
    1.92 +    CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
    1.93 +endif
    1.94 +
    1.95 +CPPFLAGS=
    1.96 +
    1.97 +# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
    1.98 +# The tests do not work properly, if compiled with -DNDEBUG
    1.99 +ifeq ($(BUILD_FOR),Linux)
   1.100 +    ifdef WARN
   1.101 +        CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
   1.102 +    else
   1.103 +        CFLAGS+= -w
   1.104 +    endif
   1.105 +    ifdef DEBUG
   1.106 +        CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
   1.107 +    else
   1.108 +        CFLAGS+= -O3 -DNDEBUG
   1.109 +    endif
   1.110 +else ifeq ($(BUILD_FOR),Darwin)    
   1.111 +    ifdef WARN
   1.112 +        # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
   1.113 +        CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
   1.114 +    else
   1.115 +        CFLAGS+= -w
   1.116 +    endif
   1.117 +    ifdef DEBUG
   1.118 +        CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
   1.119 +    else
   1.120 +        CFLAGS+= -O3 -DNDEBUG
   1.121 +    endif
   1.122 +endif
   1.123 +
   1.124 +# Additional CFLAGS used for compiling ASN1C-generated code
   1.125 +ifeq ($(BUILD_FOR),Linux)
   1.126 +    # 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.
   1.127 +    CFLAGS_GENERATED=-D_DEFAULT_SOURCE
   1.128 +else ifeq ($(BUILD_FOR),Darwin)
   1.129 +    CFLAGS_GENERATED=
   1.130 +endif
   1.131 +
   1.132 +
   1.133 +######### C++ #########
   1.134 +ifeq ($(BUILD_FOR),Linux)
   1.135 +    CXX=g++ -std=gnu++11 -pthread
   1.136 +else ifeq ($(BUILD_FOR),Darwin)
   1.137 +    # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
   1.138 +    CXX=clang -std=c++11
   1.139 +endif
   1.140 +
   1.141 +# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
   1.142 +# The tests do not work properly, if compiled with -DNDEBUG
   1.143 +ifeq ($(BUILD_FOR),Linux)
   1.144 +    CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
   1.145 +    ifdef WARN
   1.146 +        CXXFLAGS+=
   1.147 +    else
   1.148 +        CXXFLAGS+= -w
   1.149 +    endif
   1.150 +    ifdef DEBUG
   1.151 +        CXXFLAGS+= -Og -ggdb
   1.152 +    else
   1.153 +        CXXFLAGS+= -O3 -DNDEBUG
   1.154 +    endif
   1.155 +else ifeq ($(BUILD_FOR),Darwin)
   1.156 +    CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
   1.157 +    ifdef WARN
   1.158 +        CXXFLAGS+=
   1.159 +    else
   1.160 +        CXXFLAGS+= -w
   1.161 +    endif
   1.162 +    ifdef DEBUG
   1.163 +        CXXFLAGS+= -O0 -g
   1.164 +    else
   1.165 +        CXXFLAGS+= -O3 -DNDEBUG
   1.166 +    endif
   1.167 +endif
   1.168 +
   1.169 +
   1.170 +######### YML2 #########
   1.171 +YML2_PATH=$(HOME)/yml2
   1.172 +
   1.173 +YML2_PROC=$(YML2_PATH)/yml2proc
   1.174 +
   1.175 +YML2_OPTS=--encoding=utf8
   1.176 +
   1.177 +
   1.178 +######### asn1c #########
   1.179 +# asn1c binary
   1.180 +ASN1C=asn1c
   1.181 +
   1.182 +# asn1c include search flag
   1.183 +ASN1C_INC=
   1.184 +#ASN1C_INC=-I$(HOME)/include
   1.185 +
   1.186 +
   1.187 +######### libetpan #########
   1.188 +# libetpan library search flag
   1.189 +ETPAN_LIB=-L$(PREFIX)/lib
   1.190 +
   1.191 +# libetpan include search flag
   1.192 +ETPAN_INC=-I$(PREFIX)/include
   1.193 +
   1.194 +
   1.195 +######### sqlite3 #########
   1.196 +# If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
   1.197 +# Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
   1.198 +SQLITE3_FROM_OS=placeholder
   1.199 +
   1.200 +
   1.201 +######### OpenPGP #########
   1.202 +# Path of GPG binary
   1.203 +GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   1.204 +
   1.205 +# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
   1.206 +OPENPGP=GPG
   1.207 +
   1.208 +# Path of libGPGME binary
   1.209 +ifeq ($(BUILD_FOR),Linux)
   1.210 +    LIBGPGME=libgpgme.so.11
   1.211 +else ifeq ($(BUILD_FOR),Darwin)
   1.212 +    LIBGPGME=libgpgme.dylib
   1.213 +endif
   1.214 +
   1.215 +# libGPGME library search flag
   1.216 +ifeq ($(BUILD_FOR),Linux)
   1.217 +    GPGME_LIB=
   1.218 +else ifeq ($(BUILD_FOR),Darwin)
   1.219 +    GPGME_LIB=-L$(HOME)/lib
   1.220 +endif
   1.221 +
   1.222 +# libGPGME include search flag
   1.223 +ifeq ($(BUILD_FOR),Linux)
   1.224 +    GPGME_INC=
   1.225 +else ifeq ($(BUILD_FOR),Darwin)
   1.226 +    GPGME_INC=-I$(HOME)/include
   1.227 +endif
   1.228 +
   1.229 +# NETPGP library search flag
   1.230 +NETPGP_LIB=
   1.231 +#NETPGP_LIB=-L$(PREFIX)/lib
   1.232 +
   1.233 +# libGPGME include search flag
   1.234 +NETPGP_INC=
   1.235 +#NETPGP_INC=-I$(PREFIX)/include
   1.236 +
   1.237 +
   1.238 +######### Engine internals #########
   1.239 +# C macros (not environment variables) that can be overridden:
   1.240 +# DEFAULT_KEYSERVER - string with default keyserver
   1.241 +# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
   1.242 +# Example:
   1.243 +#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
   1.244 +EXTRA_MACROS=
   1.245 +
   1.246 +
   1.247 +######### Misc #########
   1.248 +# FIXME Maybe include these variables here.
   1.249 +# Check how they are used throughout the project before setting them here
   1.250 +#LLDB_BIN
   1.251 +
   1.252 +
   1.253 +-include HERE/local.conf
   1.254 \ No newline at end of file
     2.1 --- a/build-config/common.conf	Wed Sep 20 11:57:26 2017 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,213 +0,0 @@
     2.4 -# Copyright 2017, pEp Foundation
     2.5 -# This file is part of pEpEngine
     2.6 -# This file may be used under the terms of the GNU General Public License version 3
     2.7 -# see LICENSE.txt
     2.8 -
     2.9 -# General remark: to use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
    2.10 -# All the *_INC and *_LIB variables are command line flags, not paths.
    2.11 -# Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
    2.12 -
    2.13 -######### General #########
    2.14 -BUILD_ON:=$(shell uname)
    2.15 -
    2.16 -# This variable specifies the platform that the engine should be cross-compiled for.
    2.17 -BUILD_FOR=$(BUILD_ON)
    2.18 -
    2.19 -# Installation path prefix for libraries and binaries, except for system.db
    2.20 -PREFIX=$(HOME)
    2.21 -
    2.22 -# Installation path for system.db
    2.23 -SYSTEM_DB=/usr/local/share/pEp/system.db
    2.24 -
    2.25 -# Filename of the pEpEngine library
    2.26 -ifeq ($(BUILD_FOR),Linux)
    2.27 -    TARGET=libpEpEngine.so
    2.28 -else ifeq ($(BUILD_FOR),Darwin)
    2.29 -    TARGET=libpEpEngine.dylib
    2.30 -endif
    2.31 -
    2.32 -# If empty, create a release build.
    2.33 -# Otherwise, create a debug build.
    2.34 -# This variable is ineffective in your override.conf file.
    2.35 -DEBUG=
    2.36 -
    2.37 -# If empty, suppress compiler warnings.
    2.38 -# Otherwise, print warnings.
    2.39 -# This variable is ineffective in your override.conf file.
    2.40 -WARN=placeholder
    2.41 -
    2.42 -######### C #########
    2.43 -ifeq ($(BUILD_FOR),Linux)
    2.44 -    CC=gcc -std=c99 -pthread
    2.45 -else ifeq ($(BUILD_FOR),Darwin)
    2.46 -    # clang issues a warning when "-pthread" is used for linking. So, include it in CFLAGS, and not in CC
    2.47 -    CC=clang -std=c99
    2.48 -endif
    2.49 -
    2.50 -ifeq ($(BUILD_FOR),Linux)
    2.51 -    CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    2.52 -else ifeq ($(BUILD_FOR),Darwin)
    2.53 -    CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
    2.54 -endif
    2.55 -
    2.56 -CPPFLAGS=
    2.57 -
    2.58 -# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
    2.59 -# The tests do not work properly, if compiled with -DNDEBUG
    2.60 -ifeq ($(BUILD_FOR),Linux)
    2.61 -    ifdef WARN
    2.62 -        CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
    2.63 -    else
    2.64 -        CFLAGS+= -w
    2.65 -    endif
    2.66 -    ifdef DEBUG
    2.67 -        CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
    2.68 -    else
    2.69 -        CFLAGS+= -O3 -DNDEBUG
    2.70 -    endif
    2.71 -else ifeq ($(BUILD_FOR),Darwin)    
    2.72 -    ifdef WARN
    2.73 -        # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
    2.74 -        CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
    2.75 -    else
    2.76 -        CFLAGS+= -w
    2.77 -    endif
    2.78 -    ifdef DEBUG
    2.79 -        CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
    2.80 -    else
    2.81 -        CFLAGS+= -O3 -DNDEBUG
    2.82 -    endif
    2.83 -endif
    2.84 -
    2.85 -# Additional CFLAGS used for compiling ASN1C-generated code
    2.86 -ifeq ($(BUILD_FOR),Linux)
    2.87 -    # 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.
    2.88 -    CFLAGS_GENERATED=-D_DEFAULT_SOURCE
    2.89 -else ifeq ($(BUILD_FOR),Darwin)
    2.90 -    CFLAGS_GENERATED=
    2.91 -endif
    2.92 -
    2.93 -######### C++ #########
    2.94 -ifeq ($(BUILD_FOR),Linux)
    2.95 -    CXX=g++ -std=gnu++11 -pthread
    2.96 -else ifeq ($(BUILD_FOR),Darwin)
    2.97 -    # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
    2.98 -    CXX=clang -std=c++11
    2.99 -endif
   2.100 -
   2.101 -# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
   2.102 -# The tests do not work properly, if compiled with -DNDEBUG
   2.103 -ifeq ($(BUILD_FOR),Linux)
   2.104 -    CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
   2.105 -    ifdef WARN
   2.106 -        CXXFLAGS+=
   2.107 -    else
   2.108 -        CXXFLAGS+= -w
   2.109 -    endif
   2.110 -    ifdef DEBUG
   2.111 -        CXXFLAGS+= -Og -ggdb
   2.112 -    else
   2.113 -        CXXFLAGS+= -O3 -DNDEBUG
   2.114 -    endif
   2.115 -else ifeq ($(BUILD_FOR),Darwin)
   2.116 -    CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
   2.117 -    ifdef WARN
   2.118 -        CXXFLAGS+=
   2.119 -    else
   2.120 -        CXXFLAGS+= -w
   2.121 -    endif
   2.122 -    ifdef DEBUG
   2.123 -        CXXFLAGS+= -O0 -g
   2.124 -    else
   2.125 -        CXXFLAGS+= -O3 -DNDEBUG
   2.126 -    endif
   2.127 -endif
   2.128 -
   2.129 -######### C and C++ #########
   2.130 -TARGET_ARCH=
   2.131 -# The following two variables will be appended to.
   2.132 -# You can thus not set them to a fixed value here.
   2.133 -ifeq ($(BUILD_FOR),Linux)
   2.134 -    LDFLAGS=
   2.135 -else ifeq ($(BUILD_FOR),Darwin)
   2.136 -    # "-bind_at_load" helps find symbol resolution errors faster
   2.137 -    LDFLAGS=-bind_at_load
   2.138 -endif
   2.139 -
   2.140 -LDLIBS=
   2.141 -
   2.142 -######### YML2 #########
   2.143 -YML2_PATH=$(HOME)/yml2
   2.144 -
   2.145 -YML2_PROC=$(YML2_PATH)/yml2proc
   2.146 -
   2.147 -YML2_OPTS=--encoding=utf8
   2.148 -
   2.149 -######### asn1c #########
   2.150 -# asn1c binary
   2.151 -ASN1C=asn1c
   2.152 -
   2.153 -# asn1c include search flag
   2.154 -ASN1C_INC=
   2.155 -#ASN1C_INC=-I$(HOME)/include
   2.156 -
   2.157 -######### libetpan #########
   2.158 -# libetpan library search flag
   2.159 -ETPAN_LIB=-L$(PREFIX)/lib
   2.160 -
   2.161 -# libetpan include search flag
   2.162 -ETPAN_INC=-I$(PREFIX)/include
   2.163 -
   2.164 -######### sqlite3 #########
   2.165 -# If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
   2.166 -# Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
   2.167 -SQLITE3_FROM_OS=placeholder
   2.168 -
   2.169 -######### OpenPGP #########
   2.170 -# Path of GPG binary
   2.171 -GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   2.172 -
   2.173 -# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
   2.174 -OPENPGP=GPG
   2.175 -
   2.176 -# Path of libGPGME binary
   2.177 -ifeq ($(BUILD_FOR),Linux)
   2.178 -    LIBGPGME=libgpgme.so.11
   2.179 -else ifeq ($(BUILD_FOR),Darwin)
   2.180 -    LIBGPGME=libgpgme.dylib
   2.181 -endif
   2.182 -
   2.183 -# libGPGME library search flag
   2.184 -ifeq ($(BUILD_FOR),Linux)
   2.185 -    GPGME_LIB=
   2.186 -else ifeq ($(BUILD_FOR),Darwin)
   2.187 -    GPGME_LIB=-L$(HOME)/lib
   2.188 -endif
   2.189 -
   2.190 -# libGPGME include search flag
   2.191 -ifeq ($(BUILD_FOR),Linux)
   2.192 -    GPGME_INC=
   2.193 -else ifeq ($(BUILD_FOR),Darwin)
   2.194 -    GPGME_INC=-I$(HOME)/include
   2.195 -endif
   2.196 -
   2.197 -# NETPGP library search flag
   2.198 -NETPGP_LIB=
   2.199 -#NETPGP_LIB=-L$(PREFIX)/lib
   2.200 -
   2.201 -# libGPGME include search flag
   2.202 -NETPGP_INC=
   2.203 -#NETPGP_INC=-I$(PREFIX)/include
   2.204 -
   2.205 -######### Engine internals #########
   2.206 -# C macros (not environment variables) that can be overridden:
   2.207 -# DEFAULT_KEYSERVER - string with default keyserver
   2.208 -# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
   2.209 -# Example:
   2.210 -#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
   2.211 -EXTRA_MACROS=
   2.212 -
   2.213 -######### Misc #########
   2.214 -# FIXME Maybe include these variables here.
   2.215 -# Check how they are used throughout the project before setting them here
   2.216 -#LLDB_BIN