Makefile.conf
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 22 Jun 2020 23:46:21 +0200
changeset 4757 f5f8da7627e9
parent 4700 8d404d15701f
child 4730 a47eadde1552
child 4785 08d521da5611
permissions -rw-r--r--
Merged in ENGINE-757
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 #########
krista@4471
   230
# Selects OpenPGP implementation. must be `SEQUOIA`
krista@4471
   231
OPENPGP=SEQUOIA
damiano@2081
   232
damiano@3236
   233
# Sequoia-specific variables
krista@3428
   234
SEQUOIA_CFLAGS=
krista@3428
   235
SEQUOIA_LDFLAGS=
krista@3428
   236
SEQUOIA_LIB=
krista@3428
   237
SEQUOIA_INC=
damiano@3236
   238
damiano@2081
   239
######### Engine internals #########
damiano@2081
   240
# C macros (not environment variables) that can be overridden:
damiano@2081
   241
# DEFAULT_KEYSERVER - string with default keyserver
damiano@2081
   242
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
damiano@2081
   243
# Example:
damiano@2081
   244
#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
damiano@3201
   245
EXTRA_MACROS=
damiano@3201
   246
damiano@3201
   247
damiano@3201
   248
######### Misc #########
damiano@3580
   249
# FIXME Maybe include these variables here.
damiano@3580
   250
# Check how they are used throughout the project before setting them here
damiano@3580
   251
#LLDB_BIN
damiano@3580
   252
damiano@3202
   253
# Add this for running tests in debugger
damiano@3202
   254
#TEST_DEBUGGER=lldb --batch -o r
vb@2750
   255
damiano@3202
   256
# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
damiano@3202
   257
EXCLUDE=
damiano@3201
   258
damiano@3201
   259
damiano@3201
   260
######### Footer #########
damiano@3201
   261
-include $(HERE)/local.conf
damiano@3201
   262
damiano@3201
   263
ifdef BUILD_CONFIG
damiano@3201
   264
    include $(BUILD_CONFIG)
damiano@3201
   265
endif
damiano@3201
   266
krista@3428
   267
######### Post processing assignments ########
krista@3435
   268
# These variables are ineffective when set anywhere else but here.
krista@4700
   269
# KB: I have no idea why we do this - it totally defeats the purpose of
krista@4700
   270
#     local.conf.
krista@4700
   271
#     For now: set if has no value.
krista@3428
   272
ifeq ($(OPENPGP),SEQUOIA)
krista@4700
   273
ifeq ($(SEQUOIA_CFLAGS),)
krista@3428
   274
    SEQUOIA_CFLAGS=$(shell pkg-config --cflags-only-other sequoia-openpgp)
krista@4700
   275
endif
krista@4700
   276
ifeq ($(SEQUOIA_LDFLAGS),)
krista@3428
   277
    SEQUOIA_LDFLAGS=$(shell pkg-config --libs-only-l --libs-only-other sequoia-openpgp)
krista@4700
   278
endif
krista@4700
   279
ifeq ($(SEQUOIA_LIB),)
krista@3428
   280
    SEQUOIA_LIB=$(shell pkg-config --libs-only-L sequoia-openpgp)
krista@4700
   281
endif
krista@4700
   282
ifeq ($(SEQUOIA_INC),)
krista@3428
   283
    SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
krista@4700
   284
endif
krista@3428
   285
    CFLAGS+= $(SEQUOIA_CFLAGS)
krista@3428
   286
    LD_FLAGS+= $(SEQUOIA_LDFLAGS)
krista@3428
   287
endif
krista@3428
   288
damiano@3201
   289
# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
damiano@3201
   290
export YML_PATH=$(YML2_PATH)