Keep me away from the default branch. Reverted to 1954:2f1ed8cf6b6f, because though damiano's Makefile changes are sexy, they'll break ppl.
authorKrista Bennett <krista@pep-project.org>
Tue, 22 Aug 2017 15:57:25 +0200
changeset 1989d3e5bc4a9854
parent 1988 ea7bceda4dc8
child 1993 efaeadf3e6f0
child 1996 8626dd29b73c
Keep me away from the default branch. Reverted to 1954:2f1ed8cf6b6f, because though damiano's Makefile changes are sexy, they'll break ppl.
.hgignore
Makefile
Makefile.conf
README.txt
asn.1/Makefile
build-config/Darwin.conf
build-config/Linux.conf
build-config/common.conf
db/Makefile
src/Makefile
sync/Makefile
test/Makefile
     1.1 --- a/.hgignore	Tue Aug 22 15:34:17 2017 +0200
     1.2 +++ b/.hgignore	Tue Aug 22 15:57:25 2017 +0200
     1.3 @@ -3,7 +3,6 @@
     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	Tue Aug 22 15:34:17 2017 +0200
     2.2 +++ b/Makefile	Tue Aug 22 15:57:25 2017 +0200
     2.3 @@ -1,33 +1,27 @@
     2.4 -# Copyright 2017, pEp Foundation
     2.5 -# This file is part of pEpEngine
     2.6 -# This file may be used under the terms of the GNU General Public License version 3
     2.7 +# this file is under GNU General Public License v3.0
     2.8  # see LICENSE.txt
     2.9  
    2.10 -HERE_REL := $(notdir $(CURDIR))
    2.11 -
    2.12  include Makefile.conf
    2.13  
    2.14 -# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
    2.15 -export YML_PATH=$(YML2_PATH)
    2.16 +# add it to the environment of all executed programs:
    2.17 +export YML_PATH
    2.18  
    2.19 -.PHONY: all
    2.20 +
    2.21  all:
    2.22  	$(MAKE) -C asn.1 generate
    2.23  	$(MAKE) -C asn.1
    2.24  	$(MAKE) -C sync
    2.25  	$(MAKE) -C src all
    2.26  
    2.27 -.PHONY: install
    2.28 +.PHONY: clean build_test test package install uninstall db
    2.29 +
    2.30  install: all
    2.31  	$(MAKE) -C src install
    2.32  	$(MAKE) -C asn.1 install
    2.33  
    2.34 -.PHONY: uninstall
    2.35  uninstall:
    2.36  	$(MAKE) -C src uninstall
    2.37 -	$(MAKE) -C asn.1 uninstall
    2.38  
    2.39 -.PHONY: clean
    2.40  clean:
    2.41  	$(MAKE) -C src clean
    2.42  	$(MAKE) -C test clean
    2.43 @@ -35,19 +29,26 @@
    2.44  	$(MAKE) -C sync clean
    2.45  	$(MAKE) -C asn.1 clean
    2.46  
    2.47 -.PHONY: test
    2.48  test: all
    2.49  	$(MAKE) -C test test
    2.50  	$(MAKE) -C test unit_tests
    2.51  
    2.52 -.PHONY: unit_tests
    2.53  unit_tests: all
    2.54  	$(MAKE) -C test unit_tests
    2.55  
    2.56 -.PHONY: package
    2.57  package: clean
    2.58 -	cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 "$(HERE_REL)"
    2.59 +	cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 pEpEngine
    2.60  
    2.61 -.PHONY: db
    2.62  db:
    2.63  	$(MAKE) -C db db
    2.64 +
    2.65 +windist:
    2.66 +ifneq ($(BUILD_FOR),Windoze)
    2.67 +	@echo use BUILD_FOR=Windoze \(did you forget -e ?\)
    2.68 +else
    2.69 +	make clean
    2.70 +	$(MAKE) all
    2.71 +	$(MAKE) -C test all
    2.72 +	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.73 +endif
    2.74 +
     3.1 --- a/Makefile.conf	Tue Aug 22 15:34:17 2017 +0200
     3.2 +++ b/Makefile.conf	Tue Aug 22 15:57:25 2017 +0200
     3.3 @@ -1,21 +1,30 @@
     3.4 -# Copyright 2017, pEp Foundation
     3.5 -# This file is part of pEpEngine
     3.6 -# This file may be used under the terms of the GNU General Public License version 3
     3.7 -# see LICENSE.txt
     3.8 +# this file is in the Public Domain
     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 +BUILD_ON=$(shell uname)
    3.12 +BUILD_FOR=$(BUILD_ON)
    3.13 +OPTIMIZE=-g -Wall -O0 -fPIC -DDEBUG_ERRORSTACK
    3.14 +#OPTIMIZE=-O3 -Wall -DNDEBUG -std=c99
    3.15 +LD=$(CC)
    3.16 +#CC=gcc-mp-4.9 -std=c99 -fstrict-aliasing -Wstrict-aliasing=3
    3.17 +#LD=gcc-mp-4.9
    3.18 +SYSTEM_DB=/usr/local/share/pEp/system.db
    3.19 +PREFIX=$(HOME)
    3.20 +YML2PROC=$(HOME)/yml2/yml2proc
    3.21 +YML_OPTS=--encoding=utf8
    3.22 +YML_PATH=$(HOME)/yml2
    3.23 +ASN1C=asn1c
    3.24 +ASN1C_INCLUDE=/opt/local/share/asn1c
    3.25 +#ETPAN_IN=$(HOME)
    3.26 +#LIBGPGME=/opt/local/lib/libgpgme.11.dylib
    3.27  
    3.28 -# 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.29 +# C makros (not environment variables) to overwrite:
    3.30 +#
    3.31 +# DEFAULT_KEYSERVER - string with default keyserver
    3.32 +# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
    3.33  
    3.34 -BUILD_CONFIG:=$(dir $(lastword $(MAKEFILE_LIST)))build-config
    3.35 +#EXTRAMACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
    3.36  
    3.37 -include $(BUILD_CONFIG)/common.conf
    3.38 -# cross-compiling is currently not supported, but maybe you can hack something with `PLATFORM_OVERRIDE`
    3.39 -ifeq ($(BUILD_ON),$(BUILD_FOR))
    3.40 -    include $(BUILD_CONFIG)/$(BUILD_ON).conf
    3.41 -else
    3.42 -    $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON))
    3.43 -endif
    3.44 -ifdef PLATFORM_OVERRIDE
    3.45 -    include $(BUILD_CONFIG)/$(PLATFORM_OVERRIDE).conf
    3.46 -endif
    3.47 +# second instance for testing
    3.48 +
    3.49 +#EXTRAMACROS=-DLOCAL_DB_FILENAME=\".pEp_management2.db\"
    3.50 +#TARGET=libpEpEngine2.dylib 
     4.1 --- a/README.txt	Tue Aug 22 15:34:17 2017 +0200
     4.2 +++ b/README.txt	Tue Aug 22 15:57:25 2017 +0200
     4.3 @@ -60,7 +60,8 @@
     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 . 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.8 +* Asn1c, download from https://lionet.info/soft/asn1c-0.9.27.tar.gz
     4.9 +       (Debian's version 0.9.24 does not work)
    4.10  
    4.11  * yml2, which needs lxml (where to get?)
    4.12  
     5.1 --- a/asn.1/Makefile	Tue Aug 22 15:34:17 2017 +0200
     5.2 +++ b/asn.1/Makefile	Tue Aug 22 15:57:25 2017 +0200
     5.3 @@ -1,35 +1,37 @@
     5.4 -# Copyright 2017, pEp Foundation
     5.5 -# This file is part of pEpEngine
     5.6 -# This file may be used under the terms of the GNU General Public License version 3
     5.7 +# This file is under GNU General Public License 3.0
     5.8  # see LICENSE.txt
     5.9  
    5.10  include ../Makefile.conf
    5.11  
    5.12 -ALL_SOURCE=$(wildcard *.c)
    5.13 +ifeq ($(BUILD_ON),Linux)
    5.14 +ifeq ($(BUILD_FOR),Linux)
    5.15 +
    5.16 +CC=gcc
    5.17 +CFLAGS?=-fPIC
    5.18 +else
    5.19 +$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    5.20 +endif
    5.21 +endif
    5.22 +
    5.23 +ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
    5.24  ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    5.25  
    5.26  libasn1.a: $(ALL_OBJECTS)
    5.27 -	ar -rc $@ $^
    5.28 +	ar -rc $@ $(ALL_OBJECTS)
    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) $(CFLAGS_GENERATED) -I. $(ASN1C_INC) -c $< -o $@
    5.37 +	$(CC) $(CFLAGS) $(OPTIMIZE) -I. -I$(ASN1C_INCLUDE) -c $< -o $@
    5.38  
    5.39 -Sync-Protocols.c: pEp.asn1 devicegroup.asn1 protocols.asn1
    5.40 -	$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message $^
    5.41 +Sync-Protocols.c: protocols.asn1 devicegroup.asn1 pEp.asn1
    5.42 +	$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 devicegroup.asn1 $<
    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 --- a/build-config/Darwin.conf	Tue Aug 22 15:34:17 2017 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,55 +0,0 @@
     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 -    CFLAGS+= -Wall -pedantic
    6.18 -else
    6.19 -    CFLAGS+= -w
    6.20 -endif
    6.21 -ifdef DEBUG
    6.22 -    CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
    6.23 -else
    6.24 -    CFLAGS+= -O3 -DNDEBUG
    6.25 -endif
    6.26 -CFLAGS_GENERATED=
    6.27 -
    6.28 -######### C++ #########
    6.29 -# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
    6.30 -CXX=clang -std=c++11
    6.31 -CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
    6.32 -ifdef WARN
    6.33 -    CXXFLAGS+=
    6.34 -else
    6.35 -    CXXFLAGS+= -w
    6.36 -endif
    6.37 -ifdef DEBUG
    6.38 -    CXXFLAGS+= -O0 -g
    6.39 -else
    6.40 -    CXXFLAGS+= -O3 -DNDEBUG
    6.41 -endif
    6.42 -
    6.43 -######### C and C++ #########
    6.44 -
    6.45 -######### YML2 #########
    6.46 -
    6.47 -######### asn1c #########
    6.48 -
    6.49 -######### libetpan #########
    6.50 -
    6.51 -######### OpenPGP #########
    6.52 -LIBGPGME=libgpgme.dylib
    6.53 -GPGME_LIB=-L/opt/local/lib
    6.54 -GPGME_INC=-I/opt/local/include
    6.55 -
    6.56 -######### Engine internals #########
    6.57 -
    6.58 -######### Misc #########
     7.1 --- a/build-config/Linux.conf	Tue Aug 22 15:34:17 2017 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,54 +0,0 @@
     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 -
    7.44 -######### YML2 #########
    7.45 -
    7.46 -######### asn1c #########
    7.47 -
    7.48 -######### libetpan #########
    7.49 -
    7.50 -######### OpenPGP #########
    7.51 -LIBGPGME=libgpgme.so.11
    7.52 -GPGME_LIB=
    7.53 -GPGME_INC=
    7.54 -
    7.55 -######### Engine internals #########
    7.56 -
    7.57 -######### Misc #########
     8.1 --- a/build-config/common.conf	Tue Aug 22 15:34:17 2017 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,88 +0,0 @@
     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 -
    8.11 -######### General #########
    8.12 -BUILD_ON:=$(shell uname)
    8.13 -BUILD_FOR=$(BUILD_ON)
    8.14 -# Installation path prefix for libraries and binaries, except for system.db
    8.15 -PREFIX=$(HOME)
    8.16 -# Installation path for system.db
    8.17 -SYSTEM_DB=/usr/local/share/pEp/system.db
    8.18 -# Filename of the pEpEngine library
    8.19 -#TARGET This option is platform-specific
    8.20 -# If not empty, create a debug build
    8.21 -DEBUG=placeholder
    8.22 -# If not empty, print compiler warnings
    8.23 -WARN=placeholder
    8.24 -
    8.25 -######### C #########
    8.26 -#CC This option is platform-specific
    8.27 -CPPFLAGS=
    8.28 -#CFLAGS This option is platform-specific
    8.29 -# Additional CFLAGS used for compiling ASN1C-generated code
    8.30 -#CFLAGS_GENERATED This option is platform-specific
    8.31 -
    8.32 -######### C++ #########
    8.33 -#CXX This option is platform-specific
    8.34 -#CXXFLAGS This option is platform-specific
    8.35 -
    8.36 -######### C and C++ #########
    8.37 -TARGET_ARCH=
    8.38 -# The following two variables will be appended to. You can thus not set them to a fixed value here.
    8.39 -LDFLAGS=
    8.40 -LDLIBS=
    8.41 -
    8.42 -######### YML2 #########
    8.43 -YML2_PATH=$(HOME)/yml2
    8.44 -YML2_PROC=$(YML2_PATH)/yml2proc
    8.45 -YML2_OPTS=--encoding=utf8
    8.46 -
    8.47 -######### asn1c #########
    8.48 -# asn1c binary
    8.49 -ASN1C=asn1c
    8.50 -# asn1c include search flag
    8.51 -ASN1C_INC=
    8.52 -#ASN1C_INC= -I$(HOME)/include
    8.53 -
    8.54 -######### libetpan #########
    8.55 -# libetpan library search flag
    8.56 -ETPAN_LIB=-L$(PREFIX)/lib
    8.57 -# libetpan include search flag
    8.58 -ETPAN_INC=-I$(PREFIX)/include
    8.59 -
    8.60 -######### OpenPGP #########
    8.61 -# Path of GPG binary
    8.62 -GPG_CMD=gpg
    8.63 -ifneq ($(shell which gpg2),)
    8.64 -    GPG_CMD = gpg2
    8.65 -endif
    8.66 -# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
    8.67 -OPENPGP=GPG
    8.68 -# Path of libGPGME binary
    8.69 -#LIBGPGME This option is platform-specific
    8.70 -# libGPGME library search flag
    8.71 -#GPGME_LIB= This option is platform-specific
    8.72 -# libGPGME include search flag
    8.73 -#GPGME_INC= This option is platform-specific
    8.74 -# NETPGP library search flag
    8.75 -NETPGP_LIB=
    8.76 -#NETPGP_LIB=-L$(PREFIX)/lib
    8.77 -# libGPGME include search flag
    8.78 -NETPGP_INC=
    8.79 -#NETPGP_INC=-I$(PREFIX)/include
    8.80 -
    8.81 -######### Engine internals #########
    8.82 -# C macros (not environment variables) that can be overridden:
    8.83 -# DEFAULT_KEYSERVER - string with default keyserver
    8.84 -# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
    8.85 -# Example:
    8.86 -#    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
    8.87 -EXTRA_MACROS=
    8.88 -
    8.89 -######### Misc #########
    8.90 -# FIXME Maybe include these variables here. Check how they are used throughout the project before setting them here
    8.91 -#LLDB_BIN
     9.1 --- a/db/Makefile	Tue Aug 22 15:34:17 2017 +0200
     9.2 +++ b/db/Makefile	Tue Aug 22 15:57:25 2017 +0200
     9.3 @@ -1,26 +1,22 @@
     9.4 -# Copyright 2017, pEp Foundation
     9.5 -# This file is part of pEpEngine
     9.6 -# This file may be used under the terms of the GNU General Public License version 3
     9.7 +# This file is under GNU General Public License 3.0
     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 -# The 'mv' keeps a backup db around
    9.19 -system.db: create_system_db.sql $(DICOS)
    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: install
    9.27 +.PHONY: clean install
    9.28 +
    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 system.db~
    9.36 +	rm -f system.db
    10.1 --- a/src/Makefile	Tue Aug 22 15:34:17 2017 +0200
    10.2 +++ b/src/Makefile	Tue Aug 22 15:57:25 2017 +0200
    10.3 @@ -1,55 +1,70 @@
    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 -CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
   10.12 -LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
   10.13 -LDLIBS+= -lc -lasn1 -letpan 
   10.14 +ETPAN_IN?=$(HOME)
   10.15  
   10.16  ifeq ($(BUILD_ON),Darwin)
   10.17 -    ifeq ($(BUILD_FOR),Darwin)
   10.18 -        CFLAGS+= -DSQLITE_THREADSAFE=1
   10.19 -        #LDFLAGS+= -L/opt/local/lib
   10.20 -        LDLIBS+= -lsqlite3 -lz -liconv
   10.21 -    else
   10.22 -        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
   10.23 -    endif
   10.24 -else ifeq ($(BUILD_ON),Linux)
   10.25 -    ifeq ($(BUILD_FOR),Linux)
   10.26 -        CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
   10.27 -        LDLIBS+= -ldl -luuid
   10.28 -    else
   10.29 -        $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
   10.30 -    endif
   10.31 +ifeq ($(BUILD_FOR),Darwin)
   10.32 +
   10.33 +TARGET?=libpEpEngine.dylib
   10.34 +MACOSX_VERSION_MIN=10.6
   10.35 +LIBGPGME?=libgpgme.dylib
   10.36 +CC?=clang -std=c99 -pthread
   10.37 +LD?=clang
   10.38 +CFLAGS?= -I$(ETPAN_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
   10.39 +	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -I../asn.1 $(EXTRAMACROS)
   10.40 +LDFLAGS?= -lc -shared -arch x86_64 \
   10.41 +	-L$(ETPAN_IN)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
   10.42 +
   10.43  else
   10.44 -    $(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
   10.45 +$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
   10.46  endif
   10.47  
   10.48 -ifeq ($(OPENPGP),GPG)
   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 +endif
   10.66 +
   10.67 +DEBUG?=NO
   10.68 +ifeq ("$(DEBUG)","NO")
   10.69 +    CFLAGS+= -DNDEBUG
   10.70 +endif
   10.71 +
   10.72 +OPENPGP?=GPG
   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 +    GPGME_IN?=$(HOME)
   10.80 +    CFLAGS+= -DUSE_GPG -I$(GPGME_IN)/include -DLIBGPGME=\"$(LIBGPGME)\"
   10.81 +    #LDFLAGS+= -L$(GPGME_IN)/lib -lgpgme
   10.82 +else ifeq ("$(OPENPGP)","NETPGP")
   10.83      NO_SOURCE=pgp_gpg.c
   10.84 -    CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
   10.85 -    LDFLAGS+= $(NETGPG_LIB)
   10.86 -    LDLIBS+= -lnetpgp -lcurl
   10.87 +    NETPGP_IN?=$(HOME)
   10.88 +    CFLAGS+= -DUSE_NETPGP -I$(NETPGP_IN)/include
   10.89 +    LDFLAGS+= -L$(NETPGP_IN)/lib -lnetpgp -lcurl
   10.90  else
   10.91 -    $(error Unknown OpenPGP library: $(OPENPGP))
   10.92 +	$(error Unknown OpenPGP library : $(OPENPGP))
   10.93  endif
   10.94  
   10.95  ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
   10.96 +
   10.97  DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
   10.98  ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
   10.99  
  10.100 -.PHONY: all
  10.101  all: $(TARGET)
  10.102  
  10.103 --include Makefile.protocols
  10.104 +include Makefile.protocols
  10.105  
  10.106  %.d: %.c
  10.107  	@set -e; rm -f $@; \
  10.108 @@ -57,32 +72,29 @@
  10.109  	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
  10.110  	rm -f $@.$$$$
  10.111  
  10.112 -# If only the goal 'clean' is given, do not generate and include the '%.d' files.
  10.113 -ifneq ($(MAKECMDGOALS),clean)
  10.114 -    -include $(DEPENDS)
  10.115 -endif
  10.116 +-include $(DEPENDS)
  10.117 +
  10.118 +#platform_windows.o: platform_windows.cpp
  10.119 +#	$(CXX) $(CXX_FLAGS) -o $@ -c $<
  10.120  
  10.121  $(TARGET): libpEpEngine.a
  10.122 -	$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
  10.123 +	$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
  10.124  
  10.125 -.PHONY: objects
  10.126  objects: $(ALL_OBJECTS)
  10.127  
  10.128  libpEpEngine.a: $(ALL_OBJECTS)
  10.129 -	ar -rc $@ $^
  10.130 +	ar -r $@ $(ALL_OBJECTS)
  10.131  
  10.132  .PHONY: clean
  10.133 +
  10.134  clean:
  10.135  	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
  10.136  
  10.137 -.PHONY: install
  10.138  install: $(TARGET)
  10.139 -	mkdir -p "$(PREFIX)/lib/"
  10.140  	cp $< $(PREFIX)/lib/
  10.141  	mkdir -p $(PREFIX)/include/pEp
  10.142  	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.143  
  10.144 -.PHONY: uninstall
  10.145  uninstall:
  10.146  	rm -f $(PREFIX)/lib/$(TARGET)
  10.147 -	rm -rf $(PREFIX)/include/pEp
  10.148 +
    11.1 --- a/sync/Makefile	Tue Aug 22 15:34:17 2017 +0200
    11.2 +++ b/sync/Makefile	Tue Aug 22 15:57:25 2017 +0200
    11.3 @@ -1,38 +1,35 @@
    11.4 -# Copyright 2017, pEp Foundation
    11.5 -# This file is part of pEpEngine
    11.6 -# This file may be used under the terms of the GNU General Public License version 3
    11.7 +
    11.8 +# This file is under GNU General Public License 3.0
    11.9  # see LICENSE.txt
   11.10  
   11.11  include ../Makefile.conf
   11.12  
   11.13 -.PHONY: all
   11.14  all: .codegen
   11.15  
   11.16 -# Currently not in use, kept for historic reasons
   11.17  skeleton: .actions
   11.18  
   11.19  .codegen: .statemachines .actions
   11.20  	cp -f generated/*.* ../src
   11.21 -	touch $@
   11.22 +	touch .codegen
   11.23  
   11.24  .actions: devicegroup.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2
   11.25 -	$(YML2_PROC) $(YML2_OPTS) -y gen_actions.ysl2 $< -o $@
   11.26 +	$(YML2PROC) $(YML_OPTS) -y gen_actions.ysl2 $< -o $@
   11.27  
   11.28  .statemachines: devicegroup.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2
   11.29 -	$(YML2_PROC) $(YML2_OPTS) -y gen_statemachine.ysl2 $< -o $@
   11.30 +	$(YML2PROC) $(YML_OPTS) -y gen_statemachine.ysl2 $< -o $@
   11.31  
   11.32  .PHONY: clean
   11.33 +
   11.34  clean:
   11.35 -	rm -f *.xml *.xsl *.dot *.svg \
   11.36 -	$(patsubst generated/%,../src/%,$(wildcard generated/*.*)) \
   11.37 -	../generated/* ../skeletons/* .statemachines .actions .codegen \
   11.38 -	generated/Makefile.protocols
   11.39 +	rm -f *.xml *.xsl \
   11.40 +    $(pathsub generated/%, ../src/% $(wildcard generated/*.*)) \
   11.41 +    ../generated/* ../skeletons/* .statemachines .actions *.dot *.svg
   11.42  
   11.43  %.xml: %.fsm
   11.44 -	$(YML2_PATH)/yml2c $< -o $@
   11.45 +	yml2c $< -o $@
   11.46  
   11.47 -%.dot: gen_dot.ysl2 devicegroup.fsm
   11.48 -	$(YML2_PROC) $(YML2_OPTS) -y $^
   11.49 +%.dot: devicegroup.fsm gen_dot.ysl2
   11.50 +	$(YML2PROC) $(YML_OPTS) -y gen_dot.ysl2 $<
   11.51  
   11.52  %.svg: %.dot
   11.53  	dot -Tsvg -o $@ $<
    12.1 --- a/test/Makefile	Tue Aug 22 15:34:17 2017 +0200
    12.2 +++ b/test/Makefile	Tue Aug 22 15:57:25 2017 +0200
    12.3 @@ -1,65 +1,59 @@
    12.4 -# Copyright 2017, pEp Foundation
    12.5 -# This file is part of pEpEngine
    12.6 -# This file may be used under the terms of the GNU General Public License version 3
    12.7 +
    12.8 +# This file is under GNU General Public License 3.0
    12.9  # see LICENSE.txt
   12.10  
   12.11 -HERE:=$(CURDIR)
   12.12 +HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
   12.13  
   12.14  include ../Makefile.conf
   12.15  
   12.16 -TARGET=pEpEngineTest
   12.17 +CC?=g++ -std=gnu++11 -pthread
   12.18 +CXX?=g++ -std=gnu++11 -pthread
   12.19 +LD?=$(CXX)
   12.20 +LDFLAGS?=-L$(HOME)/lib
   12.21 +LDLIBS?=-letpan -lpEpEngine -lstdc++ -L../asn.1 -lasn1
   12.22 +ifeq ($(BUILD_FOR),Linux)
   12.23 +	LDLIBS+= -luuid
   12.24 +endif
   12.25 +CXXFLAGS?=-std=c++11 -g -O0 -I../src -I../asn.1
   12.26 +# CXXFLAGS=-O3 -DNDEBUG
   12.27  
   12.28 -unexport GNUPGHOME
   12.29 -TEST_HOME=$(HERE)/test_home
   12.30 -TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
   12.31 -
   12.32 -LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
   12.33 -LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
   12.34 -
   12.35 -ifeq ($(BUILD_FOR),Linux)
   12.36 -    LDLIBS+= -luuid
   12.37 +ifeq ("$(OPENPGP)","NETPGP")
   12.38 +	LDLIBS+= -lnetpgp
   12.39  endif
   12.40  
   12.41 -ifeq ($(OPENPGP),NETPGP)
   12.42 -    LDLIBS+= -lnetpgp
   12.43 -endif
   12.44 -
   12.45 -ifeq ($(shell uname),Darwin)
   12.46 -    LIBPATH=DYLD_LIBRARY_PATH
   12.47 -    LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
   12.48 -else
   12.49 -    LIBPATH=LD_LIBRARY_PATH
   12.50 -    LLDB_BIN=lldb
   12.51 -endif
   12.52 -
   12.53 -# 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.
   12.54 -# Note that += can not be used here, as it changes the amount of whitespace
   12.55 -EXTRA_LIB_PATHS=../src:
   12.56 -ifdef ETPAN_LIB
   12.57 -    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
   12.58 -endif
   12.59 -ifdef GPGME_LIB
   12.60 -    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
   12.61 -endif
   12.62 -ifdef NETPGP_LIB
   12.63 -    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
   12.64 -endif
   12.65 -# Remove trailing ':'
   12.66 -EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
   12.67 -
   12.68 -TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME)
   12.69 +TARGET=pEpEngineTest
   12.70  
   12.71  UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
   12.72  UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
   12.73  UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
   12.74  
   12.75 -.PHONY: all
   12.76  all: $(TARGET) $(UNIT_TESTS)
   12.77  
   12.78 +.PHONY: clean
   12.79 +
   12.80  # don't delete .o files!
   12.81  .PRECIOUS: %.o
   12.82  
   12.83 -.PHONY: test_home_
   12.84 +unexport GNUPGHOME;
   12.85 +TEST_HOME=$(HERE)/test_home
   12.86 +TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
   12.87 +
   12.88 +ifeq ($(shell which gpg2), )
   12.89 +    GPG_CMD = gpg
   12.90 +else
   12.91 +    GPG_CMD = gpg2
   12.92 +endif
   12.93 +
   12.94 +ifeq ($(shell uname), Darwin)
   12.95 +    LIBPATH = DYLD_LIBRARY_PATH
   12.96 +    LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
   12.97 +else
   12.98 +    LIBPATH = LD_LIBRARY_PATH
   12.99 +    LLDB_BIN = lldb
  12.100 +endif
  12.101 +
  12.102 +TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
  12.103 +
  12.104  test_home_: 
  12.105  	-gpgconf --kill gpg-agent
  12.106  	-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
  12.107 @@ -68,17 +62,15 @@
  12.108  	mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
  12.109  	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
  12.110  
  12.111 -.PHONY: clean
  12.112  clean:
  12.113  	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
  12.114  	rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
  12.115  
  12.116 -.PHONY: test
  12.117 -test: $(TARGET) test_home_
  12.118 -	$(TEST_CMD_PFX) ./$<
  12.119 +test: pEpEngineTest test_home_
  12.120 +	$(TEST_CMD_PFX) ./pEpEngineTest
  12.121  
  12.122  %_test : %_test.o test_util.o
  12.123 -	 $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  12.124 +	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
  12.125  
  12.126  %_run : % test_home_
  12.127  	$(TEST_CMD_PFX) ./$<
  12.128 @@ -92,10 +84,7 @@
  12.129  %_gdb : % test_home_
  12.130  	$(TEST_CMD_PFX) gdb ./$<
  12.131  
  12.132 -.PHONY: unit_tests
  12.133  unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
  12.134  
  12.135 -# Installs the engine, not the test binaries
  12.136 -.PHONY: install
  12.137  install:
  12.138 -	$(MAKE) -C .. install
  12.139 +	make -C .. install