From e858e82744aa1ae81fa8fb63461f874ff6f406ca Mon Sep 17 00:00:00 2001 From: Damiano Boppart Date: Thu, 26 Oct 2017 15:43:22 +0200 Subject: [PATCH] Add default.conf into the build system --- Makefile | 2 +- asn.1/Makefile | 2 +- db/Makefile | 2 +- default.conf | 260 ++++++++++++++++++++++++++++++++++++++++++++ doc/build-debian.md | 2 + doc/build-macos.md | 2 + src/Makefile | 2 +- sync/Makefile | 2 +- test/Makefile | 2 +- 9 files changed, 270 insertions(+), 6 deletions(-) create mode 100644 default.conf diff --git a/Makefile b/Makefile index d9eaba0b..a54a09fe 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ HERE_REL := $(notdir $(CURDIR)) -include Makefile.conf +include default.conf .PHONY: all all: _override_info diff --git a/asn.1/Makefile b/asn.1/Makefile index 47ece249..800c50eb 100644 --- a/asn.1/Makefile +++ b/asn.1/Makefile @@ -3,7 +3,7 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -include ../Makefile.conf +include ../default.conf ALL_SOURCE=$(wildcard *.c) ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE)) diff --git a/db/Makefile b/db/Makefile index 962d9115..b8b71d1c 100644 --- a/db/Makefile +++ b/db/Makefile @@ -3,7 +3,7 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -include ../Makefile.conf +include ../default.conf .PHONY: db db: system.db diff --git a/default.conf b/default.conf new file mode 100644 index 00000000..8b5f86b6 --- /dev/null +++ b/default.conf @@ -0,0 +1,260 @@ +# 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 + +# This file gives an overview over all the parameters that can be easily customized for a build. +# There are three ways in which you can customize your build: +# 1) Edit the variable assignments in this file +# 2) Create `local.conf` and fill it with variable assignments. +# These `local.conf` takes precedence over the assignments below. +# 3) Set the environment variable `BUILD_CONFIG` to an absolute path. +# The variable assignments found at the path indicated by `BUILD_CONFIG` take precedence over the assignments below and the assignments in `local.conf`. +# If nothing is changed according to these 3 methods, a default configuration for your platform 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) + +# Installation path for system.db +SYSTEM_DB=/usr/local/share/pEp/system.db + +# 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 in your local.conf file. +DEBUG=YES + +# If empty, suppress compiler warnings. +# Otherwise, print warnings. +# This variable is ineffective in your local.conf file. +WARN=placeholder + + +######### C and C++ ######### +TARGET_ARCH= +# The following two variables will be appended to. +# You can thus not set them to a 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 + +LDLIBS= + + +######### C ######### +ifeq ($(BUILD_FOR),Linux) + CC=gcc -std=c99 -pthread +else ifeq ($(BUILD_FOR),Darwin) + # clang issues a warning when "-pthread" is used for linking. + # So, include it in CFLAGS, and not in CC + CC=clang -std=c99 +endif + +ifeq ($(BUILD_FOR),Linux) + CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always +else ifeq ($(BUILD_FOR),Darwin) + CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics +endif + +CPPFLAGS= + +# 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+= -Og -ggdb -DDEBUG_ERRORSTACK + else + CFLAGS+= -O3 -DNDEBUG + endif +else ifeq ($(BUILD_FOR),Darwin) + ifdef WARN + # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed. + CFLAGS+= -Wall -pedantic -Wno-extended-offsetof + 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. + CFLAGS_GENERATED=-D_DEFAULT_SOURCE +else ifeq ($(BUILD_FOR),Darwin) + CFLAGS_GENERATED= +endif + + +######### C++ ######### +ifeq ($(BUILD_FOR),Linux) + CXX=g++ -std=gnu++11 -pthread +else ifeq ($(BUILD_FOR),Darwin) + # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX + CXX=clang -std=c++11 +endif + +# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests. +# The tests do not work properly, if compiled with -DNDEBUG +ifeq ($(BUILD_FOR),Linux) + CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC) + ifdef WARN + CXXFLAGS+= + else + CXXFLAGS+= -w + endif + ifdef DEBUG + CXXFLAGS+= -Og -ggdb + else + CXXFLAGS+= -O3 -DNDEBUG + endif +else ifeq ($(BUILD_FOR),Darwin) + CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC) + ifdef WARN + CXXFLAGS+= + else + CXXFLAGS+= -w + endif + ifdef DEBUG + CXXFLAGS+= -O0 -g + else + CXXFLAGS+= -O3 -DNDEBUG + endif +endif + + +######### YML2 ######### +YML2_PATH=$(HOME)/yml2 + +YML2_PROC=$(YML2_PATH)/yml2proc + +YML2_OPTS=--encoding=utf8 + +# YML_PATH is needed in the environment of every call to a program of the YML2 distribution +export YML_PATH=$(YML2_PATH) + +######### asn1c ######### +# asn1c binary +ASN1C=asn1c + +# asn1c include search flag +ASN1C_INC= +#ASN1C_INC=-I$(HOME)/include + + +######### libetpan ######### +# libetpan library search flag +ETPAN_LIB=-L$(PREFIX)/lib + +# libetpan include search flag +ETPAN_INC=-I$(PREFIX)/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 + + +######### OpenPGP ######### +# Path of GPG binary +# 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. +GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }') + +# Selects OpenPGP implementation. must be either `GPG` or `NETPGP` +OPENPGP=GPG + +# Path of libGPGME binary +ifeq ($(BUILD_FOR),Linux) + LIBGPGME=libgpgme.so.11 +else ifeq ($(BUILD_FOR),Darwin) + LIBGPGME=libgpgme.dylib +endif + +# libGPGME library search flag +ifeq ($(BUILD_FOR),Linux) + GPGME_LIB= +else ifeq ($(BUILD_FOR),Darwin) + GPGME_LIB=-L$(HOME)/lib +endif + +# libGPGME include search flag +ifeq ($(BUILD_FOR),Linux) + GPGME_INC= +else ifeq ($(BUILD_FOR),Darwin) + GPGME_INC=-I$(HOME)/include +endif + +# NETPGP library search flag +NETPGP_LIB= +#NETPGP_LIB=-L$(PREFIX)/lib + +# libGPGME include search flag +NETPGP_INC= +#NETPGP_INC=-I$(PREFIX)/include + + +######### 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 + + +######### Footer ######### +include $(HERE)/Makefile.conf + +-include $(HERE)/local.conf + +ifdef BUILD_CONFIG + include $(BUILD_CONFIG) +endif diff --git a/doc/build-debian.md b/doc/build-debian.md index 91244915..62e3138d 100644 --- a/doc/build-debian.md +++ b/doc/build-debian.md @@ -66,6 +66,8 @@ mkdir ~/code/pep-engine/build Note: Everything PLATFORM_OVERRIDE-related is currenty outdated. Do not rely on the documentation here! +Note: Everything Makefile.conf-related is currenty outdated. Do not rely on the documentation here! + For an explanation of the mechanics of `PLATFORM_OVERRIDE`, see the inline comments in `Makefile.conf`. In this guide, the platform-specific configuration will be called `local`. The installation directory will be a subdirectory of the repository. diff --git a/doc/build-macos.md b/doc/build-macos.md index f042a68b..3661599b 100644 --- a/doc/build-macos.md +++ b/doc/build-macos.md @@ -78,6 +78,8 @@ mkdir ~/code/pep-engine/build Note: Everything PLATFORM_OVERRIDE-related is currenty outdated. Do not rely on the documentation here! +Note: Everything Makefile.conf-related is currenty outdated. Do not rely on the documentation here! + For an explanation of the mechanics of `PLATFORM_OVERRIDE`, see the inline comments in `Makefile.conf`. In this guide, the platform-specific configuration will be called `local`. The installation directory will be a subdirectory of the repository. diff --git a/src/Makefile b/src/Makefile index aac8638b..6a1638eb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,7 +3,7 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -include ../Makefile.conf +include ../default.conf CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS) LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared diff --git a/sync/Makefile b/sync/Makefile index 812eb2f8..d4f8021e 100644 --- a/sync/Makefile +++ b/sync/Makefile @@ -3,7 +3,7 @@ # This file may be used under the terms of the GNU General Public License version 3 # see LICENSE.txt -include ../Makefile.conf +include ../default.conf .PHONY: all all: .codegen diff --git a/test/Makefile b/test/Makefile index 352f7409..a30ea97f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,7 @@ HERE:=$(CURDIR) -include ../Makefile.conf +include ../default.conf TARGET=pEpEngineTest