Makefile.conf
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 29 May 2020 14:57:14 +0200
branchsync
changeset 4720 de3a945ae12b
parent 4701 3db667f48863
permissions -rw-r--r--
cross-branch test contamination maybe?
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
vb@4003
    42
# pEp files and directories
vb@4003
    43
#
vb@4003
    44
# the PER_USER_DIRECTORY will be in $(HOME), respectively
vb@4003
    45
# in debug builds the PER_USER_DIRECTORY will be in $(PEP_HOME) instead if set
vb@4003
    46
#
vb@4003
    47
# PER_MACHINE_DIRECTORY is calculated depending on platform; overwrite if
vb@4003
    48
# necessary
vb@4003
    49
vb@4003
    50
#PER_USER_DIRECTORY=.pEp
damiano@4432
    51
PER_MACHINE_DIRECTORY=/usr/local/share/pEp
damiano@2081
    52
damiano@2081
    53
# Filename of the pEpEngine library
damiano@3201
    54
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    55
    TARGET=libpEpEngine.so
damiano@3201
    56
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    57
    TARGET=libpEpEngine.dylib
damiano@3201
    58
endif
damiano@3201
    59
damiano@3201
    60
# If empty, create a release build.
damiano@3201
    61
# Otherwise, create a debug build.
damiano@3202
    62
# This variable is ineffective when set anywhere else but here.
damiano@3201
    63
DEBUG=placeholder
damiano@3201
    64
damiano@3201
    65
# If empty, suppress compiler warnings.
damiano@3201
    66
# Otherwise, print warnings.
damiano@3202
    67
# This variable is ineffective when set anywhere else but here.
damiano@3201
    68
WARN=placeholder
damiano@2081
    69
damiano@2081
    70
damiano@2081
    71
######### C and C++ #########
damiano@3201
    72
TARGET_ARCH=
damiano@2211
    73
damiano@2081
    74
# The following two variables will be appended to.
damiano@3202
    75
# You can thus not set them to a final, fixed value here.
damiano@3201
    76
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    77
    LDFLAGS=
damiano@3201
    78
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    79
    # "-bind_at_load" helps find symbol resolution errors faster
damiano@3201
    80
    LDFLAGS=-bind_at_load
damiano@3201
    81
endif
damiano@2081
    82
damiano@3201
    83
LDLIBS=
damiano@2081
    84
damiano@2081
    85
damiano@2081
    86
######### C #########
damiano@3201
    87
ifeq ($(BUILD_FOR),Linux)
damiano@3201
    88
    CC=gcc -std=c99 -pthread
damiano@3201
    89
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    90
    # clang issues a warning when "-pthread" is used for linking.
damiano@3201
    91
    # So, include it in CFLAGS, and not in CC
damiano@3201
    92
    CC=clang -std=c99
damiano@3201
    93
endif
damiano@2081
    94
damiano@3201
    95
ifeq ($(BUILD_FOR),Linux)
neal@4235
    96
    CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=auto
damiano@3201
    97
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
    98
    CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
damiano@3201
    99
endif
damiano@2081
   100
damiano@3201
   101
# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
damiano@3201
   102
# The tests do not work properly, if compiled with -DNDEBUG
damiano@3201
   103
ifeq ($(BUILD_FOR),Linux)
damiano@3201
   104
    ifdef WARN
damiano@3201
   105
        CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
damiano@3201
   106
    else
damiano@3201
   107
        CFLAGS+= -w
damiano@3201
   108
    endif
damiano@3201
   109
    ifdef DEBUG
damiano@3201
   110
        CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
damiano@3201
   111
    else
damiano@3201
   112
        CFLAGS+= -O3 -DNDEBUG
damiano@3201
   113
    endif
damiano@3201
   114
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   115
    ifdef WARN
krista@4124
   116
        CFLAGS+= -Wall -pedantic
damiano@3201
   117
    else
damiano@3201
   118
        CFLAGS+= -w
damiano@3201
   119
    endif
damiano@3201
   120
    ifdef DEBUG
damiano@3201
   121
        CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
damiano@3201
   122
    else
damiano@3201
   123
        CFLAGS+= -O3 -DNDEBUG
damiano@3201
   124
    endif
damiano@3201
   125
endif
damiano@2081
   126
damiano@2081
   127
# Additional CFLAGS used for compiling ASN1C-generated code
damiano@3201
   128
ifeq ($(BUILD_FOR),Linux)
damiano@3201
   129
    # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
damiano@3201
   130
    #   _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
damiano@3201
   131
    # otherwise printed during the compilation of every asn1c-generated C file.
damiano@3201
   132
    # It's a glibc specific warning, only present in few versions around ~2.19.
damiano@3201
   133
    # See https://lwn.net/Articles/590381/ for a discussion.
damiano@3201
   134
    CFLAGS_GENERATED=-D_DEFAULT_SOURCE
