You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pEpEngine/Makefile.conf

322 lines
9.0 KiB

# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
# See `doc/build-<your platform>.md` for documentation on how to build, and customize your build.
# This file sets all the make variables that allow you to customize a build.
# There are 3 ways in which you can customize your build:
# 1) Edit the variable assignments in this file (this is a tracked file, so your repository will be dirty)
# 2) Create `local.conf` and fill it with variable assignments.
# 3) Set the environment variable `BUILD_CONFIG` to an absolute path.
# The variable assignments found in the make file at the path indicated by `BUILD_CONFIG` will be evaluated.
# Customization options are applied in the order given above. Later variable assignments take precedence over earlier ones.
# It is possible to use multiple variants simultaniously.
# If nothing is changed according to these 3 methods, a default configuration for your platform (specified below) will be used for the build.
######### Header #########
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
######### General #########
# To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
# All the *_INC and *_LIB variables are command line flags, not paths.
# Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
BUILD_ON:=$(shell uname)
# This variable specifies the platform that the engine should be cross-compiled for.
BUILD_FOR=$(BUILD_ON)
# Cross-compiling is currently not supported.
# Maybe you can hack something with `local.conf`.
ifneq ($(BUILD_ON),$(BUILD_FOR))
$(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
endif
# Installation path prefix for libraries and binaries, except for system.db
PREFIX=$(HOME)
# pEp files and directories
#
# the PER_USER_DIRECTORY will be in $(HOME), respectively
# in debug builds the PER_USER_DIRECTORY will be in $(PEP_HOME) instead if set
#
# PER_MACHINE_DIRECTORY is calculated depending on platform; overwrite if
# necessary
#PER_USER_DIRECTORY=.pEp
PER_MACHINE_DIRECTORY=/usr/local/share/pEp
# Filename of the pEpEngine library
ifeq ($(BUILD_FOR),Linux)
TARGET=libpEpEngine.so
else ifeq ($(BUILD_FOR),Darwin)
TARGET=libpEpEngine.dylib
endif
# If empty, create a release build.
# Otherwise, create a debug build.
# This variable is ineffective when set anywhere else but here.
DEBUG=placeholder
# If empty, suppress compiler warnings.
# Otherwise, print warnings.
# This variable is ineffective when set anywhere else but here.
WARN=placeholder
######### C and C++ #########
TARGET_ARCH=
# The following two variables will be appended to.
# You can thus not set them to a final, fixed value here.
ifeq ($(BUILD_FOR),Linux)
LDFLAGS+=
else ifeq ($(BUILD_FOR),Darwin)
# "-bind_at_load" helps find symbol resolution errors faster
LDFLAGS+=-bind_at_load
endif
# Are we wiping this on purpose?
LDLIBS=
######### C #########
ifeq ($(BUILD_FOR),Linux)
CC=gcc
else ifeq ($(BUILD_FOR),Darwin)
CC=clang
endif
CFLAGS+=-std=c99 -pthread
CFLAGS+=-fPIC -fstrict-aliasing
ifeq ($(BUILD_FOR),Linux)
CFLAGS+=-fdiagnostics-color=auto
else ifeq ($(BUILD_FOR),Darwin)
CFLAGS+=-fcolor-diagnostics
endif
# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
# The tests do not work properly, if compiled with -DNDEBUG
ifeq ($(BUILD_FOR),Linux)
ifdef WARN
CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
else
CFLAGS+= -w
endif
ifdef DEBUG
CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
else
CFLAGS+= -O3 -DNDEBUG
endif
else ifeq ($(BUILD_FOR),Darwin)
ifdef WARN
CFLAGS+= -Wall -pedantic
else
CFLAGS+= -w
endif
ifdef DEBUG
CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
else
CFLAGS+= -O3 -DNDEBUG
endif
endif
# Additional CFLAGS used for compiling ASN1C-generated code
ifeq ($(BUILD_FOR),Linux)
# The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
# _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
# otherwise printed during the compilation of every asn1c-generated C file.
# It's a glibc specific warning, only present in few versions around ~2.19.
# See https://lwn.net/Articles/590381/ for a discussion.
CPPFLAGS_GENERATED=-D_DEFAULT_SOURCE
else ifeq ($(BUILD_FOR),Darwin)
CPPFLAGS_GENERATED=
endif
######### C++ #########
ifeq ($(BUILD_FOR),Linux)
CXX=g++
CXXFLAGS+=-std=gnu++11
else ifeq ($(BUILD_FOR),Darwin)
CXX=clang
CXXFLAGS+=-std=c++11
endif
CXXFLAGS+=-pthread
# The flag -DNDEBUG will always be removed from CPPFLAGS for compiling tests.
#
# The tests do not work properly, if compiled with -DNDEBUG
ifeq ($(BUILD_FOR),Linux)
CXXFLAGS+=-fdiagnostics-color=auto -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
CXXFLAGS+= -w
endif
ifdef DEBUG
CXXFLAGS+= -g -ggdb
else
CXXFLAGS+= -O3
CPPFLAGS+= -DNDEBUG
endif
else ifeq ($(BUILD_FOR),Darwin)
CXXFLAGS+=-fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
CXXFLAGS+= -w
endif
ifdef DEBUG
CXXFLAGS+= -O0 -g
else
CXXFLAGS+= -O3
CPPFLAGS+= -DNDEBUG
endif
endif
######### C and C++ #########
ifeq ($(BUILD_FOR),Darwin)
CPPFLAGS+=-D_DARWIN_C_SOURCE
LDLIBS+=-liconv
else
LDLIBS+=-luuid
endif
######### YML2 #########
YML2_PATH=$(HOME)/yml2
YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
YML2_OPTS=--encoding=utf8
######### asn1c #########
# asn1c binary
ASN1C=asn1c
# asn1c include search flag
ASN1C_INC=
#ASN1C_INC=-I$(HOME)/include
######### sqlite3 #########
# If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
# Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
SQLITE3_FROM_OS=placeholder
######### MIME #########
######### pEp MIME #########
# Set pEpMIME= anything (there are ifdefs on it) in your local.conf if you want
# to compile built-in pEpMIME (requires a separate libppEpMIME source repo to be
# checked out elsewhere on the system - define or redefine these in local.conf
# if you want to use it; otherwise, we default to etpan. (This will eventually
# become the default, but not yet.
#
PEP_MIME=
PEP_MIME_SRC=$(HOME)/src/pEpMIME/src
######### libetpan #########
# libetpan library search flag
#
ETPAN_LIB=
#ETPAN_LIB=-L$(HOME)/lib
# libetpan include search flag
ETPAN_INC=
#ETPAN_INC=-I$(HOME)/include
######### OpenPGP #########
# Selects OpenPGP implementation. must be `SEQUOIA`
OPENPGP=SEQUOIA
# Sequoia-specific variables
SEQUOIA_CFLAGS+=
SEQUOIA_LDFLAGS+=
SEQUOIA_LIB=
SEQUOIA_INC=
######### Engine internals #########
# C macros (not environment variables) that can be overridden:
# DEFAULT_KEYSERVER - string with default keyserver
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
# Example:
# EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
EXTRA_MACROS=
######### Misc #########
# FIXME Maybe include these variables here.
# Check how they are used throughout the project before setting them here
#LLDB_BIN
# Add this for running tests in debugger
#TEST_DEBUGGER=lldb --batch -o r
# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
EXCLUDE=
######### Footer #########
################################
# Include local.conf for any overrides and additional flags
################################
-include $(HERE)/local.conf
ifdef BUILD_CONFIG
include $(BUILD_CONFIG)
endif
######### Post processing assignments ########
# If sequoia has been set up and the SEQUOIA flags aren't defined, set them up.
# Otherwise, add them to the CFLAGS/CXXFLAGS/LDFLAGS and library/include variables
ifeq ($(OPENPGP),SEQUOIA)
ifeq ($(SEQUOIA_CFLAGS),)
SEQUOIA_CFLAGS+=$(shell pkg-config --cflags-only-other sequoia-openpgp)
endif
ifeq ($(SEQUOIA_LDFLAGS),)
SEQUOIA_LDFLAGS+=$(shell pkg-config --libs-only-l sequoia-openpgp)
endif
ifeq ($(SEQUOIA_LIB),)
SEQUOIA_LIB=$(shell pkg-config --libs-only-L --libs-only-other sequoia-openpgp)
endif
ifeq ($(SEQUOIA_INC),)
SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
endif
CFLAGS+= $(SEQUOIA_CFLAGS)
CXXFLAGS+= $(SEQUOIA_CFLAGS)
LD_FLAGS+= $(SEQUOIA_LDFLAGS)
endif
# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
export YML_PATH=$(YML2_PATH)
# Postprocess for pEpMIME
ifdef PEP_MIME
# Replace c++11 with c++14 for now (limiting the subst to the ++11 means it doesn't matter if gnu or not)
CXXFLAGS:=$(subst ++11,++14,$(CXXFLAGS)) -fPIC -fvisibility=hidden
endif
ifdef PEP_MIME
ifndef PEP_MIME_SRC
$(error "Compiling with the PEP_MIME option set requires the value of PEP_MIME_SRC to be set to the source directory for libpEpMIME")
else
CPPFLAGS+=-DPEP_BUILTIN_MIME
LDLIBS+=-lstdc++
ETPAN_LIB=
ETPAN_INC=
endif
endif