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