ENGINE-233: well, at least it doesn't seem to break things that already work...
1.1 --- a/.hgignore Thu Aug 24 11:30:35 2017 +0200
1.2 +++ b/.hgignore Mon Aug 28 11:29:31 2017 +0200
1.3 @@ -3,6 +3,7 @@
1.4 ^asn\.1/Makefile\.am\.sample$
1.5 ^asn\.1/libasn1\.a$
1.6 .*xcuserdata/
1.7 +^build/
1.8
1.9 syntax: glob
1.10 *.orig
2.1 --- a/Makefile Thu Aug 24 11:30:35 2017 +0200
2.2 +++ b/Makefile Mon Aug 28 11:29:31 2017 +0200
2.3 @@ -1,27 +1,33 @@
2.4 -# this file is under GNU General Public License v3.0
2.5 +# Copyright 2017, pEp Foundation
2.6 +# This file is part of pEpEngine
2.7 +# This file may be used under the terms of the GNU General Public License version 3
2.8 # see LICENSE.txt
2.9
2.10 +HERE_REL := $(notdir $(CURDIR))
2.11 +
2.12 include Makefile.conf
2.13
2.14 -# add it to the environment of all executed programs:
2.15 -export YML_PATH
2.16 +# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
2.17 +export YML_PATH=$(YML2_PATH)
2.18
2.19 -
2.20 -all:
2.21 +.PHONY: all
2.22 +all: _platform_override_info
2.23 $(MAKE) -C asn.1 generate
2.24 $(MAKE) -C asn.1
2.25 $(MAKE) -C sync
2.26 $(MAKE) -C src all
2.27
2.28 -.PHONY: clean build_test test package install uninstall db
2.29 -
2.30 +.PHONY: install
2.31 install: all
2.32 $(MAKE) -C src install
2.33 $(MAKE) -C asn.1 install
2.34
2.35 +.PHONY: uninstall
2.36 uninstall:
2.37 $(MAKE) -C src uninstall
2.38 + $(MAKE) -C asn.1 uninstall
2.39
2.40 +.PHONY: clean
2.41 clean:
2.42 $(MAKE) -C src clean
2.43 $(MAKE) -C test clean
2.44 @@ -29,26 +35,29 @@
2.45 $(MAKE) -C sync clean
2.46 $(MAKE) -C asn.1 clean
2.47
2.48 +.PHONY: test
2.49 test: all
2.50 $(MAKE) -C test test
2.51 $(MAKE) -C test unit_tests
2.52
2.53 +.PHONY: unit_tests
2.54 unit_tests: all
2.55 $(MAKE) -C test unit_tests
2.56
2.57 +.PHONY: package
2.58 package: clean
2.59 - cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 pEpEngine
2.60 + cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 "$(HERE_REL)"
2.61
2.62 +.PHONY: db
2.63 db:
2.64 $(MAKE) -C db db
2.65
2.66 -windist:
2.67 -ifneq ($(BUILD_FOR),Windoze)
2.68 - @echo use BUILD_FOR=Windoze \(did you forget -e ?\)
2.69 +.PHONY: _platform_override
2.70 +ifdef PLATFORM_OVERRIDE
2.71 +_platform_override_info:
2.72 + @echo "================================================"
2.73 + @echo "PLATFORM_OVERRIDE is set to '$(PLATFORM_OVERRIDE)'."
2.74 + @echo "================================================"
2.75 else
2.76 - make clean
2.77 - $(MAKE) all
2.78 - $(MAKE) -C test all
2.79 - zip -j pEpEngine-dist.zip src/pEpEngine.h src/keymanagement.h src/pEpEngine.dll src/pEpEngine.def test/pEpEngineTest.exe test/*.asc test/*.key db/*.db test/*.txt test/*.asc src/*.sql
2.80 +_platform_override_info:
2.81 endif
2.82 -
3.1 --- a/Makefile.conf Thu Aug 24 11:30:35 2017 +0200
3.2 +++ b/Makefile.conf Mon Aug 28 11:29:31 2017 +0200
3.3 @@ -1,30 +1,21 @@
3.4 -# this file is in the Public Domain
3.5 +# Copyright 2017, pEp Foundation
3.6 +# This file is part of pEpEngine
3.7 +# This file may be used under the terms of the GNU General Public License version 3
3.8 +# see LICENSE.txt
3.9 +
3.10 +# This file assembles all the make variables that a maintainer or dev may want to taylor to his or her needs on a given platform.
3.11 +
3.12 +# To use custom build configuration variables, put them in a new file with the path `build-config/<name>.conf`. Execute `export PLATFORM_OVERRIDE=<name>` before running make. If this environment variable is not set, make will load a default configuration for your platform.
3.13 +
3.14 +BUILD_CONFIG:=$(dir $(lastword $(MAKEFILE_LIST)))build-config
3.15
3.16 -BUILD_ON=$(shell uname)
3.17 -BUILD_FOR=$(BUILD_ON)
3.18 -OPTIMIZE=-g -Wall -O0 -fPIC -DDEBUG_ERRORSTACK
3.19 -#OPTIMIZE=-O3 -Wall -DNDEBUG -std=c99
3.20 -LD=$(CC)
3.21 -#CC=gcc-mp-4.9 -std=c99 -fstrict-aliasing -Wstrict-aliasing=3
3.22 -#LD=gcc-mp-4.9
3.23 -SYSTEM_DB=/usr/local/share/pEp/system.db
3.24 -PREFIX=$(HOME)
3.25 -YML2PROC=$(HOME)/yml2/yml2proc
3.26 -YML_OPTS=--encoding=utf8
3.27 -YML_PATH=$(HOME)/yml2
3.28 -ASN1C=asn1c
3.29 -ASN1C_INCLUDE=/opt/local/share/asn1c
3.30 -#ETPAN_IN=$(HOME)
3.31 -#LIBGPGME=/opt/local/lib/libgpgme.11.dylib
3.32 -
3.33 -# C makros (not environment variables) to overwrite:
3.34 -#
3.35 -# DEFAULT_KEYSERVER - string with default keyserver
3.36 -# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
3.37 -
3.38 -#EXTRAMACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
3.39 -
3.40 -# second instance for testing
3.41 -
3.42 -#EXTRAMACROS=-DLOCAL_DB_FILENAME=\".pEp_management2.db\"
3.43 -#TARGET=libpEpEngine2.dylib
3.44 +include $(BUILD_CONFIG)/common.conf
3.45 +# cross-compiling is currently not supported, but maybe you can hack something with `PLATFORM_OVERRIDE`
3.46 +ifeq ($(BUILD_ON),$(BUILD_FOR))
3.47 + include $(BUILD_CONFIG)/$(BUILD_ON).conf
3.48 +else
3.49 + $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON))
3.50 +endif
3.51 +ifdef PLATFORM_OVERRIDE
3.52 + include $(BUILD_CONFIG)/$(PLATFORM_OVERRIDE).conf
3.53 +endif
4.1 --- a/README.txt Thu Aug 24 11:30:35 2017 +0200
4.2 +++ b/README.txt Mon Aug 28 11:29:31 2017 +0200
4.3 @@ -60,8 +60,7 @@
4.4
4.5 * NetPGP/p≡p, see https://cacert.pep.foundation/dev/repos/netpgp-et/
4.6
4.7 -* Asn1c, download from https://lionet.info/soft/asn1c-0.9.27.tar.gz
4.8 - (Debian's version 0.9.24 does not work)
4.9 +* Asn1c, download from https://lionet.info/soft/asn1c-0.9.27.tar.gz . Debian 8's v0.9.24 does not work. Debian 9's v0.9.27 generates non-POSIX code, that will cause issues when the engine is compiled with '-std=c99'. Thus, use v0.9.28 for best results.
4.10
4.11 * yml2, which needs lxml (where to get?)
4.12
5.1 --- a/asn.1/Makefile Thu Aug 24 11:30:35 2017 +0200
5.2 +++ b/asn.1/Makefile Mon Aug 28 11:29:31 2017 +0200
5.3 @@ -1,37 +1,35 @@
5.4 -# This file is under GNU General Public License 3.0
5.5 +# Copyright 2017, pEp Foundation
5.6 +# This file is part of pEpEngine
5.7 +# This file may be used under the terms of the GNU General Public License version 3
5.8 # see LICENSE.txt
5.9
5.10 include ../Makefile.conf
5.11
5.12 -ifeq ($(BUILD_ON),Linux)
5.13 -ifeq ($(BUILD_FOR),Linux)
5.14 -
5.15 -CC=gcc
5.16 -CFLAGS?=-fPIC
5.17 -else
5.18 -$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
5.19 -endif
5.20 -endif
5.21 -
5.22 -ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
5.23 +ALL_SOURCE=$(wildcard *.c)
5.24 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
5.25
5.26 libasn1.a: $(ALL_OBJECTS)
5.27 - ar -rc $@ $(ALL_OBJECTS)
5.28 + ar -rc $@ $^
5.29
5.30 +# "converter-sample.c" is the example file containing a "main()" function generated by ans1c.
5.31 +.PHONY: generate
5.32 generate: Sync-Protocols.c
5.33 rm -f converter-sample.c
5.34
5.35 %.o: %.c %.h
5.36 - $(CC) $(CFLAGS) $(OPTIMIZE) -I. -I$(ASN1C_INCLUDE) -c $< -o $@
5.37 + $(CC) $(CFLAGS) $(CFLAGS_GENERATED) -I. $(ASN1C_INC) -c $< -o $@
5.38
5.39 -Sync-Protocols.c: protocols.asn1 devicegroup.asn1 pEp.asn1
5.40 - $(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 devicegroup.asn1 $<
5.41 +Sync-Protocols.c: pEp.asn1 devicegroup.asn1 protocols.asn1
5.42 + $(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message $^
5.43
5.44 .PHONY: clean
5.45 -
5.46 clean:
5.47 rm -f *.a *.o *.c *.h *.sample
5.48
5.49 +.PHONY: install
5.50 install: libasn1.a
5.51 cp $< $(PREFIX)/lib/
5.52 +
5.53 +.PHONY: uninstall
5.54 +uninstall:
5.55 + rm -f $(PREFIX)/lib/libasn1.a
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/build-config/Darwin.conf Mon Aug 28 11:29:31 2017 +0200
6.3 @@ -0,0 +1,58 @@
6.4 +# Copyright 2017, pEp Foundation
6.5 +# This file is part of pEpEngine
6.6 +# This file may be used under the terms of the GNU General Public License version 3
6.7 +# see LICENSE.txt
6.8 +
6.9 +######### General #########
6.10 +TARGET=libpEpEngine.dylib
6.11 +
6.12 +######### C #########
6.13 +# clang issues a warning when "-pthread" is used for linking. So, include it in CFLAGS, and not in CC
6.14 +CC=clang -std=c99
6.15 +CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
6.16 +ifdef WARN
6.17 + # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
6.18 + CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
6.19 +else
6.20 + CFLAGS+= -w
6.21 +endif
6.22 +ifdef DEBUG
6.23 + CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
6.24 +else
6.25 + CFLAGS+= -O3 -DNDEBUG
6.26 +endif
6.27 +CFLAGS_GENERATED=
6.28 +
6.29 +######### C++ #########
6.30 +# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
6.31 +CXX=clang -std=c++11
6.32 +CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
6.33 +ifdef WARN
6.34 + CXXFLAGS+=
6.35 +else
6.36 + CXXFLAGS+= -w
6.37 +endif
6.38 +ifdef DEBUG
6.39 + CXXFLAGS+= -O0 -g
6.40 +else
6.41 + CXXFLAGS+= -O3 -DNDEBUG
6.42 +endif
6.43 +
6.44 +######### C and C++ #########
6.45 +# "-bind_at_load" helps find symbol resolution errors faster
6.46 +LDFLAGS=-bind_at_load
6.47 +
6.48 +######### YML2 #########
6.49 +
6.50 +######### asn1c #########
6.51 +
6.52 +######### libetpan #########
6.53 +
6.54 +######### OpenPGP #########
6.55 +LIBGPGME=libgpgme.dylib
6.56 +GPGME_LIB=-L/opt/local/lib
6.57 +GPGME_INC=-I/opt/local/include
6.58 +
6.59 +######### Engine internals #########
6.60 +
6.61 +######### Misc #########
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/build-config/Linux.conf Mon Aug 28 11:29:31 2017 +0200
7.3 @@ -0,0 +1,55 @@
7.4 +# Copyright 2017, pEp Foundation
7.5 +# This file is part of pEpEngine
7.6 +# This file may be used under the terms of the GNU General Public License version 3
7.7 +# see LICENSE.txt
7.8 +
7.9 +######### General #########
7.10 +TARGET=libpEpEngine.so
7.11 +
7.12 +######### C #########
7.13 +CC=gcc -std=c99 -pthread
7.14 +CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
7.15 +ifdef WARN
7.16 + CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
7.17 +else
7.18 + CFLAGS+= -w
7.19 +endif
7.20 +ifdef DEBUG
7.21 + CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
7.22 +else
7.23 + CFLAGS+= -O3 -DNDEBUG
7.24 +endif
7.25 +# '-Wno-cpp' 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.
7.26 +CFLAGS_GENERATED=-Wno-cpp
7.27 +
7.28 +######### C++ #########
7.29 +CXX=g++ -std=gnu++11 -pthread
7.30 +CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
7.31 +ifdef WARN
7.32 + CXXFLAGS+=
7.33 +else
7.34 + CXXFLAGS+= -w
7.35 +endif
7.36 +ifdef DEBUG
7.37 + CXXFLAGS+= -Og -ggdb
7.38 +else
7.39 + CXXFLAGS+= -O3 -DNDEBUG
7.40 +endif
7.41 +
7.42 +######### C and C++ #########
7.43 +LDFLAGS=
7.44 +
7.45 +######### YML2 #########
7.46 +
7.47 +######### asn1c #########
7.48 +
7.49 +######### libetpan #########
7.50 +
7.51 +######### OpenPGP #########
7.52 +LIBGPGME=libgpgme.so.11
7.53 +GPGME_LIB=
7.54 +GPGME_INC=
7.55 +
7.56 +######### Engine internals #########
7.57 +
7.58 +######### Misc #########
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/build-config/common.conf Mon Aug 28 11:29:31 2017 +0200
8.3 @@ -0,0 +1,93 @@
8.4 +# Copyright 2017, pEp Foundation
8.5 +# This file is part of pEpEngine
8.6 +# This file may be used under the terms of the GNU General Public License version 3
8.7 +# see LICENSE.txt
8.8 +
8.9 +# General remark: to use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
8.10 +# 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".
8.11 +
8.12 +######### General #########
8.13 +BUILD_ON:=$(shell uname)
8.14 +BUILD_FOR=$(BUILD_ON)
8.15 +# Installation path prefix for libraries and binaries, except for system.db
8.16 +PREFIX=$(HOME)
8.17 +# Installation path for system.db
8.18 +SYSTEM_DB=/usr/local/share/pEp/system.db
8.19 +# Filename of the pEpEngine library
8.20 +#TARGET This option is platform-specific
8.21 +# If not empty, create a debug build. This variable is ineffective in your PLATFORM_OVERRIDE.conf file.
8.22 +DEBUG=
8.23 +# If not empty, print compiler warnings. This variable is ineffective in your PLATFORM_OVERRIDE.conf file.
8.24 +WARN=placeholder
8.25 +
8.26 +######### C #########
8.27 +#CC This option is platform-specific
8.28 +CPPFLAGS=
8.29 +#CFLAGS This option is platform-specific
8.30 +# Additional CFLAGS used for compiling ASN1C-generated code
8.31 +#CFLAGS_GENERATED This option is platform-specific
8.32 +
8.33 +######### C++ #########
8.34 +#CXX This option is platform-specific
8.35 +#CXXFLAGS This option is platform-specific
8.36 +
8.37 +######### C and C++ #########
8.38 +TARGET_ARCH=
8.39 +# The following two variables will be appended to. You can thus not set them to a fixed value here.
8.40 +#LDFLAGS= This option is platform-specific
8.41 +LDLIBS=
8.42 +
8.43 +######### YML2 #########
8.44 +YML2_PATH=$(HOME)/yml2
8.45 +YML2_PROC=$(YML2_PATH)/yml2proc
8.46 +YML2_OPTS=--encoding=utf8
8.47 +
8.48 +######### asn1c #########
8.49 +# asn1c binary
8.50 +ASN1C=asn1c
8.51 +# asn1c include search flag
8.52 +ASN1C_INC=
8.53 +#ASN1C_INC=-I$(HOME)/include
8.54 +
8.55 +######### libetpan #########
8.56 +# libetpan library search flag
8.57 +ETPAN_LIB=-L$(PREFIX)/lib
8.58 +# libetpan include search flag
8.59 +ETPAN_INC=-I$(PREFIX)/include
8.60 +
8.61 +######### sqlite3 #########
8.62 +# 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.
8.63 +SQLITE3_FROM_OS=placeholder
8.64 +
8.65 +######### OpenPGP #########
8.66 +# Path of GPG binary
8.67 +GPG_CMD=gpg
8.68 +ifneq ($(shell which gpg2),)
8.69 + GPG_CMD=gpg2
8.70 +endif
8.71 +# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
8.72 +OPENPGP=GPG
8.73 +# Path of libGPGME binary
8.74 +#LIBGPGME This option is platform-specific
8.75 +# libGPGME library search flag
8.76 +#GPGME_LIB= This option is platform-specific
8.77 +# libGPGME include search flag
8.78 +#GPGME_INC= This option is platform-specific
8.79 +# NETPGP library search flag
8.80 +NETPGP_LIB=
8.81 +#NETPGP_LIB=-L$(PREFIX)/lib
8.82 +# libGPGME include search flag
8.83 +NETPGP_INC=
8.84 +#NETPGP_INC=-I$(PREFIX)/include
8.85 +
8.86 +######### Engine internals #########
8.87 +# C macros (not environment variables) that can be overridden:
8.88 +# DEFAULT_KEYSERVER - string with default keyserver
8.89 +# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
8.90 +# Example:
8.91 +# EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
8.92 +EXTRA_MACROS=
8.93 +
8.94 +######### Misc #########
8.95 +# FIXME Maybe include these variables here. Check how they are used throughout the project before setting them here
8.96 +#LLDB_BIN
9.1 --- a/db/Makefile Thu Aug 24 11:30:35 2017 +0200
9.2 +++ b/db/Makefile Mon Aug 28 11:29:31 2017 +0200
9.3 @@ -1,22 +1,26 @@
9.4 -# This file is under GNU General Public License 3.0
9.5 +# Copyright 2017, pEp Foundation
9.6 +# This file is part of pEpEngine
9.7 +# This file may be used under the terms of the GNU General Public License version 3
9.8 # see LICENSE.txt
9.9
9.10 include ../Makefile.conf
9.11
9.12 +.PHONY: db
9.13 db: system.db
9.14
9.15 -dicos=$(wildcard *.csv)
9.16 +DICOS = $(wildcard *.csv)
9.17
9.18 -system.db: create_system_db.sql $(dicos)
9.19 +# The 'mv' keeps a backup db around
9.20 +system.db: create_system_db.sql $(DICOS)
9.21 -mv -f $@ $@~
9.22 sqlite3 -batch $@ < $<
9.23 - for c in $(dicos); do echo $$c ; echo .import "$$c" wordlist | sqlite3 -batch -csv $@ ; done
9.24 + for c in $(DICOS) ; do echo "$$c" ; echo .import "$$c" wordlist | sqlite3 -batch -csv $@ ; done
9.25
9.26 -.PHONY: clean install
9.27 -
9.28 +.PHONY: install
9.29 install: system.db
9.30 mkdir -p `dirname $(SYSTEM_DB)`
9.31 cp system.db $(SYSTEM_DB)
9.32
9.33 +.PHONY: clean
9.34 clean:
9.35 - rm -f system.db
9.36 + rm -f system.db system.db~
10.1 --- a/src/Makefile Thu Aug 24 11:30:35 2017 +0200
10.2 +++ b/src/Makefile Mon Aug 28 11:29:31 2017 +0200
10.3 @@ -1,70 +1,61 @@
10.4 +# Copyright 2017, pEp Foundation
10.5 +# This file is part of pEpEngine
10.6 +# This file may be used under the terms of the GNU General Public License version 3
10.7 +# see LICENSE.txt
10.8 +
10.9 include ../Makefile.conf
10.10
10.11 -ETPAN_IN?=$(HOME)
10.12 +CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
10.13 +LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
10.14 +LDLIBS+= -lc -letpan -lasn1 -lsqlite3
10.15 +NO_SOURCE=
10.16
10.17 ifeq ($(BUILD_ON),Darwin)
10.18 -ifeq ($(BUILD_FOR),Darwin)
10.19 -
10.20 -TARGET?=libpEpEngine.dylib
10.21 -MACOSX_VERSION_MIN=10.6
10.22 -LIBGPGME?=libgpgme.dylib
10.23 -CC?=clang -std=c99 -pthread
10.24 -LD?=clang
10.25 -CFLAGS?= -I$(ETPAN_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
10.26 - -DSYSTEM_DB=\"$(SYSTEM_DB)\" -I../asn.1 $(EXTRAMACROS)
10.27 -LDFLAGS?= -lc -shared -arch x86_64 \
10.28 - -L$(ETPAN_IN)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
10.29 -
10.30 + ifeq ($(BUILD_FOR),Darwin)
10.31 + CFLAGS+= -DSQLITE_THREADSAFE=1
10.32 + #LDFLAGS+= -L/opt/local/lib
10.33 + LDLIBS+= -lsqlite3 -lz -liconv
10.34 + else
10.35 + $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
10.36 + endif
10.37 +else ifeq ($(BUILD_ON),Linux)
10.38 + ifeq ($(BUILD_FOR),Linux)
10.39 + CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
10.40 + LDLIBS+= -ldl -luuid
10.41 + else
10.42 + $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
10.43 + endif
10.44 else
10.45 -$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
10.46 + $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
10.47 endif
10.48
10.49 -else ifeq ($(BUILD_ON),Linux)
10.50 -ifeq ($(BUILD_FOR),Linux)
10.51 -
10.52 -TARGET=libpEpEngine.so
10.53 -LIBGPGME?=libgpgme.so.11
10.54 -CC=gcc -std=c99
10.55 -CFLAGS?= -I$(ETPAN_IN)/include $(OPTIMIZE) -fPIC -pedantic -DSYSTEM_DB=\"$(SYSTEM_DB)\" \
10.56 - -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE -I../asn.1 $(EXTRAMACROS)
10.57 -LDFLAGS?= -L$(ETPAN_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1 -luuid
10.58 -
10.59 -else
10.60 -$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
10.61 -endif
10.62 -
10.63 -else
10.64 -$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
10.65 +ifdef SQLITE3_FROM_OS
10.66 + NO_SOURCE+= sqlite3.c
10.67 + CFLAGS+= -DSQLITE3_FROM_OS
10.68 endif
10.69
10.70 -DEBUG?=NO
10.71 -ifeq ("$(DEBUG)","NO")
10.72 - CFLAGS+= -DNDEBUG
10.73 +ifeq ($(OPENPGP),GPG)
10.74 + NO_SOURCE+= pgp_netpgp.c
10.75 + CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
10.76 + LDFLAGS+= $(GPGME_LIB)
10.77 + # No extra LDLIBS are needed here, because GPGME is dynamically loaded
10.78 +else ifeq ($(OPENPGP),NETPGP)
10.79 + NO_SOURCE+= pgp_gpg.c
10.80 + CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
10.81 + LDFLAGS+= $(NETGPG_LIB)
10.82 + LDLIBS+= -lnetpgp -lcurl
10.83 +else
10.84 + $(error Unknown OpenPGP library: $(OPENPGP))
10.85 endif
10.86
10.87 -OPENPGP?=GPG
10.88 -ifeq ("$(OPENPGP)","GPG")
10.89 - NO_SOURCE=pgp_netpgp.c
10.90 - GPGME_IN?=$(HOME)
10.91 - CFLAGS+= -DUSE_GPG -I$(GPGME_IN)/include -DLIBGPGME=\"$(LIBGPGME)\"
10.92 - #LDFLAGS+= -L$(GPGME_IN)/lib -lgpgme
10.93 -else ifeq ("$(OPENPGP)","NETPGP")
10.94 - NO_SOURCE=pgp_gpg.c
10.95 - NETPGP_IN?=$(HOME)
10.96 - CFLAGS+= -DUSE_NETPGP -I$(NETPGP_IN)/include
10.97 - LDFLAGS+= -L$(NETPGP_IN)/lib -lnetpgp -lcurl
10.98 -else
10.99 - $(error Unknown OpenPGP library : $(OPENPGP))
10.100 -endif
10.101 -
10.102 -ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
10.103 -
10.104 +ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
10.105 DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
10.106 ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
10.107
10.108 +.PHONY: all
10.109 all: $(TARGET)
10.110
10.111 -include Makefile.protocols
10.112 +-include Makefile.protocols
10.113
10.114 %.d: %.c
10.115 @set -e; rm -f $@; \
10.116 @@ -72,29 +63,32 @@
10.117 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
10.118 rm -f $@.$$$$
10.119
10.120 --include $(DEPENDS)
10.121 -
10.122 -#platform_windows.o: platform_windows.cpp
10.123 -# $(CXX) $(CXX_FLAGS) -o $@ -c $<
10.124 +# If only the goal 'clean' is given, do not generate and include the '%.d' files.
10.125 +ifneq ($(MAKECMDGOALS),clean)
10.126 + -include $(DEPENDS)
10.127 +endif
10.128
10.129 $(TARGET): libpEpEngine.a
10.130 - $(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
10.131 + $(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
10.132
10.133 +.PHONY: objects
10.134 objects: $(ALL_OBJECTS)
10.135
10.136 libpEpEngine.a: $(ALL_OBJECTS)
10.137 - ar -r $@ $(ALL_OBJECTS)
10.138 + ar -rc $@ $^
10.139
10.140 .PHONY: clean
10.141 -
10.142 clean:
10.143 rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
10.144
10.145 +.PHONY: install
10.146 install: $(TARGET)
10.147 + mkdir -p "$(PREFIX)/lib/"
10.148 cp $< $(PREFIX)/lib/
10.149 mkdir -p $(PREFIX)/include/pEp
10.150 cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h cryptotech.h sync.h sync_fsm.h sync_app.h blacklist.h openpgp_compat.h $(PREFIX)/include/pEp/
10.151
10.152 +.PHONY: uninstall
10.153 uninstall:
10.154 rm -f $(PREFIX)/lib/$(TARGET)
10.155 -
10.156 + rm -rf $(PREFIX)/include/pEp
11.1 --- a/src/bloblist.c Thu Aug 24 11:30:35 2017 +0200
11.2 +++ b/src/bloblist.c Mon Aug 28 11:29:31 2017 +0200
11.3 @@ -32,6 +32,10 @@
11.4 free(bloblist);
11.5 return NULL;
11.6 }
11.7 + /* Default behaviour, can be overwritten post-allocation with
11.8 + set_blob_content_disposition */
11.9 + if (strstr(filename, "cid://") == filename)
11.10 + bloblist->disposition = PEP_CONTENT_DISP_INLINE;
11.11 }
11.12
11.13 if (blob) {
11.14 @@ -166,12 +170,8 @@
11.15 return len;
11.16 }
11.17
11.18 -DYNAMIC_API void set_blob_content_disposition(bloblist_t* blob,
11.19 - content_disposition_type disposition,
11.20 - char* extension_typename,
11.21 - stringpair_list_t* dispo_params) {
11.22 -
11.23 - blob->disposition_extention_type = extension_typename;
11.24 - blob->disposition = disposition;
11.25 - blob->disposition_parms = dispo_params;
11.26 +DYNAMIC_API void set_blob_disposition(bloblist_t* blob,
11.27 + content_disposition_type disposition) {
11.28 + if (blob)
11.29 + blob->disposition = disposition;
11.30 }
12.1 --- a/src/bloblist.h Thu Aug 24 11:30:35 2017 +0200
12.2 +++ b/src/bloblist.h Mon Aug 28 11:29:31 2017 +0200
12.3 @@ -25,10 +25,6 @@
12.4 // NULL if unknown
12.5 content_disposition_type disposition; // default is attachment when allocated
12.6 // (see mime.h and RFC2183)
12.7 - char* disposition_extention_type; // NULL unless the disposition type is
12.8 - // PEP_CONTENT_DISP_EXTENSION - then this
12.9 - // is the type name
12.10 - stringpair_list_t* disposition_parms; // default: NULL (see RFC2183))
12.11 struct _bloblist_t *next;
12.12 } bloblist_t;
12.13
12.14 @@ -112,17 +108,9 @@
12.15 // parameters:
12.16 // blob (in) bloblist struct to change disposition for
12.17 // disposition (in) disposition type (see enum)
12.18 -// extension_typename if disposition type is an extension type,
12.19 -// the name for the type goes here, NULL otherwise
12.20 -// OWNERSHIP GOES TO BLOBLIST
12.21 -// dispo_params(in) type/value pairs for disposition parameters,
12.22 -// if any exist, otherwise NULL.
12.23 -// OWNERSHIP GOES TO BLOBLIST
12.24
12.25 -DYNAMIC_API void set_blob_content_disposition(bloblist_t* blob,
12.26 - content_disposition_type disposition,
12.27 - char* extension_typename,
12.28 - stringpair_list_t* dispo_params);
12.29 +DYNAMIC_API void set_blob_disposition(bloblist_t* blob,
12.30 + content_disposition_type disposition);
12.31
12.32
12.33
13.1 --- a/src/etpan_mime.c Thu Aug 24 11:30:35 2017 +0200
13.2 +++ b/src/etpan_mime.c Mon Aug 28 11:29:31 2017 +0200
13.3 @@ -301,6 +301,11 @@
13.4 switch (resource->rid_type) {
13.5 case PEP_RID_CID:
13.6 content_id = strdup(resource->rid);
13.7 + disposition =
13.8 + mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_INLINE,
13.9 + NULL, NULL, NULL, NULL, (size_t) -1);
13.10 + if (disposition == NULL)
13.11 + goto enomem;
13.12 break;
13.13 case PEP_RID_FILENAME:
13.14 default:
14.1 --- a/src/mime.c Thu Aug 24 11:30:35 2017 +0200
14.2 +++ b/src/mime.c Mon Aug 28 11:29:31 2017 +0200
14.3 @@ -97,82 +97,6 @@
14.4 return status;
14.5 }
14.6
14.7 -static PEP_STATUS mime_html_text(
14.8 - const char *plaintext,
14.9 - const char *htmltext,
14.10 - struct mailmime **result
14.11 - )
14.12 -{
14.13 - PEP_STATUS status = PEP_STATUS_OK;
14.14 - struct mailmime * mime = NULL;
14.15 - struct mailmime * submime = NULL;
14.16 - int r;
14.17 -
14.18 - assert(plaintext);
14.19 - assert(htmltext);
14.20 - assert(result);
14.21 -
14.22 - *result = NULL;
14.23 -
14.24 - mime = part_multiple_new("multipart/alternative");
14.25 - assert(mime);
14.26 - if (mime == NULL)
14.27 - goto enomem;
14.28 -
14.29 - pEp_rid_list_t* resource = new_rid_node(PEP_RID_FILENAME, "msg.txt");
14.30 -
14.31 - submime = get_text_part(resource, "text/plain", plaintext, strlen(plaintext),
14.32 - MAILMIME_MECHANISM_QUOTED_PRINTABLE);
14.33 - free_rid_list(resource);
14.34 - resource = NULL;
14.35 -
14.36 - assert(submime);
14.37 - if (submime == NULL)
14.38 - goto enomem;
14.39 -
14.40 - r = mailmime_smart_add_part(mime, submime);
14.41 - assert(r == MAILIMF_NO_ERROR);
14.42 - if (r == MAILIMF_ERROR_MEMORY) {
14.43 - goto enomem;
14.44 - }
14.45 - else {
14.46 - // mailmime_smart_add_part() takes ownership of submime
14.47 - submime = NULL;
14.48 - }
14.49 -
14.50 - resource = new_rid_node(PEP_RID_FILENAME, "msg.html");
14.51 - submime = get_text_part(resource, "text/html", htmltext, strlen(htmltext),
14.52 - MAILMIME_MECHANISM_QUOTED_PRINTABLE);
14.53 - free_rid_list(resource);
14.54 - resource = NULL;
14.55 -
14.56 - assert(submime);
14.57 - if (submime == NULL)
14.58 - goto enomem;
14.59 -
14.60 - r = mailmime_smart_add_part(mime, submime);
14.61 - assert(r == MAILIMF_NO_ERROR);
14.62 - if (r == MAILIMF_ERROR_MEMORY)
14.63 - goto enomem;
14.64 - else {
14.65 - // mailmime_smart_add_part() takes ownership of submime
14.66 - submime = NULL;
14.67 - }
14.68 -
14.69 - *result = mime;
14.70 - return PEP_STATUS_OK;
14.71 -
14.72 -enomem:
14.73 - status = PEP_OUT_OF_MEMORY;
14.74 -
14.75 - if (mime)
14.76 - mailmime_free(mime);
14.77 -
14.78 - if (submime)
14.79 - mailmime_free(submime);
14.80 -
14.81 - return status;
14.82 -}
14.83
14.84 static PEP_STATUS mime_attachment(
14.85 bloblist_t *blob,
14.86 @@ -216,6 +140,127 @@
14.87 return status;
14.88 }
14.89
14.90 +static PEP_STATUS mime_html_text(
14.91 + const char *plaintext,
14.92 + const char *htmltext,
14.93 + bloblist_t *inlined_attachments,
14.94 + struct mailmime **result
14.95 + )
14.96 +{
14.97 + PEP_STATUS status = PEP_STATUS_OK;
14.98 + struct mailmime * top_level_html_mime = NULL;
14.99 + struct mailmime * mime = NULL;
14.100 + struct mailmime * submime = NULL;
14.101 + int r;
14.102 +
14.103 + assert(plaintext);
14.104 + assert(htmltext);
14.105 + assert(result);
14.106 +
14.107 + *result = NULL;
14.108 +
14.109 + mime = part_multiple_new("multipart/alternative");
14.110 + assert(mime);
14.111 + if (mime == NULL)
14.112 + goto enomem;
14.113 +
14.114 + pEp_rid_list_t* resource = new_rid_node(PEP_RID_FILENAME, "msg.txt");
14.115 +
14.116 + submime = get_text_part(resource, "text/plain", plaintext, strlen(plaintext),
14.117 + MAILMIME_MECHANISM_QUOTED_PRINTABLE);
14.118 + free_rid_list(resource);
14.119 + resource = NULL;
14.120 +
14.121 + assert(submime);
14.122 + if (submime == NULL)
14.123 + goto enomem;
14.124 +
14.125 + r = mailmime_smart_add_part(mime, submime);
14.126 + assert(r == MAILIMF_NO_ERROR);
14.127 + if (r == MAILIMF_ERROR_MEMORY) {
14.128 + goto enomem;
14.129 + }
14.130 + else {
14.131 + // mailmime_smart_add_part() takes ownership of submime
14.132 + submime = NULL;
14.133 + }
14.134 +
14.135 +
14.136 + if (inlined_attachments) {
14.137 + /* Noooooo... dirk, why do you do this to me? */
14.138 + submime = part_multiple_new("multipart/related");
14.139 + assert(submime);
14.140 + if (submime == NULL)
14.141 + goto enomem;
14.142 +
14.143 + top_level_html_mime = submime;
14.144 +
14.145 + r = mailmime_smart_add_part(mime, top_level_html_mime);
14.146 + assert(r == MAILIMF_NO_ERROR);
14.147 + if (r == MAILIMF_ERROR_MEMORY) {
14.148 + goto enomem;
14.149 + }
14.150 + else {
14.151 + // mailmime_smart_add_part() takes ownership of submime
14.152 + submime = NULL;
14.153 + }
14.154 + }
14.155 + else {
14.156 + top_level_html_mime = mime;
14.157 + }
14.158 +
14.159 + resource = new_rid_node(PEP_RID_FILENAME, "msg.html");
14.160 + submime = get_text_part(resource, "text/html", htmltext, strlen(htmltext),
14.161 + MAILMIME_MECHANISM_QUOTED_PRINTABLE);
14.162 + free_rid_list(resource);
14.163 + resource = NULL;
14.164 +
14.165 + assert(submime);
14.166 + if (submime == NULL)
14.167 + goto enomem;
14.168 +
14.169 + r = mailmime_smart_add_part(top_level_html_mime, submime);
14.170 + assert(r == MAILIMF_NO_ERROR);
14.171 + if (r == MAILIMF_ERROR_MEMORY)
14.172 + goto enomem;
14.173 + else {
14.174 + // mailmime_smart_add_part() takes ownership of submime
14.175 + submime = NULL;
14.176 + }
14.177 +
14.178 + bloblist_t *_a;
14.179 + for (_a = inlined_attachments; _a != NULL; _a = _a->next) {
14.180 +
14.181 + status = mime_attachment(_a, &submime);
14.182 + if (status != PEP_STATUS_OK)
14.183 + return PEP_UNKNOWN_ERROR; // FIXME
14.184 +
14.185 + r = mailmime_smart_add_part(top_level_html_mime, submime);
14.186 + assert(r == MAILIMF_NO_ERROR);
14.187 + if (r == MAILIMF_ERROR_MEMORY) {
14.188 + goto enomem;
14.189 + }
14.190 + else {
14.191 + // mailmime_smart_add_part() takes ownership of submime
14.192 + submime = NULL;
14.193 + }
14.194 + }
14.195 +
14.196 + *result = mime;
14.197 + return PEP_STATUS_OK;
14.198 +
14.199 +enomem:
14.200 + status = PEP_OUT_OF_MEMORY;
14.201 +
14.202 + if (mime)
14.203 + mailmime_free(mime);
14.204 +
14.205 + if (submime)
14.206 + mailmime_free(submime);
14.207 +
14.208 + return status;
14.209 +}
14.210 +
14.211 static struct mailimf_mailbox * identity_to_mailbox(const pEp_identity *ident)
14.212 {
14.213 char *_username = NULL;
14.214 @@ -605,6 +650,35 @@
14.215 return retval;
14.216 }
14.217
14.218 +static void split_inlined_and_attached(bloblist_t** inlined, bloblist_t** attached) {
14.219 + bloblist_t** curr_pp = attached;
14.220 + bloblist_t* curr = *curr_pp;
14.221 +
14.222 + bloblist_t* inline_ret = NULL;
14.223 + bloblist_t** inline_curr_pp = &inline_ret;
14.224 +
14.225 + bloblist_t* att_ret = NULL;
14.226 + bloblist_t** att_curr_pp = &att_ret;
14.227 +
14.228 + while (curr) {
14.229 + if (curr->disposition == PEP_CONTENT_DISP_INLINE) {
14.230 + *inline_curr_pp = curr;
14.231 + inline_curr_pp = &(curr->next);
14.232 + }
14.233 + else {
14.234 + *att_curr_pp = curr;
14.235 + att_curr_pp = &(curr->next);
14.236 + }
14.237 + *curr_pp = curr->next;
14.238 + curr->next = NULL;
14.239 + curr = *curr_pp;
14.240 + }
14.241 +
14.242 + *inlined = inline_ret;
14.243 + *attached = att_ret;
14.244 +}
14.245 +
14.246 +
14.247 static PEP_STATUS mime_encode_message_plain(
14.248 const message *msg,
14.249 bool omit_fields,
14.250 @@ -627,7 +701,15 @@
14.251 htmltext = msg->longmsg_formatted;
14.252
14.253 if (htmltext && (htmltext[0] != '\0')) {
14.254 - status = mime_html_text(plaintext, htmltext, &mime);
14.255 + /* first, we need to strip out the inlined attachments to ensure this
14.256 + gets set up correctly */
14.257 +
14.258 + bloblist_t* inlined_attachments = NULL;
14.259 + /* Noooooo... dirk, why do you do this to me? */
14.260 + split_inlined_and_attached(&inlined_attachments, &msg->attachments);
14.261 +
14.262 +
14.263 + status = mime_html_text(plaintext, htmltext, inlined_attachments, &mime);
14.264 if (status != PEP_STATUS_OK)
14.265 goto pep_error;
14.266 }
15.1 --- a/src/pEp_internal.h Thu Aug 24 11:30:35 2017 +0200
15.2 +++ b/src/pEp_internal.h Mon Aug 28 11:29:31 2017 +0200
15.3 @@ -56,7 +56,11 @@
15.4 #include <stdio.h>
15.5 #include <ctype.h>
15.6
15.7 +#ifdef SQLITE3_FROM_OS
15.8 +#include <sqlite3.h>
15.9 +#else
15.10 #include "sqlite3.h"
15.11 +#endif
15.12
15.13 #define _EXPORT_PEP_ENGINE_DLL
15.14 #include "pEpEngine.h"
16.1 --- a/sync/Makefile Thu Aug 24 11:30:35 2017 +0200
16.2 +++ b/sync/Makefile Mon Aug 28 11:29:31 2017 +0200
16.3 @@ -1,35 +1,38 @@
16.4 -
16.5 -# This file is under GNU General Public License 3.0
16.6 +# Copyright 2017, pEp Foundation
16.7 +# This file is part of pEpEngine
16.8 +# This file may be used under the terms of the GNU General Public License version 3
16.9 # see LICENSE.txt
16.10
16.11 include ../Makefile.conf
16.12
16.13 +.PHONY: all
16.14 all: .codegen
16.15
16.16 +# Currently not in use, kept for historic reasons
16.17 skeleton: .actions
16.18
16.19 .codegen: .statemachines .actions
16.20 cp -f generated/*.* ../src
16.21 - touch .codegen
16.22 + touch $@
16.23
16.24 .actions: devicegroup.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2
16.25 - $(YML2PROC) $(YML_OPTS) -y gen_actions.ysl2 $< -o $@
16.26 + $(YML2_PROC) $(YML2_OPTS) -y gen_actions.ysl2 $< -o $@
16.27
16.28 .statemachines: devicegroup.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2
16.29 - $(YML2PROC) $(YML_OPTS) -y gen_statemachine.ysl2 $< -o $@
16.30 + $(YML2_PROC) $(YML2_OPTS) -y gen_statemachine.ysl2 $< -o $@
16.31
16.32 .PHONY: clean
16.33 -
16.34 clean:
16.35 - rm -f *.xml *.xsl \
16.36 - $(pathsub generated/%, ../src/% $(wildcard generated/*.*)) \
16.37 - ../generated/* ../skeletons/* .statemachines .actions *.dot *.svg
16.38 + rm -f *.xml *.xsl *.dot *.svg \
16.39 + $(patsubst generated/%,../src/%,$(wildcard generated/*.*)) \
16.40 + ../generated/* ../skeletons/* .statemachines .actions .codegen \
16.41 + generated/Makefile.protocols
16.42
16.43 %.xml: %.fsm
16.44 - yml2c $< -o $@
16.45 + $(YML2_PATH)/yml2c $< -o $@
16.46
16.47 -%.dot: devicegroup.fsm gen_dot.ysl2
16.48 - $(YML2PROC) $(YML_OPTS) -y gen_dot.ysl2 $<
16.49 +%.dot: gen_dot.ysl2 devicegroup.fsm
16.50 + $(YML2_PROC) $(YML2_OPTS) -y $^
16.51
16.52 %.svg: %.dot
16.53 dot -Tsvg -o $@ $<
17.1 --- a/test/Makefile Thu Aug 24 11:30:35 2017 +0200
17.2 +++ b/test/Makefile Mon Aug 28 11:29:31 2017 +0200
17.3 @@ -1,59 +1,65 @@
17.4 -
17.5 -# This file is under GNU General Public License 3.0
17.6 +# Copyright 2017, pEp Foundation
17.7 +# This file is part of pEpEngine
17.8 +# This file may be used under the terms of the GNU General Public License version 3
17.9 # see LICENSE.txt
17.10
17.11 -HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
17.12 +HERE:=$(CURDIR)
17.13
17.14 include ../Makefile.conf
17.15
17.16 -CC?=g++ -std=gnu++11 -pthread
17.17 -CXX?=g++ -std=gnu++11 -pthread
17.18 -LD?=$(CXX)
17.19 -LDFLAGS?=-L$(HOME)/lib
17.20 -LDLIBS?=-letpan -lpEpEngine -lstdc++ -L../asn.1 -lasn1
17.21 +TARGET=pEpEngineTest
17.22 +
17.23 +unexport GNUPGHOME
17.24 +TEST_HOME=$(HERE)/test_home
17.25 +TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
17.26 +
17.27 +LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
17.28 +LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lsqlite3
17.29 +
17.30 ifeq ($(BUILD_FOR),Linux)
17.31 - LDLIBS+= -luuid
17.32 + LDLIBS+= -luuid
17.33 endif
17.34 -CXXFLAGS?=-std=c++11 -g -O0 -I../src -I../asn.1
17.35 -# CXXFLAGS=-O3 -DNDEBUG
17.36
17.37 -ifeq ("$(OPENPGP)","NETPGP")
17.38 - LDLIBS+= -lnetpgp
17.39 +ifeq ($(OPENPGP),NETPGP)
17.40 + LDLIBS+= -lnetpgp
17.41 endif
17.42
17.43 -TARGET=pEpEngineTest
17.44 +ifeq ($(shell uname),Darwin)
17.45 + LIBPATH=DYLD_LIBRARY_PATH
17.46 + LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
17.47 +else
17.48 + LIBPATH=LD_LIBRARY_PATH
17.49 + LLDB_BIN=lldb
17.50 +endif
17.51 +
17.52 +# Create a list of the extra library paths for the loader. I do not assume that the engine (and its dependencies) are installed for testing.
17.53 +# Note that += can not be used here, as it changes the amount of whitespace
17.54 +EXTRA_LIB_PATHS=../src:
17.55 +ifdef ETPAN_LIB
17.56 + EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
17.57 +endif
17.58 +ifdef GPGME_LIB
17.59 + EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
17.60 +endif
17.61 +ifdef NETPGP_LIB
17.62 + EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
17.63 +endif
17.64 +# Remove trailing ':'
17.65 +EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
17.66 +
17.67 +TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME)
17.68
17.69 UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
17.70 UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
17.71 UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
17.72
17.73 +.PHONY: all
17.74 all: $(TARGET) $(UNIT_TESTS)
17.75
17.76 -.PHONY: clean
17.77 -
17.78 # don't delete .o files!
17.79 .PRECIOUS: %.o
17.80
17.81 -unexport GNUPGHOME;
17.82 -TEST_HOME=$(HERE)/test_home
17.83 -TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
17.84 -
17.85 -ifeq ($(shell which gpg2), )
17.86 - GPG_CMD = gpg
17.87 -else
17.88 - GPG_CMD = gpg2
17.89 -endif
17.90 -
17.91 -ifeq ($(shell uname), Darwin)
17.92 - LIBPATH = DYLD_LIBRARY_PATH
17.93 - LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
17.94 -else
17.95 - LIBPATH = LD_LIBRARY_PATH
17.96 - LLDB_BIN = lldb
17.97 -endif
17.98 -
17.99 -TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
17.100 -
17.101 +.PHONY: test_home_
17.102 test_home_:
17.103 -gpgconf --kill gpg-agent
17.104 -HOME=$(TEST_HOME) gpgconf --kill gpg-agent
17.105 @@ -62,15 +68,17 @@
17.106 mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
17.107 $(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
17.108
17.109 +.PHONY: clean
17.110 clean:
17.111 rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
17.112 rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
17.113
17.114 -test: pEpEngineTest test_home_
17.115 - $(TEST_CMD_PFX) ./pEpEngineTest
17.116 +.PHONY: test
17.117 +test: $(TARGET) test_home_
17.118 + $(TEST_CMD_PFX) ./$<
17.119
17.120 %_test : %_test.o test_util.o
17.121 - $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
17.122 + $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
17.123
17.124 %_run : % test_home_
17.125 $(TEST_CMD_PFX) ./$<
17.126 @@ -84,7 +92,13 @@
17.127 %_gdb : % test_home_
17.128 $(TEST_CMD_PFX) gdb ./$<
17.129
17.130 +.PHONY: unit_tests
17.131 unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
17.132
17.133 +.PHONY: compile
17.134 +compile: $(UNIT_TESTS) $(TARGET)
17.135 +
17.136 +# Installs the engine, not the test binaries
17.137 +.PHONY: install
17.138 install:
17.139 - make -C .. install
17.140 + $(MAKE) -C .. install