Browse Source

ENGINE-864: pEpMIME Makefile madness

mime-integrate
Krista Bennett 9 months ago
parent
commit
9130f81042
6 changed files with 178 additions and 27 deletions
  1. +3
    -0
      .gitignore
  2. +13
    -3
      Makefile
  3. +37
    -23
      Makefile.conf
  4. +86
    -0
      pEpMIME/Makefile
  5. +38
    -0
      pEpMIME/README.md
  6. +1
    -1
      test/Makefile

+ 3
- 0
.gitignore View File

@ -87,6 +87,9 @@ test/EngineTests
test/googletest
test/tmp/*
.idea/
pEpMIME/*.hh
pEpMIME/*.cc
pEpMIME/*.hxx
# ignore generated test data


+ 13
- 3
Makefile View File

@ -19,17 +19,24 @@ ifdef BUILD_CONFIG
$(info ================================================)
endif
.PHONY: all pepmime sync asn1 build install dbinstall uninstall clean tags test package db
BUILT_IN_MIME=
build: pepmime asn1
ifdef PEP_MIME
BUILT_IN_MIME=pepmime
endif
.PHONY: all $(BUILT_IN_MIME) sync asn1 build install dbinstall uninstall clean tags test package db
build: $(BUILT_IN_MIME) asn1
$(MAKE) -C src
all: build
# `make all` is not for tests, that's what `make test` is for
# $(MAKE) -C test
pepmime:
pepmime:
$(MAKE) -C pEpMIME lib
sync:
$(MAKE) -C sync
@ -59,6 +66,9 @@ clean:
$(MAKE) -C asn.1 clean
$(MAKE) -C sync clean
$(MAKE) -C build-android clean
ifdef PEP_MIME
$(MAKE) -C pEpMIME clean
endif
tags:
$(MAKE) -C asn.1 tags


+ 37
- 23
Makefile.conf View File

@ -67,6 +67,26 @@ 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 = 1
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=
@ -138,10 +158,19 @@ endif
######### C++ #########
ifeq ($(BUILD_FOR),Linux)
ifndef PEP_MIME
CXX=g++ -std=gnu++11 -pthread
else
CXX=g++ -std=gnu++14 -pthread
endif
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
endif
# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
@ -172,6 +201,9 @@ else ifeq ($(BUILD_FOR),Darwin)
endif
endif
ifdef PEP_MIME
CXXFLAGS+=-fPIC -fvisibility=hidden
endif
######### C and C++ #########
ifeq ($(BUILD_FOR),Darwin)
@ -199,26 +231,6 @@ ASN1C=asn1c
ASN1C_INC=
#ASN1C_INC=-I$(HOME)/include
######### pEp MIME #########
PEP_MIME = 1
PEP_MIME_SRC=$(HOME)/src/pEpMIME/src
CPPFLAGS=-DPEP_BUILTIN_MIME
CXXFLAGS=-DPEP_BUILTIN_MIME
LDLIBS+=-lstdc++
######### libetpan #########
# libetpan library search flag
#
ETPAN_LIB=
#ETPAN_LIB=-L$(HOME)/lib
# libetpan include search flag
ETPAN_INC=
#ETPAN_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.
@ -292,11 +304,13 @@ 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
$(shell mkdir -p pEpMIME)
$(shell cp $(PEP_MIME_SRC)/*.{cc,hh,hxx} $(HERE)/pEpMIME)
$(shell cp $(PEP_MIME_SRC)/Makefile $(HERE)/pEpMIME)
CPPFLAGS=-DPEP_BUILTIN_MIME
CXXFLAGS=-DPEP_BUILTIN_MIME
LDLIBS+=-lstdc++
ETPAN_LIB=
ETPAN_INC=
# $(shell cp $(PEP_MIME_SRC)/*.{cc,hh,hxx} $(HERE)/pEpMIME)
# $(shell sed -i '' 's/#include <pep\/\(.*\)>/#include "..\/src\/\1"/g' $(HERE)/pEpMIME/*.{hh,hxx,cc})
endif
else
endif


+ 86
- 0
pEpMIME/Makefile View File

@ -0,0 +1,86 @@
# This file is under GNU General Public License 3.0
# see LICENSE.txt
##################################################################################
# This is a modified Makefile based on that in the libpEpMIME repository.
# THEY ARE NOT INTERCHANGEABLE. This is SPECIFICALLY for the pEp engine and
# is only for the built-in variant of the compiler.
#
# Note that this is the only supported way of including pEpMIME within the engine.
#
# If additional object files are added to the repository object requirements, they
# will have to be included here specifically.
##################################################################################
.PHONY: mimesrc lib all clean install test
include ../Makefile.conf
######### General #########
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
# MacOS needs -liconv, Linix don't.
ifeq ($(BUILD_FOR),Darwin)
LDLIBS+= -liconv
endif
PEPMIME_SRC_FILES:= $(wildcard $(PEP_MIME_SRC)/*.cc) $(wildcard $(PEP_MIME_SRC)/*.hh) $(wildcard $(PEP_MIME_SRC)/*.hxx)
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}
%.hh : $(PEP_MIME_SRC)/%.hh
cp -p $< $@
sed -i '' 's/#include <pEp\/\(.*\)>/#include "..\/src\/\1"/g' $@
%.cc : $(PEP_MIME_SRC)/%.cc
cp -p $< $@
sed -i '' 's/#include <pEp\/\(.*\)>/#include "..\/src\/\1"/g' $@
%.hxx : $(PEP_MIME_SRC)/%.hxx
cp -p $< $@
sed -i '' 's/#include <pEp\/\(.*\)>/#include "..\/src\/\1"/g' $@
LIB_OBJ=pEpMIME.o pEpMIME_internal.o rules.o bodyparser.o \
attachment.o bodygenerator.o \
headerparser.o parse_timestamp.o parse_address.o nulllogger.o \
base64.o nfc.o mime_headers.o nfc_sets.o to_utf8.o quoted_printable.o \
header_generator.o message.o pEpEngine_mime.o
libpEpMIME.a: $(LIB_OBJ)
${AR} rcs $@ $^
%.o : %.cc %.hh
${CXX} ${CXXFLAGS} -I${PREFIX}/include -o $@ -c $<
%.o : %.cc
${CXX} ${CXXFLAGS} -I${PREFIX}/include -o $@ -c $<
clean:
rm -vf *.o *.a
srcclean:
rm *.cc *.hh *.hxx
install: lib
mkdir -p "$(PREFIX)/lib/"
cp -v libpEpMIME.a $(PREFIX)/lib
uninstall:
rm $(PREFIX)/lib/libpEpMIME.a

+ 38
- 0
pEpMIME/README.md View File

@ -0,0 +1,38 @@
# Instructions and caveats for using pEpMIME as the built-in engine parser
## Makefile variables and local.conf
We copy the necessary files from the user's *separate* libpEpMIME repository
on the machine.
**Note: The Makefile in this directory is *different* from the libpEpMIME Makefile.**
**DO NOT REPLACE THE pEpEngine's pEpMIME Makefile with the one from the libpEpMIME repository. It won't work!**
Source files in this directory are local copies only and will be copied over if the repository is
updated. We post-process the source to change the "installed-header" requirements of the "separate"
(quotes intentional) library.
* PEP_MIME=1
* PEP_MIME_SRC=<your checked-out libpEpMIME repo's src directory>
## Known issues
On MacOS, the built-in standard BSD C library provides strlcat et al. **However**, for some weird reason, when
compiling the engine with pEpMIME, the compiler thinks strlcat is no longer defined, though everything links and runs
in the end.
If you see something like:
```
platform_unix.c:280:5: warning: implicitly declaring library function 'strlcat' with type 'unsigned long (char *, const char *, unsigned long)' [-Wimplicit-function-declaration]
strlcat(*first, second, size);
^
platform_unix.c:280:5: note: include the header <string.h> or explicitly provide a declaration for 'strlcat'
1 warning generated.
```
It doesn't seem to be an actual issue, and maybe it's a problem of compiling part of the engine with clang and part of it with clang++ and c++14, but anyway, watch out for it, and
don't complain to the engine team unless you figure out how to fix it ;)
## TODO
* git submodules would be a good way to handle our "copy this in because it really isn't a separate library" issue

+ 1
- 1
test/Makefile View File

@ -69,7 +69,7 @@ endif
CXXFLAGS:=-I$(GTEST_INC_DIR) $(filter-out -DNDEBUG,$(CXXFLAGS))
# FIXME Possibly missing incdirs: ASN1C_INC
CXXFLAGS+= -I./src -I../sync $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
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)


Loading…
Cancel
Save