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