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