damiano@3201
   135
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   136
    CFLAGS_GENERATED=
damiano@3201
   137
endif
damiano@2081
   138
damiano@2081
   139
damiano@2081
   140
######### C++ #########
damiano@3201
   141
ifeq ($(BUILD_FOR),Linux)
damiano@3201
   142
    CXX=g++ -std=gnu++11 -pthread
damiano@3201
   143
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   144
    # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
damiano@3201
   145
    CXX=clang -std=c++11
damiano@3201
   146
endif
damiano@2081
   147
damiano@3201
   148
# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
damiano@3201
   149
# The tests do not work properly, if compiled with -DNDEBUG
damiano@3201
   150
ifeq ($(BUILD_FOR),Linux)
neal@4235
   151
    CXXFLAGS=-fdiagnostics-color=auto -I../src -I../asn.1 $(ETPAN_INC)
damiano@3201
   152
    ifdef WARN
damiano@3201
   153
        CXXFLAGS+=
damiano@3201
   154
    else
damiano@3201
   155
        CXXFLAGS+= -w
damiano@3201
   156
    endif
damiano@3201
   157
    ifdef DEBUG
damiano@3201
   158
        CXXFLAGS+= -g -ggdb
damiano@3201
   159
    else
damiano@3201
   160
        CXXFLAGS+= -O3 -DNDEBUG
damiano@3201
   161
    endif
damiano@3201
   162
else ifeq ($(BUILD_FOR),Darwin)
damiano@3201
   163
    CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
damiano@3201
   164
    ifdef WARN
damiano@3201
   165
        CXXFLAGS+=
damiano@3201
   166
    else
damiano@3201
   167
        CXXFLAGS+= -w
damiano@3201
   168
    endif
damiano@3201
   169
    ifdef DEBUG
damiano@3201
   170
        CXXFLAGS+= -O0 -g
damiano@3201
   171
    else
damiano@3201
   172
        CXXFLAGS+= -O3 -DNDEBUG
damiano@3201
   173
    endif
damiano@3201
   174
endif
damiano@3201
   175
damiano@3201
   176
damiano@3201
   177
######### C and C++ #########
krista@4028
   178
ifeq ($(BUILD_FOR),Darwin)
krista@4028
   179
    CPPFLAGS=-D_DARWIN_C_SOURCE
krista@4028
   180
else
krista@4028
   181
    CPPFLAGS=
krista@4028
   182
endif
krista@4028
   183
damiano@2081
   184
damiano@2081
   185
damiano@2081
   186
######### YML2 #########
damiano@3201
   187
YML2_PATH=$(HOME)/yml2
damiano@2081
   188
damiano@3202
   189
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
damiano@2081
   190
damiano@3201
   191
YML2_OPTS=--encoding=utf8
damiano@2081
   192
damiano@2081
   193
damiano@2081
   194
######### asn1c #########
damiano@2081
   195
# asn1c binary
damiano@3201
   196
ASN1C=asn1c
damiano@2081
   197
damiano@2081
   198
# asn1c include search flag
damiano@3201
   199
ASN1C_INC=
damiano@3202
   200
#ASN1C_INC=-I$(HOME)/include
damiano@2081
   201
damiano@2081
   202
damiano@2081
   203
######### libetpan #########
damiano@2081
   204
# libetpan library search flag
damiano@3201
   205
ETPAN_LIB=
damiano@3202
   206
#ETPAN_LIB=-L$(HOME)/lib
damiano@2081
   207
damiano@2081
   208
# libetpan include search flag
damiano@3201
   209
ETPAN_INC=
damiano@3202
   210
#ETPAN_INC=-I$(HOME)/include
damiano@2081
   211
damiano@2081
   212
vb@3443
   213
######### pEp MIME #########
vb@3443
   214
# set this to skip libetpan and use PEP_MIME instead
vb@3443
   215
# PEP_MIME=1
vb@3443
   216
#
vb@3443
   217
# pEp MIME library search flag
vb@3443
   218
PEP_MIME_LIB=
vb@3443
   219
# pEp MIME include search flag
vb@3443
   220
PEP_MIME_INC=
vb@3443
   221
vb@3443
   222
damiano@2081
   223
######### sqlite3 #########
damiano@2081
   224
# If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
damiano@2081
   225
# Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
damiano@3201
   226
SQLITE3_FROM_OS=placeholder
damiano@2081
   227
damiano@2081
   228
damiano@2081
   229
######### OpenPGP #########
damiano@2081
   230
# Path of GPG binary
damiano@2163
   231
# 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
   232
GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
damiano@2081
   233
damiano@3237
   234
# Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
damiano@3201
   235
OPENPGP=GPG
damiano@2081
   236
damiano@3236
   237
# Sequoia-specific variables
krista@3428
   238
SEQUOIA_CFLAGS=
krista@3428
   239
