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