Makefile.conf
author Damiano Boppart <damiano.boppart@pep.security>
Wed, 23 Jan 2019 15:31:29 +0100
branchmake-cleanup
changeset 3237 574cba8e448f
parent 3236 efb3aff10882
child 3284 57fda9f58f7c
permissions -rw-r--r--
Only call pkg-config when actually linking sequoia
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
damiano@2081
   201
######### sqlite3 #########
damiano@2081
   202
# If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
damiano@2081
   203
# Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
damiano@3201
   204
SQLITE3_FROM_OS=placeholder
damiano@2081
   205
damiano@2081
   206
damiano@2081
   207
######### OpenPGP #########
damiano@2081
   208
# Path of GPG binary
damiano@2163
   209
# 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
   210
GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
damiano@2081
   211
damiano@3237
   212
# Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
damiano@3201
   213
OPENPGP=GPG
damiano@2081
   214
damiano@3236
   215
# Sequoia-specific variables
damiano@3237
   216
ifeq ($(OPENPGP),SEQUOIA)
damiano@3237
   217
    SEQUOIA_CFLAGS:=$(shell pkg-config --cflags-only-other sequoia)
damiano@3237
   218
    SEQUOIA_LDFLAGS:=$(shell pkg-config --libs-only-L --libs-only-other sequoia)
damiano@3237
   219
    SEQUOIA_LIB:=$(shell pkg-config --libs-only-l sequoia)
damiano@3237
   220
    SEQUOIA_INC:=$(shell pkg-config --cflags-only-I sequoia)
damiano@3237
   221
endif
damiano@3236
   222
damiano@3201
   223
# libGPGME filename
damiano@3202
   224
ifeq ($(OPENPGP),GPG)
damiano@3202
   225
    ifeq ($(BUILD_FOR),Linux)
damiano@3202
   226
        LIBGPGME=libgpgme.so.11
damiano@3202
   227
    else ifeq ($(BUILD_FOR),Darwin)
damiano@3202
   228
        LIBGPGME=libgpgme.11.dylib
damiano@3202
   229
    endif
damiano@3201
   230
endif
damiano@2081
   231
damiano@2081
   232
# libGPGME library search flag
damiano@3201
   233
GPGME_LIB=
damiano@3201
   234
#GPGME_LIB=-L$(HOME)/lib
damiano@2081
   235
damiano@2081
   236
# libGPGME include search flag
damiano@3201
   237
GPGME_INC=
damiano@3201
   238
#GPGME_INC=-I$(HOME)/include
damiano@2081
   239
damiano@2081
   240
# NETPGP library search flag
damiano@3201
   241
NETPGP_LIB=
damiano@3202
   242
#NETPGP_LIB=-L$(HOME)/lib
damiano@2081
   243
damiano@2081
   244
# libGPGME include search flag
damiano@3201
   245
NETPGP_INC=
damiano@3202
   246
#NETPGP_INC=-I$(HOME)/include
damiano@2081
   247
damiano@2081
   248
damiano@3201
   249
######### CppUnit #########
damiano@3201
   250
# CppUnit library search flag
damiano@3201
   251
CPPUNIT_LIB=
damiano@3201
   252
#CPPUNIT_LIB=-L$(HOME)/local/lib
damiano@3201
   253
damiano@3201
   254
# CppUnit include search flag
damiano@3201
   255
CPPUNIT_INC=
damiano@3201
   256
#CPPUNIT_INC=-I$(HOME)/local/inc
damiano@3201
   257
damiano@3201
   258
damiano@2081
   259
######### Engine internals #########
damiano@2081
   260
# C macros (not environment variables) that can be overridden:
damiano@2081
   261
# DEFAULT_KEYSERVER - string with default keyserver
damiano@2081
   262
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
damiano@2081
   263
# Example:
damiano@2081
   264
#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
damiano@3201
   265
EXTRA_MACROS=
damiano@3201
   266
damiano@3201
   267
damiano@3201
   268
######### Misc #########
damiano@3202
   269
# Add this for running tests in debugger
damiano@3202
   270
#TEST_DEBUGGER=lldb --batch -o r
vb@2750
   271
damiano@3202
   272
# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
damiano@3202
   273
EXCLUDE=
damiano@3201
   274
damiano@3201
   275
damiano@3201
   276
######### Footer #########
damiano@3201
   277
-include $(HERE)/local.conf
damiano@3201
   278
damiano@3201
   279
ifdef BUILD_CONFIG
damiano@3201
   280
    include $(BUILD_CONFIG)
damiano@3201
   281
endif
damiano@3201
   282
damiano@3201
   283
# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
damiano@3201
   284
export YML_PATH=$(YML2_PATH)