SEQUOIA_LDFLAGS=
krista@3428
   240
SEQUOIA_LIB=
krista@3428
   241
SEQUOIA_INC=
damiano@3236
   242
damiano@3201
   243
# libGPGME filename
damiano@3284
   244
ifeq ($(BUILD_FOR),Linux)
damiano@3284
   245
    LIBGPGME=libgpgme.so.11
damiano@3284
   246
else ifeq ($(BUILD_FOR),Darwin)
damiano@3284
   247
    LIBGPGME=libgpgme.11.dylib
damiano@3201
   248
endif
damiano@2081
   249
damiano@2081
   250
# libGPGME library search flag
damiano@3201
   251
GPGME_LIB=
damiano@3201
   252
#GPGME_LIB=-L$(HOME)/lib
damiano@2081
   253
damiano@2081
   254
# libGPGME include search flag
damiano@3201
   255
GPGME_INC=
damiano@3201
   256
#GPGME_INC=-I$(HOME)/include
damiano@2081
   257
damiano@2081
   258
# NETPGP library search flag
damiano@3201
   259
NETPGP_LIB=
damiano@3202
   260
#NETPGP_LIB=-L$(HOME)/lib
damiano@2081
   261
damiano@2081
   262
# libGPGME include search flag
damiano@3201
   263
NETPGP_INC=
damiano@3202
   264
#NETPGP_INC=-I$(HOME)/include
damiano@2081
   265
damiano@2081
   266
krista@3428
   267
damiano@3201
   268
######### CppUnit #########
damiano@3201
   269
# CppUnit library search flag
damiano@3201
   270
CPPUNIT_LIB=
damiano@3201
   271
#CPPUNIT_LIB=-L$(HOME)/local/lib
damiano@3201
   272
damiano@3201
   273
# CppUnit include search flag
damiano@3201
   274
CPPUNIT_INC=
damiano@3201
   275
#CPPUNIT_INC=-I$(HOME)/local/inc
damiano@3201
   276
damiano@3201
   277
damiano@2081
   278
######### Engine internals #########
damiano@2081
   279
# C macros (not environment variables) that can be overridden:
damiano@2081
   280
# DEFAULT_KEYSERVER - string with default keyserver
damiano@2081
   281
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
damiano@2081
   282
# Example:
damiano@2081
   283
#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
damiano@3201
   284
EXTRA_MACROS=
damiano@3201
   285
damiano@3201
   286
damiano@3201
   287
######### Misc #########
damiano@3580
   288
# FIXME Maybe include these variables here.
damiano@3580
   289
# Check how they are used throughout the project before setting them here
damiano@3580
   290
#LLDB_BIN
damiano@3580
   291
damiano@3202
   292
# Add this for running tests in debugger
damiano@3202
   293
#TEST_DEBUGGER=lldb --batch -o r
vb@2750
   294
damiano@3202
   295
# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
damiano@3202
   296
EXCLUDE=
damiano@3201
   297
damiano@3201
   298
damiano@3201
   299
######### Footer #########
damiano@3201
   300
-include $(HERE)/local.conf
damiano@3201
   301
damiano@3201
   302
ifdef BUILD_CONFIG
damiano@3201
   303
    include $(BUILD_CONFIG)
damiano@3201
   304
endif
damiano@3201
   305
krista@3428
   306
######### Post processing assignments ########
krista@3435
   307
# These variables are ineffective when set anywhere else but here.
krista@4701
   308
# KB: I have no idea why we do this - it totally defeats the purpose of
krista@4701
   309
#     local.conf.
krista@4701
   310
#     For now: set if has no value.
krista@3428
   311
ifeq ($(OPENPGP),SEQUOIA)
krista@4701
   312
ifeq ($(SEQUOIA_CFLAGS),)
krista@4701
   313
     SEQUOIA_CFLAGS=$(shell pkg-config --cflags-only-other sequoia-openpgp)
krista@4701
   314
endif
krista@4701
   315
ifeq ($(SEQUOIA_LDFLAGS),)
krista@4701
   316
     SEQUOIA_LDFLAGS=$(shell pkg-config --libs-only-l --libs-only-other sequoia-openpgp)
krista@4701
   317
endif
krista@4701
   318
ifeq ($(SEQUOIA_LIB),)
krista@4701
   319
     SEQUOIA_LIB=$(shell pkg-config --libs-only-L sequoia-openpgp)
krista@4701
   320
endif
krista@4701
   321
ifeq ($(SEQUOIA_INC),)
krista@4701
   322
     SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
krista@4701
   323
endif
krista@4701
   324
     CFLAGS+= $(SEQUOIA_CFLAGS)
krista@4701
   325
     LD_FLAGS+= $(SEQUOIA_LDFLAGS)
krista@3428
   326
endif
krista@3428
   327
damiano@3201
   328
# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
damiano@3201
   329
export YML_PATH=$(YML2_PATH)