Makefile.conf
author Damiano Boppart <damiano@pep-security.net>
Wed, 20 Sep 2017 17:53:25 +0200
branchENGINE-261
changeset 2081 1593ebbb7f31
parent 2070 d834a86b51e9
child 2083 361a6dc2c075
permissions -rw-r--r--
Move all build configuration into Makefile.conf
     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
     4 # see LICENSE.txt
     5 
     6 # This file gives an overview over all the parameters that can be easily customized for a build.
     7 # If you want to customized the build configuration without making the working copy unclean, create an addional makefile at `local.conf`.
     8 # `local.conf` will be included at the end of this file, and thus allows overriding any of the variables here.
     9 # If nothing is changed here (or in `local.conf`) a default configuration for your platform will be used.
    10 
    11 HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
    12 
    13 ######### General #########
    14 # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
    15 # All the *_INC and *_LIB variables are command line flags, not paths.
    16 # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
    17 
    18 BUILD_ON:=$(shell uname)
    19 
    20 # This variable specifies the platform that the engine should be cross-compiled for.
    21 BUILD_FOR=$(BUILD_ON)
    22 
    23 # Cross-compiling is currently not supported.
    24 # Maybe you can hack something with `local.conf`.
    25 ifneq ($(BUILD_ON),$(BUILD_FOR))
    26     $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
    27 endif
    28 
    29 # Installation path prefix for libraries and binaries, except for system.db
    30 PREFIX=$(HOME)
    31 
    32 # Installation path for system.db
    33 SYSTEM_DB=/usr/local/share/pEp/system.db
    34 
    35 # Filename of the pEpEngine library
    36 ifeq ($(BUILD_FOR),Linux)
    37     TARGET=libpEpEngine.so
    38 else ifeq ($(BUILD_FOR),Darwin)
    39     TARGET=libpEpEngine.dylib
    40 endif
    41 
    42 # If empty, create a release build.
    43 # Otherwise, create a debug build.
    44 # This variable is ineffective in your override.conf file.
    45 DEBUG=
    46 
    47 # If empty, suppress compiler warnings.
    48 # Otherwise, print warnings.
    49 # This variable is ineffective in your override.conf file.
    50 WARN=placeholder
    51 
    52 
    53 ######### C and C++ #########
    54 TARGET_ARCH=
    55 # The following two variables will be appended to.
    56 # You can thus not set them to a fixed value here.
    57 ifeq ($(BUILD_FOR),Linux)
    58     LDFLAGS=
    59 else ifeq ($(BUILD_FOR),Darwin)
    60     # "-bind_at_load" helps find symbol resolution errors faster
    61     LDFLAGS=-bind_at_load
    62 endif
    63 
    64 LDLIBS=
    65 
    66 
    67 ######### C #########
    68 ifeq ($(BUILD_FOR),Linux)
    69     CC=gcc -std=c99 -pthread
    70 else ifeq ($(BUILD_FOR),Darwin)
    71     # clang issues a warning when "-pthread" is used for linking. So, include it in CFLAGS, and not in CC
    72     CC=clang -std=c99
    73 endif
    74 
    75 ifeq ($(BUILD_FOR),Linux)
    76     CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    77 else ifeq ($(BUILD_FOR),Darwin)
    78     CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
    79 endif
    80 
    81 CPPFLAGS=
    82 
    83 # The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
    84 # The tests do not work properly, if compiled with -DNDEBUG
    85 ifeq ($(BUILD_FOR),Linux)
    86     ifdef WARN
    87         CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
    88     else
    89         CFLAGS+= -w
    90     endif
    91     ifdef DEBUG
    92         CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
    93     else
    94         CFLAGS+= -O3 -DNDEBUG
    95     endif
    96 else ifeq ($(BUILD_FOR),Darwin)    
    97     ifdef WARN
    98         # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
    99         CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
   100     else
   101         CFLAGS+= -w
   102     endif
   103     ifdef DEBUG
   104         CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
   105     else
   106         CFLAGS+= -O3 -DNDEBUG
   107     endif
   108 endif
   109 
   110 # Additional CFLAGS used for compiling ASN1C-generated code
   111 ifeq ($(BUILD_FOR),Linux)
   112     # 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.
   113     CFLAGS_GENERATED=-D_DEFAULT_SOURCE
   114 else ifeq ($(BUILD_FOR),Darwin)
   115     CFLAGS_GENERATED=
   116 endif
   117 
   118 
   119 ######### C++ #########
   120 ifeq ($(BUILD_FOR),Linux)
   121     CXX=g++ -std=gnu++11 -pthread
   122 else ifeq ($(BUILD_FOR),Darwin)
   123     # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
   124     CXX=clang -std=c++11
   125 endif
   126 
   127 # The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
   128 # The tests do not work properly, if compiled with -DNDEBUG
   129 ifeq ($(BUILD_FOR),Linux)
   130     CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
   131     ifdef WARN
   132         CXXFLAGS+=
   133     else
   134         CXXFLAGS+= -w
   135     endif
   136     ifdef DEBUG
   137         CXXFLAGS+= -Og -ggdb
   138     else
   139         CXXFLAGS+= -O3 -DNDEBUG
   140     endif
   141 else ifeq ($(BUILD_FOR),Darwin)
   142     CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
   143     ifdef WARN
   144         CXXFLAGS+=
   145     else
   146         CXXFLAGS+= -w
   147     endif
   148     ifdef DEBUG
   149         CXXFLAGS+= -O0 -g
   150     else
   151         CXXFLAGS+= -O3 -DNDEBUG
   152     endif
   153 endif
   154 
   155 
   156 ######### YML2 #########
   157 YML2_PATH=$(HOME)/yml2
   158 
   159 YML2_PROC=$(YML2_PATH)/yml2proc
   160 
   161 YML2_OPTS=--encoding=utf8
   162 
   163 
   164 ######### asn1c #########
   165 # asn1c binary
   166 ASN1C=asn1c
   167 
   168 # asn1c include search flag
   169 ASN1C_INC=
   170 #ASN1C_INC=-I$(HOME)/include
   171 
   172 
   173 ######### libetpan #########
   174 # libetpan library search flag
   175 ETPAN_LIB=-L$(PREFIX)/lib
   176 
   177 # libetpan include search flag
   178 ETPAN_INC=-I$(PREFIX)/include
   179 
   180 
   181 ######### sqlite3 #########
   182 # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
   183 # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
   184 SQLITE3_FROM_OS=placeholder
   185 
   186 
   187 ######### OpenPGP #########
   188 # Path of GPG binary
   189 GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   190 
   191 # Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
   192 OPENPGP=GPG
   193 
   194 # Path of libGPGME binary
   195 ifeq ($(BUILD_FOR),Linux)
   196     LIBGPGME=libgpgme.so.11
   197 else ifeq ($(BUILD_FOR),Darwin)
   198     LIBGPGME=libgpgme.dylib
   199 endif
   200 
   201 # libGPGME library search flag
   202 ifeq ($(BUILD_FOR),Linux)
   203     GPGME_LIB=
   204 else ifeq ($(BUILD_FOR),Darwin)
   205     GPGME_LIB=-L$(HOME)/lib
   206 endif
   207 
   208 # libGPGME include search flag
   209 ifeq ($(BUILD_FOR),Linux)
   210     GPGME_INC=
   211 else ifeq ($(BUILD_FOR),Darwin)
   212     GPGME_INC=-I$(HOME)/include
   213 endif
   214 
   215 # NETPGP library search flag
   216 NETPGP_LIB=
   217 #NETPGP_LIB=-L$(PREFIX)/lib
   218 
   219 # libGPGME include search flag
   220 NETPGP_INC=
   221 #NETPGP_INC=-I$(PREFIX)/include
   222 
   223 
   224 ######### Engine internals #########
   225 # C macros (not environment variables) that can be overridden:
   226 # DEFAULT_KEYSERVER - string with default keyserver
   227 # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
   228 # Example:
   229 #    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
   230 EXTRA_MACROS=
   231 
   232 
   233 ######### Misc #########
   234 # FIXME Maybe include these variables here.
   235 # Check how they are used throughout the project before setting them here
   236 #LLDB_BIN
   237 
   238 
   239 -include HERE/local.conf