Makefile.conf
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 29 May 2019 09:59:00 +0200
branchsync
changeset 3762 55501092d6e3
parent 3580 7c757957849b
child 3648 f7f07e2825d1
child 4003 572e950593dc
permissions -rw-r--r--
Yeah, so static local variables are dangerous with multiple threads. (This has apparently been in since revision 0, so we should probably look out for other similar assumptions in the code.
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@2569
     6
# See `doc/build-<your platform>.md` for documentation on how to build, and customize your build.
vb@450
     7
damiano@3201
     8
# This file sets all the make variables that allow you to customize a build.
damiano@3201
     9
# There are 3 ways in which you can customize your build:
damiano@3201
    10
# 1) Edit the variable assignments in this file (this is a tracked file, so your repository will be dirty)
damiano@3201
    11
# 2) Create `local.conf` and fill it with variable assignments.
damiano@3201
    12
# 3) Set the environment variable `BUILD_CONFIG` to an absolute path.
damiano@3201
    13
#    The variable assignments found in the make file at the path indicated by `BUILD_CONFIG` will be evaluated.
damiano@3201
    14
# Customization options are applied in the order given above. Later variable assignments take precedence over earlier ones.
damiano@3201
    15
# It is possible to use multiple variants simultaniously.
damiano@3201
    16
# If nothing is changed according to these 3 methods, a default configuration for your platform (specified below) will be used for the build.
damiano@3201
    17
damiano@3201
    18
damiano@3201
    19
######### Header #########
damiano@3201
    20
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
damiano@3201
    21
damiano@3201
    22
damiano@2081
    23
######### General #########
damiano@2081
    24
# To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
damiano@2081
    25
# All the *_INC and *_LIB variables are command line flags, not paths.
damiano@2081
    26
# Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
vb@1089
    27
damiano@3201
    28
BUILD_ON:=$(shell uname)
damiano@2081
    29
damiano@2081
    30
# This variable specifies the platform that the engine should be cross-compiled for.
damiano@3201
    31
BUILD_FOR=$(BUILD_ON)
damiano@3201
    32
damiano@3201
    33
# Cross-compiling is currently not supported.
damiano@3201
    34
# Maybe you can hack something with `local.conf`.
damiano@3201
    35
ifneq ($(BUILD_ON),$(BUILD_FOR))
damiano@3201
    36
    $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
damiano@3201
    37
endif
damiano@2081
    38
damiano@2081
    39
# Installation path prefix for libraries and binaries, except for system.db
damiano@3201
    40
PREFIX=$(HOME)
damiano@2081
    41
damiano@2081
    42
# Installation path for system.db
damiano@3201
    43
SYSTEM_DB=/usr/local/share/pEp/system.db
damiano@2081
    44
damiano@2081
    45
# Filename of the pEpEngine library
damiano@3201
    46
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    47
    TARGET=libpEpEngine.so
damiano@3201
    48
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    49
    TARGET=libpEpEngine.dylib
damiano@3201
    50
endif
damiano@3201
    51
damiano@3201
    52
# If empty, create a release build.
damiano@3201
    53
# Otherwise, create a debug build.
damiano@3202
    54
# This variable is ineffective when set anywhere else but here.
damiano@3201
    55
DEBUG=placeholder
damiano@3201
    56
damiano@3201
    57
# If empty, suppress compiler warnings.
damiano@3201
    58
# Otherwise, print warnings.
damiano@3202
    59
# This variable is ineffective when set anywhere else but here.
damiano@3201
    60
WARN=placeholder
damiano@2081
    61
damiano@2081
    62
damiano@2081
    63
######### C and C++ #########
damiano@3201
    64
TARGET_ARCH=
damiano@2211
    65
damiano@2081
    66
# The following two variables will be appended to.
damiano@3202
    67
# You can thus not set them to a final, fixed value here.
damiano@3201
    68
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    69
    LDFLAGS=
damiano@3201
    70
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    71
    # "-bind_at_load" helps find symbol resolution errors faster
damiano@3201
    72
    LDFLAGS=-bind_at_load
damiano@3201
    73
endif
damiano@2081
    74
damiano@3201
    75
LDLIBS=
damiano@2081
    76
damiano@2081
    77
damiano@2081
    78
######### C #########
damiano@3201
    79
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    80
    CC=gcc -std=c99 -pthread
damiano@3201
    81
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    82
    # clang issues a warning when "-pthread" is used for linking.
damiano@3201
    83
    # So, include it in CFLAGS, and not in CC
damiano@3201
    84
    CC=clang -std=c99
damiano@3201
    85
endif
damiano@2081
    86
damiano@3201
    87
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    88
    CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
damiano@3201
    89
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    90
    CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
damiano@3201
    91
endif
damiano@2081
    92
damiano@3201
    93
# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
damiano@3201
    94
# The tests do not work properly, if compiled with -DNDEBUG
damiano@3201
    95
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    96
    ifdef WARN
damiano@3201
    97
        CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
damiano@3201
    98
    else
damiano@3201
    99
        CFLAGS+= -w
damiano@3201
   100
    endif
damiano@3201
   101
    ifdef DEBUG
damiano@3201
   102
        CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
damiano@3201
   103
    else
damiano@3201
   104
        CFLAGS+= -O3 -DNDEBUG
damiano@3201
   105
    endif
damiano@3201
   106
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   107
    ifdef WARN
damiano@3201
   108
        # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
damiano@3201
   109
        CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
damiano@3201
   110
    else
damiano@3201
   111
        CFLAGS+= -w
damiano@3201
   112
    endif
damiano@3201
   113
    ifdef DEBUG
damiano@3201
   114
        CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
damiano@3201
   115
    else
damiano@3201
   116
        CFLAGS+= -O3 -DNDEBUG
damiano@3201
   117
    endif
damiano@3201
   118
endif
damiano@2081
   119
damiano@2081
   120
# Additional CFLAGS used for compiling ASN1C-generated code
damiano@3201
   121
ifeq ($(BUILD_FOR),Linux)
damiano@3201
   122
    # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
damiano@3201
   123
    #   _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
damiano@3201
   124
    # otherwise printed during the compilation of every asn1c-generated C file.
damiano@3201
   125
    # It's a glibc specific warning, only present in few versions around ~2.19.
damiano@3201
   126
    # See https://lwn.net/Articles/590381/ for a discussion.
damiano@3201
   127
    CFLAGS_GENERATED=-D_DEFAULT_SOURCE
damiano@3201
   128
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   129
    CFLAGS_GENERATED=
damiano@3201
   130
endif
damiano@2081
   131
damiano@2081
   132
damiano@2081
   133
######### C++ #########
damiano@3201
   134
ifeq ($(BUILD_FOR),Linux)
damiano@3201
   135
    CXX=g++ -std=gnu++11 -pthread
damiano@3201
   136
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   137
    # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
damiano@3201
   138
    CXX=clang -std=c++11
damiano@3201
   139
endif
damiano@2081
   140
damiano@3201
   141
# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
damiano@3201
   142
# The tests do not work properly, if compiled with -DNDEBUG
damiano@3201
   143
ifeq ($(BUILD_FOR),Linux)
damiano@3201
   144
    CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
damiano@3201
   145
    ifdef WARN
damiano@3201
   146
        CXXFLAGS+=
damiano@3201
   147
    else
damiano@3201
   148
        CXXFLAGS+= -w
damiano@3201
   149
    endif
damiano@3201
   150
    ifdef DEBUG
damiano@3201
   151
        CXXFLAGS+= -g -ggdb
damiano@3201
   152
    else
damiano@3201
   153
        CXXFLAGS+= -O3 -DNDEBUG
damiano@3201
   154
    endif
damiano@3201
   155
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   156
    CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
damiano@3201
   157
    ifdef WARN
damiano@3201
   158
        CXXFLAGS+=
damiano@3201
   159
    else
damiano@3201
   160
        CXXFLAGS+= -w
damiano@3201
   161
    endif
damiano@3201
   162
    ifdef DEBUG
damiano@3201
   163
        CXXFLAGS+= -O0 -g
damiano@3201
   164
    else
damiano@3201
   165
        CXXFLAGS+= -O3 -DNDEBUG
damiano@3201
   166
    endif
damiano@3201
   167
endif
damiano@3201
   168
damiano@3201
   169
damiano@3201
   170
######### C and C++ #########
damiano@3201
   171
CPPFLAGS=
damiano@2081
   172
damiano@2081
   173
damiano@2081
   174
######### YML2 #########
damiano@3201
   175
YML2_PATH=$(HOME)/yml2
damiano@2081
   176
damiano@3202
   177
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
damiano@2081
   178
damiano@3201
   179
YML2_OPTS=--encoding=utf8
damiano@2081
   180
damiano@2081
   181
damiano@2081
   182
######### asn1c #########
damiano@2081
   183
# asn1c binary
damiano@3201
   184
ASN1C=asn1c
damiano@2081
   185
damiano@2081
   186
# asn1c include search flag
damiano@3201
   187
ASN1C_INC=
damiano@3202
   188
#ASN1C_INC=-I$(HOME)/include
damiano@2081
   189
damiano@2081
   190
damiano@2081
   191
######### libetpan #########
damiano@2081
   192
# libetpan library search flag
damiano@3201
   193
ETPAN_LIB=
damiano@3202
   194
#ETPAN_LIB=-L$(HOME)/lib
damiano@2081
   195
damiano@2081
   196
# libetpan include search flag
damiano@3201
   197
ETPAN_INC=
damiano@3202
   198
#ETPAN_INC=-I$(HOME)/include
damiano@2081
   199
damiano@2081
   200
vb@3443
   201
######### pEp MIME #########
vb@3443
   202
# set this to skip libetpan and use PEP_MIME instead
vb@3443
   203
# PEP_MIME=1
vb@3443
   204
#
vb@3443
   205
# pEp MIME library search flag
vb@3443
   206
PEP_MIME_LIB=
vb@3443
   207
# pEp MIME include search flag
vb@3443
   208
PEP_MIME_INC=
vb@3443
   209
vb@3443
   210
damiano@2081
   211
######### sqlite3 #########
damiano@2081
   212
# If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
damiano@2081
   213
# Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
damiano@3201
   214
SQLITE3_FROM_OS=placeholder
damiano@2081
   215
damiano@2081
   216
damiano@2081
   217
######### OpenPGP #########
damiano@2081
   218
# Path of GPG binary
damiano@2163
   219
# 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@3201
   220
GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
damiano@2081
   221
damiano@3237
   222
# Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
damiano@3201
   223
OPENPGP=GPG
damiano@2081
   224
damiano@3236
   225
# Sequoia-specific variables
krista@3428
   226
SEQUOIA_CFLAGS=
krista@3428
   227
SEQUOIA_LDFLAGS=
krista@3428
   228
SEQUOIA_LIB=
krista@3428
   229
SEQUOIA_INC=
damiano@3236
   230
damiano@3201
   231
# libGPGME filename
damiano@3284
   232
ifeq ($(BUILD_FOR),Linux)
damiano@3284
   233
    LIBGPGME=libgpgme.so.11
damiano@3284
   234
else ifeq ($(BUILD_FOR),Darwin)
damiano@3284
   235
    LIBGPGME=libgpgme.11.dylib
damiano@3201
   236
endif
damiano@2081
   237
damiano@2081
   238
# libGPGME library search flag
damiano@3201
   239
GPGME_LIB=
damiano@3201
   240
#GPGME_LIB=-L$(HOME)/lib
damiano@2081
   241
damiano@2081
   242
# libGPGME include search flag
damiano@3201
   243
GPGME_INC=
damiano@3201
   244
#GPGME_INC=-I$(HOME)/include
damiano@2081
   245
damiano@2081
   246
# NETPGP library search flag
damiano@3201
   247
NETPGP_LIB=
damiano@3202
   248
#NETPGP_LIB=-L$(HOME)/lib
damiano@2081
   249
damiano@2081
   250
# libGPGME include search flag
damiano@3201
   251
NETPGP_INC=
damiano@3202
   252
#NETPGP_INC=-I$(HOME)/include
damiano@2081
   253
damiano@2081
   254
krista@3428
   255
damiano@3201
   256
######### CppUnit #########
damiano@3201
   257
# CppUnit library search flag
damiano@3201
   258
CPPUNIT_LIB=
damiano@3201
   259
#CPPUNIT_LIB=-L$(HOME)/local/lib
damiano@3201
   260
damiano@3201
   261
# CppUnit include search flag
damiano@3201
   262
CPPUNIT_INC=
damiano@3201
   263
#CPPUNIT_INC=-I$(HOME)/local/inc
damiano@3201
   264
damiano@3201
   265
damiano@2081
   266
######### Engine internals #########
damiano@2081
   267
# C macros (not environment variables) that can be overridden:
damiano@2081
   268
# DEFAULT_KEYSERVER - string with default keyserver
damiano@2081
   269
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
damiano@2081
   270
# Example:
damiano@2081
   271
#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
damiano@3201
   272
EXTRA_MACROS=
damiano@3201
   273
damiano@3201
   274
damiano@3201
   275
######### Misc #########
damiano@3580
   276
# FIXME Maybe include these variables here.
damiano@3580
   277
# Check how they are used throughout the project before setting them here
damiano@3580
   278
#LLDB_BIN
damiano@3580
   279
damiano@3202
   280
# Add this for running tests in debugger
damiano@3202
   281
#TEST_DEBUGGER=lldb --batch -o r
vb@2750
   282
damiano@3202
   283
# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
damiano@3202
   284
EXCLUDE=
damiano@3201
   285
damiano@3201
   286
damiano@3201
   287
######### Footer #########
damiano@3201
   288
-include $(HERE)/local.conf
damiano@3201
   289
damiano@3201
   290
ifdef BUILD_CONFIG
damiano@3201
   291
    include $(BUILD_CONFIG)
damiano@3201
   292
endif
damiano@3201
   293
krista@3428
   294
######### Post processing assignments ########
krista@3435
   295
# These variables are ineffective when set anywhere else but here.
krista@3428
   296
ifeq ($(OPENPGP),SEQUOIA)
krista@3428
   297
    SEQUOIA_CFLAGS=$(shell pkg-config --cflags-only-other sequoia-openpgp)
krista@3428
   298
    SEQUOIA_LDFLAGS=$(shell pkg-config --libs-only-l --libs-only-other sequoia-openpgp)
krista@3428
   299
    SEQUOIA_LIB=$(shell pkg-config --libs-only-L sequoia-openpgp)
krista@3428
   300
    SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
krista@3428
   301
    CFLAGS+= $(SEQUOIA_CFLAGS)
krista@3428
   302
    LD_FLAGS+= $(SEQUOIA_LDFLAGS)
krista@3428
   303
endif
krista@3428
   304
damiano@3201
   305
# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
damiano@3201
   306
export YML_PATH=$(YML2_PATH)