ENGINE-864: Cleanup, plus fixed some semantics regarding CFLAGS/CXXFLAGS/CPPFLAGS that had been built in to the build system.

ENGINE-864
Krista Bennett 2021-02-03 10:18:19 +01:00
parent 08910435a3
commit 4cc0e3a5af
5 changed files with 88 additions and 88 deletions

View File

@ -67,26 +67,6 @@ DEBUG=placeholder
WARN=placeholder
######### MIME #########
# This is before the C/C++ stuff because pEpMIME runs on a different
# C++ version than we'd like for the moment and we need to set it conditionally
######### pEp MIME #########
PEP_MIME=0
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
######### C and C++ #########
TARGET_ARCH=
@ -99,22 +79,23 @@ else ifeq ($(BUILD_FOR),Darwin)
LDFLAGS+=-bind_at_load
endif
# Are we wiping this on purpose?
LDLIBS=
######### C #########
ifeq ($(BUILD_FOR),Linux)
CC=gcc -std=c99 -pthread
CC=gcc
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
CC=clang
endif
CFLAGS+=-std=c99 -pthread
CFLAGS+=-fPIC -fstrict-aliasing
ifeq ($(BUILD_FOR),Linux)
CFLAGS+=-fPIC -fstrict-aliasing -fdiagnostics-color=auto
CFLAGS+=-fdiagnostics-color=auto
else ifeq ($(BUILD_FOR),Darwin)
CFLAGS+=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
CFLAGS+=-fcolor-diagnostics
endif
# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
@ -150,33 +131,26 @@ ifeq ($(BUILD_FOR),Linux)
# 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
CPPFLAGS_GENERATED=-D_DEFAULT_SOURCE
else ifeq ($(BUILD_FOR),Darwin)
CFLAGS_GENERATED=
CPPFLAGS_GENERATED=
endif
######### C++ #########
ifeq ($(BUILD_FOR),Linux)
ifndef PEP_MIME
CXX=g++ -std=gnu++11 -pthread
else
CXX=g++ -std=gnu++14 -pthread
endif
CXX=g++
CXXFLAGS+=-std=gnu++11
else ifeq ($(BUILD_FOR),Darwin)
ifndef PEP_MIME
# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
CXX=clang -std=c++11
else
# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
CXX=clang -std=c++14
endif
CXX=clang
CXXFLAGS+=-std=c++11
endif
# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
CXXFLAGS+=-pthread
# The flag -DNDEBUG will always be removed from CPPFLAGS for compiling tests.
#
# The tests do not work properly, if compiled with -DNDEBUG
# FIXME: -D flags traditionally go in CPPFLAGS, as they're preprocessor defines. We need to clean
# this up in the whole build system.
ifeq ($(BUILD_FOR),Linux)
CXXFLAGS+=-fdiagnostics-color=auto -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
@ -187,10 +161,11 @@ ifeq ($(BUILD_FOR),Linux)
ifdef DEBUG
CXXFLAGS+= -g -ggdb
else
CXXFLAGS+= -O3 -DNDEBUG
CXXFLAGS+= -O3
CPPFLAGS+= -DNDEBUG
endif
else ifeq ($(BUILD_FOR),Darwin)
CXXFLAGS+=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
CXXFLAGS+=-fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
@ -199,13 +174,11 @@ else ifeq ($(BUILD_FOR),Darwin)
ifdef DEBUG
CXXFLAGS+= -O0 -g
else
CXXFLAGS+= -O3 -DNDEBUG
CXXFLAGS+= -O3
CPPFLAGS+= -DNDEBUG
endif
endif
ifdef PEP_MIME
CXXFLAGS+=-fPIC -fvisibility=hidden
endif
######### C and C++ #########
ifeq ($(BUILD_FOR),Darwin)
@ -233,12 +206,36 @@ ASN1C=asn1c
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
@ -271,6 +268,10 @@ EXCLUDE=
######### Footer #########
################################
# Include local.conf for any overrides and additional flags
################################
-include $(HERE)/local.conf
ifdef BUILD_CONFIG
@ -278,10 +279,9 @@ ifdef BUILD_CONFIG
endif
######### Post processing assignments ########
# These variables are ineffective when set anywhere else but here.
# KB: I have no idea why we do this - it totally defeats the purpose of
# local.conf.
# For now: set if has no value.
# 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)
@ -296,12 +296,18 @@ 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")

View File

@ -5,7 +5,7 @@ include ../Makefile.conf
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
CPPFLAGS+=$(CFLAGS_GENERATED)
CPPFLAGS+=$(CPPFLAGS_GENERATED)
ASN1C_INC+= -I.
.PHONY: all clean install uninstall

View File

@ -37,17 +37,29 @@ else
SED=sed -i
endif
######################################################################
#
# libpEpMIME can be built as a separate library in its own repository.
#
# However, it is dependent on the engine, which obviously does not
# work within the engine, as the engine is dependent upon IT.
# Because header files within the engine are local and not defined
# to exist in some installed library under pEp/header_file.h, we simply
# copy them into this directory and build/modify them as needed.
#
######################################################################
# Repo source
PEPMIME_SRC_FILES:= $(wildcard $(PEP_MIME_SRC)/*.cc) $(wildcard $(PEP_MIME_SRC)/*.hh) $(wildcard $(PEP_MIME_SRC)/*.hxx)
# Stripped filenames
LOCAL_PEPMIME_SRC:= $(subst $(PEP_MIME_SRC)/,,$(PEPMIME_SRC_FILES))
#$(error $(PEP_MIME_SRC) BOB $(PEPMIME_SRC_FILES) ******************** $(LOCAL_PEPMIME_SRC))
all: lib
lib: mimesrc libpEpMIME.a
mimesrc: ${LOCAL_PEPMIME_SRC}
# Copy the files to the local directory and change their engine header references to quoted references
%.hh : $(PEP_MIME_SRC)/%.hh
cp -p $< $@
$(SED) 's/#include <pEp\/\(.*\)>/#include "..\/src\/\1"/g' $@

View File

@ -31,14 +31,14 @@ LDLIBS+= -lc -lasn1
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)
CFLAGS+= -DSQLITE_THREADSAFE=1
CPPFLAGS+= -DSQLITE_THREADSAFE=1
LDLIBS+= -lz -liconv -mmacosx-version-min=10.10
else
$(error I do not know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else ifeq ($(BUILD_ON),Linux)
ifeq ($(BUILD_FOR),Linux)
CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
CPPFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
LDLIBS+= -ldl -luuid
else
$(error I do not know how to make for $(BUILD_FOR) on $(BUILD_ON))
@ -49,12 +49,13 @@ endif
ifdef SQLITE3_FROM_OS
NO_SOURCE+= sqlite3.c
CFLAGS+= -DSQLITE3_FROM_OS
CPPFLAGS+= -DSQLITE3_FROM_OS
LDLIBS+= -lsqlite3
endif
ifeq ($(OPENPGP),SEQUOIA)
CFLAGS+= -DUSE_SEQUOIA $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
CPPFLAGS+= -DUSE_SEQUOIA
CFLAGS+= $(SEQUOIA_CFLAGS) $(SEQUOIA_INC)
LDFLAGS+= $(SEQUOIA_LDFLAGS)
LDLIBS+= $(SEQUOIA_LIB)
else
@ -81,7 +82,7 @@ ifneq ($(MAKECMDGOALS),clean)
endif
$(TARGET): libpEpEngine.a
$(CC) $(CFLAGS) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
$(CC) $(CPPFLAGS) $(CFLAGS) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
.PHONY: objects clean install_headers install uninstall beinstall
@ -96,7 +97,7 @@ clean:
rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.* distribution_codec.*
# CAVEAT:
# install_headers is needed for building pEp MIME
# install_headers is needed for building *STANDALONE* pEp MIME - it is NOT used for built-in functionality!!!
install_headers: $(TARGET)
mkdir -p $(PREFIX)/include/pEp
@ -107,6 +108,7 @@ install_headers: $(TARGET)
status_to_string.h aux_mime_msg.h keyreset_command.h platform.h platform_unix.h ../asn.1/*.h \
$(PREFIX)/include/pEp/
# FIXME: Does anyone but Roker use install_headers? Otherwise, remove the dependency.
install: $(TARGET) install_headers
mkdir -p "$(PREFIX)/lib/"
cp -v $< $(PREFIX)/lib/

View File

@ -26,7 +26,7 @@ ifeq ($(shell grep -c $(GTEST_SUITE_SYM) $(GTEST_SRC_DIR)/src/gtest.cc),0)
GTEST_SUITE_SYM=test_case_name
endif
CXXFLAGS+= -DGTEST_SUITE_SYM=$(GTEST_SUITE_SYM)
CPPFLAGS+= -DGTEST_SUITE_SYM=$(GTEST_SUITE_SYM)
ifeq ($(OPENPGP),GPG)
LDFLAGS+= $(GPGME_LIB)
@ -49,7 +49,8 @@ endif
ifeq ($(OPENPGP),SEQUOIA)
LDFLAGS+= $(SEQUOIA_LDFLAGS)
LDLIBS+= $(SEQUOIA_LIB)
CXXFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
CXXFLAGS+= $(SEQUOIA_CFLAGS)
CPPFLAGS+= -DUSE_SEQUOIA
INC_FLAGS+= $(SEQUOIA_INC)
endif
@ -57,26 +58,12 @@ ifdef SQLITE3_FROM_OS
LDLIBS+= -lsqlite3
endif
ifeq ($(OPENPGP),GPG)
#LDLIBS+= -lgpgme
else ifeq ($(OPENPGP),NETPGP)
LDLIBS+= -lnetpgp
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -ltre
endif
endif
CXXFLAGS:=-I$(GTEST_INC_DIR) $(filter-out -DNDEBUG,$(CXXFLAGS))
CPPFLAGS:=$(filter-out -DNDEBUG,$(CPPFLAGS))
# FIXME Possibly missing incdirs: ASN1C_INC
CXXFLAGS+= -I./src -I../src -I ../asn.1 -I../sync $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
ifeq ($(OPENPGP),GPG)
CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
else ifeq ($(OPENPGP),NETPGP)
CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
endif
EXTRA_LIB_PATHS=.:../src:
ifndef PEP_MIME
ifdef ETPAN_LIB
@ -84,13 +71,6 @@ ifdef ETPAN_LIB
endif
endif
ifdef GPGME_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
endif
ifdef NETPGP_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
endif
# Remove trailing ':'
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
@ -114,7 +94,7 @@ all:
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
$(TARGET): $(OBJS)
${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ -lpEpEngine -lgtest -lgtest_main -lsequoia_openpgp_ffi $(LDLIBS)
${CXX} ${CPPFLAGS} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ -lpEpEngine -lgtest -lgtest_main -lsequoia_openpgp_ffi $(LDLIBS)
test: all