merging sync
authorVolker Birk <vb@pep-project.org>
Tue, 02 Apr 2019 11:34:45 +0200
branchsync
changeset 3433759e5f5244a7
parent 3432 b8abbad4e091
parent 3431 f67516cd02ca
child 3434 458a804f88e4
merging
     1.1 --- a/Makefile	Tue Apr 02 11:34:30 2019 +0200
     1.2 +++ b/Makefile	Tue Apr 02 11:34:45 2019 +0200
     1.3 @@ -5,7 +5,7 @@
     1.4  
     1.5  HERE_REL := $(notdir $(CURDIR))
     1.6  
     1.7 -include default.conf
     1.8 +include Makefile.conf
     1.9  
    1.10  ifneq ($(wildcard local.conf),)
    1.11      $(info ================================================)
    1.12 @@ -30,6 +30,10 @@
    1.13  	$(MAKE) -C src install
    1.14  	$(MAKE) -C asn.1 install
    1.15  
    1.16 +.PHONY: dbinstall
    1.17 +dbinstall: db
    1.18 +	$(MAKE) -C db install
    1.19 +
    1.20  .PHONY: uninstall
    1.21  uninstall:
    1.22  	$(MAKE) -C src uninstall
    1.23 @@ -42,7 +46,6 @@
    1.24  	$(MAKE) -C db clean
    1.25  	$(MAKE) -C sync clean
    1.26  	$(MAKE) -C asn.1 clean
    1.27 -	rm -rf test_home
    1.28  
    1.29  .PHONY: tags
    1.30  tags:
     2.1 --- a/Makefile.conf	Tue Apr 02 11:34:30 2019 +0200
     2.2 +++ b/Makefile.conf	Tue Apr 02 11:34:45 2019 +0200
     2.3 @@ -5,107 +5,252 @@
     2.4  
     2.5  # See `doc/build-<your platform>.md` for documentation on how to build, and customize your build.
     2.6  
     2.7 +# This file sets all the make variables that allow you to customize a build.
     2.8 +# There are 3 ways in which you can customize your build:
     2.9 +# 1) Edit the variable assignments in this file (this is a tracked file, so your repository will be dirty)
    2.10 +# 2) Create `local.conf` and fill it with variable assignments.
    2.11 +# 3) Set the environment variable `BUILD_CONFIG` to an absolute path.
    2.12 +#    The variable assignments found in the make file at the path indicated by `BUILD_CONFIG` will be evaluated.
    2.13 +# Customization options are applied in the order given above. Later variable assignments take precedence over earlier ones.
    2.14 +# It is possible to use multiple variants simultaniously.
    2.15 +# If nothing is changed according to these 3 methods, a default configuration for your platform (specified below) will be used for the build.
    2.16 +
    2.17 +
    2.18 +######### Header #########
    2.19 +HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
    2.20 +
    2.21 +
    2.22  ######### General #########
    2.23  # To use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
    2.24  # All the *_INC and *_LIB variables are command line flags, not paths.
    2.25  # Thus, all *_INC variables' values must start with "-I", and all *_LIB variables' values must start with "-L".
    2.26  
    2.27 -#BUILD_ON:=$(shell uname)
    2.28 +BUILD_ON:=$(shell uname)
    2.29  
    2.30  # This variable specifies the platform that the engine should be cross-compiled for.
    2.31 -#BUILD_FOR=$(BUILD_ON)
    2.32 +BUILD_FOR=$(BUILD_ON)
    2.33 +
    2.34 +# Cross-compiling is currently not supported.
    2.35 +# Maybe you can hack something with `local.conf`.
    2.36 +ifneq ($(BUILD_ON),$(BUILD_FOR))
    2.37 +    $(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).)
    2.38 +endif
    2.39  
    2.40  # Installation path prefix for libraries and binaries, except for system.db
    2.41 -#PREFIX=$(HOME)
    2.42 +PREFIX=$(HOME)
    2.43  
    2.44  # Installation path for system.db
    2.45 -#SYSTEM_DB=/usr/local/share/pEp/system.db
    2.46 +SYSTEM_DB=/usr/local/share/pEp/system.db
    2.47  
    2.48  # Filename of the pEpEngine library
    2.49 -#TARGET=libpEpEngine.so
    2.50 +ifeq ($(BUILD_FOR),Linux)
    2.51 +    TARGET=libpEpEngine.so
    2.52 +else ifeq ($(BUILD_FOR),Darwin)
    2.53 +    TARGET=libpEpEngine.dylib
    2.54 +endif
    2.55 +
    2.56 +# If empty, create a release build.
    2.57 +# Otherwise, create a debug build.
    2.58 +# This variable is ineffective when set anywhere else but here.
    2.59 +DEBUG=placeholder
    2.60 +
    2.61 +# If empty, suppress compiler warnings.
    2.62 +# Otherwise, print warnings.
    2.63 +# This variable is ineffective when set anywhere else but here.
    2.64 +WARN=placeholder
    2.65  
    2.66  
    2.67  ######### C and C++ #########
    2.68 -#TARGET_ARCH=
    2.69 +TARGET_ARCH=
    2.70  
    2.71  # The following two variables will be appended to.
    2.72 -# You can thus not set them to a fixed value here.
    2.73 -#LDFLAGS=
    2.74 +# You can thus not set them to a final, fixed value here.
    2.75 +ifeq ($(BUILD_FOR),Linux)
    2.76 +    LDFLAGS=
    2.77 +else ifeq ($(BUILD_FOR),Darwin)
    2.78 +    # "-bind_at_load" helps find symbol resolution errors faster
    2.79 +    LDFLAGS=-bind_at_load
    2.80 +endif
    2.81  
    2.82 -#LDLIBS=
    2.83 +LDLIBS=
    2.84  
    2.85  
    2.86  ######### C #########
    2.87 -#CC=
    2.88 +ifeq ($(BUILD_FOR),Linux)
    2.89 +    CC=gcc -std=c99 -pthread
    2.90 +else ifeq ($(BUILD_FOR),Darwin)
    2.91 +    # clang issues a warning when "-pthread" is used for linking.
    2.92 +    # So, include it in CFLAGS, and not in CC
    2.93 +    CC=clang -std=c99
    2.94 +endif
    2.95  
    2.96 -#CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    2.97 +ifeq ($(BUILD_FOR),Linux)
    2.98 +    CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
    2.99 +else ifeq ($(BUILD_FOR),Darwin)
   2.100 +    CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
   2.101 +endif
   2.102  
   2.103 -#CPPFLAGS=
   2.104 -
   2.105 -#CFLAGS+= -w -O3 -DNDEBUG
   2.106 +# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
   2.107 +# The tests do not work properly, if compiled with -DNDEBUG
   2.108 +ifeq ($(BUILD_FOR),Linux)
   2.109 +    ifdef WARN
   2.110 +        CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
   2.111 +    else
   2.112 +        CFLAGS+= -w
   2.113 +    endif
   2.114 +    ifdef DEBUG
   2.115 +        CFLAGS+= -g -ggdb -DDEBUG_ERRORSTACK
   2.116 +    else
   2.117 +        CFLAGS+= -O3 -DNDEBUG
   2.118 +    endif
   2.119 +else ifeq ($(BUILD_FOR),Darwin)
   2.120 +    ifdef WARN
   2.121 +        # FIXME Remove 'no-extended-offsetof' after ENGINE-236 is closed.
   2.122 +        CFLAGS+= -Wall -pedantic -Wno-extended-offsetof
   2.123 +    else
   2.124 +        CFLAGS+= -w
   2.125 +    endif
   2.126 +    ifdef DEBUG
   2.127 +        CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
   2.128 +    else
   2.129 +        CFLAGS+= -O3 -DNDEBUG
   2.130 +    endif
   2.131 +endif
   2.132  
   2.133  # Additional CFLAGS used for compiling ASN1C-generated code
   2.134 -#CFLAGS_GENERATED=-D_DEFAULT_SOURCE
   2.135 +ifeq ($(BUILD_FOR),Linux)
   2.136 +    # The '_DEFAULT_SOURCE' feature test macro is required to suppress the warning
   2.137 +    #   _BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE
   2.138 +    # otherwise printed during the compilation of every asn1c-generated C file.
   2.139 +    # It's a glibc specific warning, only present in few versions around ~2.19.
   2.140 +    # See https://lwn.net/Articles/590381/ for a discussion.
   2.141 +    CFLAGS_GENERATED=-D_DEFAULT_SOURCE
   2.142 +else ifeq ($(BUILD_FOR),Darwin)
   2.143 +    CFLAGS_GENERATED=
   2.144 +endif
   2.145  
   2.146  
   2.147  ######### C++ #########
   2.148 -#CXX=g++ -std=gnu++11 -pthread
   2.149 +ifeq ($(BUILD_FOR),Linux)
   2.150 +    CXX=g++ -std=gnu++11 -pthread
   2.151 +else ifeq ($(BUILD_FOR),Darwin)
   2.152 +    # clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
   2.153 +    CXX=clang -std=c++11
   2.154 +endif
   2.155  
   2.156 -#CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC) -w -O3 -DNDEBUG
   2.157 +# The flag -DNDEBUG will always be removed from CXXFLAGS for compiling tests.
   2.158 +# The tests do not work properly, if compiled with -DNDEBUG
   2.159 +ifeq ($(BUILD_FOR),Linux)
   2.160 +    CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
   2.161 +    ifdef WARN
   2.162 +        CXXFLAGS+=
   2.163 +    else
   2.164 +        CXXFLAGS+= -w
   2.165 +    endif
   2.166 +    ifdef DEBUG
   2.167 +        CXXFLAGS+= -g -ggdb
   2.168 +    else
   2.169 +        CXXFLAGS+= -O3 -DNDEBUG
   2.170 +    endif
   2.171 +else ifeq ($(BUILD_FOR),Darwin)
   2.172 +    CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
   2.173 +    ifdef WARN
   2.174 +        CXXFLAGS+=
   2.175 +    else
   2.176 +        CXXFLAGS+= -w
   2.177 +    endif
   2.178 +    ifdef DEBUG
   2.179 +        CXXFLAGS+= -O0 -g
   2.180 +    else
   2.181 +        CXXFLAGS+= -O3 -DNDEBUG
   2.182 +    endif
   2.183 +endif
   2.184 +
   2.185 +
   2.186 +######### C and C++ #########
   2.187 +CPPFLAGS=
   2.188  
   2.189  
   2.190  ######### YML2 #########
   2.191 -#YML2_PATH=$(HOME)/yml2
   2.192 +YML2_PATH=$(HOME)/yml2
   2.193  
   2.194 -#YML2_PROC=$(YML2_PATH)/yml2proc
   2.195 +YML2_PROC=$(YML2_PATH)/yml2proc $(YML2_OPTS)
   2.196  
   2.197 -#YML2_OPTS=--encoding=utf8
   2.198 +YML2_OPTS=--encoding=utf8
   2.199  
   2.200  
   2.201  ######### asn1c #########
   2.202  # asn1c binary
   2.203 -#ASN1C=asn1c
   2.204 +ASN1C=asn1c
   2.205  
   2.206  # asn1c include search flag
   2.207 +ASN1C_INC=
   2.208  #ASN1C_INC=-I$(HOME)/include
   2.209  
   2.210  
   2.211  ######### libetpan #########
   2.212  # libetpan library search flag
   2.213 -#ETPAN_LIB=-L$(PREFIX)/lib
   2.214 +ETPAN_LIB=
   2.215 +#ETPAN_LIB=-L$(HOME)/lib
   2.216  
   2.217  # libetpan include search flag
   2.218 -#ETPAN_INC=-I$(PREFIX)/include
   2.219 +ETPAN_INC=
   2.220 +#ETPAN_INC=-I$(HOME)/include
   2.221  
   2.222  
   2.223  ######### sqlite3 #########
   2.224  # If empty (or undefined), compile sqlite3 from the sources shipped with the pEp distribution.
   2.225  # Otherwise, use an sqlite3 implementation found in the OS's include/library paths.
   2.226 -#SQLITE3_FROM_OS=placeholder
   2.227 +SQLITE3_FROM_OS=placeholder
   2.228  
   2.229  
   2.230  ######### OpenPGP #########
   2.231  # Path of GPG binary
   2.232  # 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.
   2.233 -#GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   2.234 +GPG_CMD:=$(shell gpgconf --list-components | awk -F: '/^gpg:/ { print $$3; exit 0; }')
   2.235  
   2.236 -# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
   2.237 -#OPENPGP=GPG
   2.238 +# Selects OpenPGP implementation. must be either `SEQUOIA`, `GPG` or `NETPGP`
   2.239 +OPENPGP=GPG
   2.240  
   2.241 -# Path of libGPGME binary
   2.242 -#LIBGPGME=libgpgme.so.11
   2.243 +# Sequoia-specific variables
   2.244 +SEQUOIA_CFLAGS=
   2.245 +SEQUOIA_LDFLAGS=
   2.246 +SEQUOIA_LIB=
   2.247 +SEQUOIA_INC=
   2.248 +
   2.249 +# libGPGME filename
   2.250 +ifeq ($(BUILD_FOR),Linux)
   2.251 +    LIBGPGME=libgpgme.so.11
   2.252 +else ifeq ($(BUILD_FOR),Darwin)
   2.253 +    LIBGPGME=libgpgme.11.dylib
   2.254 +endif
   2.255  
   2.256  # libGPGME library search flag
   2.257 -#GPGME_LIB=
   2.258 +GPGME_LIB=
   2.259 +#GPGME_LIB=-L$(HOME)/lib
   2.260  
   2.261  # libGPGME include search flag
   2.262 -#GPGME_INC=
   2.263 +GPGME_INC=
   2.264 +#GPGME_INC=-I$(HOME)/include
   2.265  
   2.266  # NETPGP library search flag
   2.267 -#NETPGP_LIB=-L$(PREFIX)/lib
   2.268 +NETPGP_LIB=
   2.269 +#NETPGP_LIB=-L$(HOME)/lib
   2.270  
   2.271  # libGPGME include search flag
   2.272 -#NETPGP_INC=-I$(PREFIX)/include
   2.273 +NETPGP_INC=
   2.274 +#NETPGP_INC=-I$(HOME)/include
   2.275 +
   2.276 +
   2.277 +
   2.278 +######### CppUnit #########
   2.279 +# CppUnit library search flag
   2.280 +CPPUNIT_LIB=
   2.281 +#CPPUNIT_LIB=-L$(HOME)/local/lib
   2.282 +
   2.283 +# CppUnit include search flag
   2.284 +CPPUNIT_INC=
   2.285 +#CPPUNIT_INC=-I$(HOME)/local/inc
   2.286  
   2.287  
   2.288  ######### Engine internals #########
   2.289 @@ -114,7 +259,33 @@
   2.290  # CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
   2.291  # Example:
   2.292  #    EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
   2.293 -#EXTRA_MACROS=
   2.294 +EXTRA_MACROS=
   2.295  
   2.296 -# add this for running tests in debugger
   2.297 +
   2.298 +######### Misc #########
   2.299 +# Add this for running tests in debugger
   2.300  #TEST_DEBUGGER=lldb --batch -o r
   2.301 +
   2.302 +# comma-separated list of tests to exclude from gensuite (relevant for running tests only)
   2.303 +EXCLUDE=
   2.304 +
   2.305 +
   2.306 +######### Footer #########
   2.307 +-include $(HERE)/local.conf
   2.308 +
   2.309 +ifdef BUILD_CONFIG
   2.310 +    include $(BUILD_CONFIG)
   2.311 +endif
   2.312 +
   2.313 +######### Post processing assignments ########
   2.314 +ifeq ($(OPENPGP),SEQUOIA)
   2.315 +    SEQUOIA_CFLAGS=$(shell pkg-config --cflags-only-other sequoia-openpgp)
   2.316 +    SEQUOIA_LDFLAGS=$(shell pkg-config --libs-only-l --libs-only-other sequoia-openpgp)
   2.317 +    SEQUOIA_LIB=$(shell pkg-config --libs-only-L sequoia-openpgp)
   2.318 +    SEQUOIA_INC=$(shell pkg-config --cflags-only-I sequoia-openpgp)
   2.319 +    CFLAGS+= $(SEQUOIA_CFLAGS)
   2.320 +    LD_FLAGS+= $(SEQUOIA_LDFLAGS)
   2.321 +endif
   2.322 +
   2.323 +# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
   2.324 +export YML_PATH=$(YML2_PATH)
     3.1 --- a/asn.1/Makefile	Tue Apr 02 11:34:30 2019 +0200
     3.2 +++ b/asn.1/Makefile	Tue Apr 02 11:34:45 2019 +0200
     3.3 @@ -1,7 +1,7 @@
     3.4  # This file is under GNU General Public License 3.0
     3.5  # see LICENSE.txt
     3.6  
     3.7 -include ../default.conf
     3.8 +include ../Makefile.conf
     3.9  
    3.10  ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
    3.11  ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
    3.12 @@ -16,7 +16,7 @@
    3.13  	rm -f converter-sample.c
    3.14  
    3.15  %.o: %.c %.h
    3.16 -	$(CC) $(CFLAGS) $(OPTIMIZE) -I. -I$(ASN1C_INC) -c $< -o $@
    3.17 +	$(CC) $(CFLAGS) $(OPTIMIZE) -I. $(ASN1C_INC) -c $< -o $@
    3.18  
    3.19  Sync.c: sync.asn1 keysync.asn1 pEp.asn1
    3.20  	$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=auto pEp.asn1 keysync.asn1 $<
     4.1 --- a/db/Makefile	Tue Apr 02 11:34:30 2019 +0200
     4.2 +++ b/db/Makefile	Tue Apr 02 11:34:45 2019 +0200
     4.3 @@ -3,7 +3,7 @@
     4.4  # This file may be used under the terms of the GNU General Public License version 3
     4.5  # see LICENSE.txt
     4.6  
     4.7 -include ../default.conf
     4.8 +include ../Makefile.conf
     4.9  
    4.10  .PHONY: db
    4.11  db: system.db
     5.1 --- a/src/Makefile	Tue Apr 02 11:34:30 2019 +0200
     5.2 +++ b/src/Makefile	Tue Apr 02 11:34:45 2019 +0200
     5.3 @@ -3,7 +3,7 @@
     5.4  # This file may be used under the terms of the GNU General Public License version 3
     5.5  # see LICENSE.txt
     5.6  
     5.7 -include ../default.conf
     5.8 +include ../Makefile.conf
     5.9  
    5.10  CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
    5.11  LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
    5.12 @@ -86,17 +86,18 @@
    5.13  clean:
    5.14  	rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
    5.15  	rm -Rf $(TARGET).dSYM
    5.16 +	rm -f KeySync_fsm.* Sync_actions.c Sync_event.* Sync_func.* Sync_impl.* sync_codec.*
    5.17  
    5.18  .PHONY: install
    5.19  install: $(TARGET)
    5.20  	mkdir -p "$(PREFIX)/lib/"
    5.21  	cp $< $(PREFIX)/lib/
    5.22  	mkdir -p $(PREFIX)/include/pEp
    5.23 -	cp -v pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
    5.24 -	      timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
    5.25 -	      cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
    5.26 -	      labeled_int_list.h key_reset.h base64.h sync_codec.h \
    5.27 -		  ../asn.1/*.h $(PREFIX)/include/pEp/
    5.28 +	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h \
    5.29 +	   timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h \
    5.30 +	   cryptotech.h sync_api.h blacklist.h pEp_string.h openpgp_compat.h \
    5.31 +	   labeled_int_list.h key_reset.h base64.h sync_codec.h \
    5.32 +	   ../asn.1/*.h $(PREFIX)/include/pEp/
    5.33  
    5.34  .PHONY: uninstall
    5.35  uninstall:
     6.1 --- a/sync/Makefile	Tue Apr 02 11:34:30 2019 +0200
     6.2 +++ b/sync/Makefile	Tue Apr 02 11:34:45 2019 +0200
     6.3 @@ -1,43 +1,41 @@
     6.4  # This file is under GNU General Public License 3.0
     6.5  # see LICENSE.txt
     6.6  
     6.7 -include ../default.conf
     6.8 +include ../Makefile.conf
     6.9  
    6.10 -all: .codegen
    6.11 +all: copy
    6.12  
    6.13 -.codegen: generated .statemachines .actions .codecs .messages
    6.14 -	touch .codegen
    6.15 -	make copy
    6.16 +generated:
    6.17 +	mkdir -p $@
    6.18  
    6.19 -.actions: sync.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2 $(wildcard cond_act_*.yml2)
    6.20 +.actions: sync.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2 $(wildcard cond_act_*.yml2) | generated
    6.21  	$(YML2_PROC) -y gen_actions.ysl2 $< -o $@
    6.22  
    6.23 -.statemachines: sync.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2
    6.24 +.statemachines: sync.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2 | generated
    6.25  	$(YML2_PROC) -y gen_statemachine.ysl2 $< -o $@
    6.26  
    6.27 -.codecs: sync.fsm gen_codec.ysl2 fsm.yml2 functions.ysl2
    6.28 +.codecs: sync.fsm gen_codec.ysl2 fsm.yml2 functions.ysl2 | generated
    6.29  	$(YML2_PROC) -y gen_codec.ysl2 $< -o $@
    6.30  
    6.31 -.messages: sync.fsm gen_messages.ysl2 gen_message_func.ysl2 fsm.yml2 functions.ysl2
    6.32 +.messages: sync.fsm gen_messages.ysl2 gen_message_func.ysl2 fsm.yml2 functions.ysl2 | generated
    6.33  	$(YML2_PROC) -y gen_messages.ysl2 $< -o $@
    6.34  	$(YML2_PROC) -y gen_message_func.ysl2 $< -o $@
    6.35  
    6.36 -.PHONY: clean copy
    6.37 +.PHONY: clean
    6.38 +clean:
    6.39 +	rm -rf generated
    6.40 +	rm -f *.xml *.xsl .statemachines .actions .codecs .messages *.dot *.svg
    6.41  
    6.42 -clean:
    6.43 -	rm -f *.xml *.xsl generated/* .statemachines .actions .codecs .messages *.dot *.svg
    6.44 -
    6.45 -copy:
    6.46 +.PHONY: copy
    6.47 +copy: .actions .statemachines .codecs .messages
    6.48  	cp -f generated/*.c generated/*.h ../src
    6.49  
    6.50 -generated: .codegen
    6.51 -	-mkdir -p generated
    6.52 -
    6.53  %.xml: %.fsm
    6.54  	yml2c $< -o $@
    6.55  
    6.56  %.dot: sync.fsm gen_dot.ysl2
    6.57 -	yml2proc -y gen_dot.ysl2 $<
    6.58 +	$(YML2_PROC) -y gen_dot.ysl2 $<
    6.59  
    6.60  %.svg: %.dot
    6.61  	dot -Tsvg -o $@ $<
    6.62 +
     7.1 --- a/test/Makefile	Tue Apr 02 11:34:30 2019 +0200
     7.2 +++ b/test/Makefile	Tue Apr 02 11:34:45 2019 +0200
     7.3 @@ -1,106 +1,109 @@
     7.4 -
     7.5  # Copyright 2017, pEp Foundation
     7.6  # This file is part of pEpEngine
     7.7  # This file may be used under the terms of the GNU General Public License version 3
     7.8  # see LICENSE.txt
     7.9  
    7.10 -include ../default.conf
    7.11 +HERE:=$(CURDIR)
    7.12  
    7.13 -PY_ENV := $(shell command -v python3 2> /dev/null)
    7.14 +include ../Makefile.conf
    7.15  
    7.16 -HERE:=$(CURDIR)
    7.17 +# User's without python3 will skip the generated parts of the test suite. That's OK.
    7.18 +PY_ENV:=$(shell command -v python3 2> /dev/null)
    7.19 +
    7.20  TEST_HOME=$(HERE)/pEp_test_home
    7.21  
    7.22  TARGET=TestDriver
    7.23  
    7.24 -SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
    7.25 -OBJS := $(addsuffix .o,$(basename $(SRCS)))
    7.26 -DEPS := $(OBJS:.o=.d)
    7.27 +SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
    7.28 +OBJS:=$(addsuffix .o,$(basename $(SRCS)))
    7.29 +DEPS:=$(OBJS:.o=.d)
    7.30  
    7.31 -INC_DIRS := ./include /usr/local/include ../src ../sync ../asn.1
    7.32 -INC_FLAGS := $(addprefix -I,$(INC_DIRS)) $(GPGME_INC) $(CPPUNIT_INC)
    7.33  
    7.34 -LDFLAGS += -L/usr/local/lib
    7.35 -CFLAGS += -Wno-deprecated
    7.36 -CXXFLAGS += -Wno-deprecated
    7.37 -CFLAGS:=$(filter-out -Wall,$(CFLAGS))
    7.38 +LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(CPPUNIT_LIB)
    7.39  
    7.40 -LDFLAGS+= $(ETPAN_LIB) $(CPPUNIT_LIB) -L../asn.1 -L../src
    7.41 -LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    7.42 +ifeq ($(OPENPGP),GPG)
    7.43 +    LDFLAGS+= $(GPGME_LIB)
    7.44 +else ifeq ($(OPENPGP),NETPGP)
    7.45 +    LDFLAGS+= $(NETGPG_LIB)
    7.46 +endif
    7.47 +
    7.48 +
    7.49 +LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1 -lcpptest
    7.50  
    7.51  ifeq ($(BUILD_FOR),Linux)
    7.52 -	LDLIBS+= -luuid
    7.53 -endif
    7.54 -
    7.55 -ifeq ($(OPENPGP),NETPGP)
    7.56 -	LDLIBS+= -lnetpgp
    7.57 -	CFLAGS+= -DUSE_NETPGP
    7.58 -ifeq ($(BUILD_FOR),Linux)
    7.59 -	LDLIBS+= -ltre
    7.60 -endif
    7.61 +    LDLIBS+= -luuid
    7.62  endif
    7.63  
    7.64  ifeq ($(OPENPGP),SEQUOIA)
    7.65 -	LDFLAGS+= $(SEQUOIA_LDFLAGS)
    7.66 -	LDLIBS+= $(SEQUOIA_LIB)
    7.67 -	CFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
    7.68 -	INC_FLAGS+= $(SEQUOIA_INC)
    7.69 +    LDFLAGS+= $(SEQUOIA_LDFLAGS)
    7.70 +    LDLIBS+= $(SEQUOIA_LIB)
    7.71 +    CFLAGS+= $(SEQUOIA_CFLAGS) -DUSE_SEQUOIA
    7.72 +    INC_FLAGS+= $(SEQUOIA_INC)
    7.73  endif
    7.74  
    7.75  ifdef SQLITE3_FROM_OS
    7.76 -	LDLIBS+= -lsqlite3
    7.77 +    LDLIBS+= -lsqlite3
    7.78  endif
    7.79  
    7.80 -ifeq ($(shell uname),Darwin)
    7.81 -	LIBPATH=DYLD_LIBRARY_PATH
    7.82 -	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    7.83 -else
    7.84 -	LIBPATH=LD_LIBRARY_PATH
    7.85 -	LLDB_BIN=lldb
    7.86 +ifeq ($(OPENPGP),GPG)
    7.87 +    #LDLIBS+= -lgpgme
    7.88 +else ifeq ($(OPENPGP),NETPGP)
    7.89 +    LDLIBS+= -lnetpgp
    7.90 +    ifeq ($(BUILD_FOR),Linux)
    7.91 +        LDLIBS+= -ltre
    7.92 +    endif
    7.93  endif
    7.94  
    7.95 -LDLIBS+= -lcpptest
    7.96  
    7.97 +CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
    7.98  
    7.99 -# 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.
   7.100 -# Note that += can not be used here, as it changes the amount of whitespace
   7.101 -EXTRA_LIB_PATHS=../src:
   7.102 +# FIXME Possibly missing incdirs: ASN1C_INC
   7.103 +CXXFLAGS+= -I./include -I../sync $(CPPUNIT_INC) -Wno-deprecated
   7.104 +
   7.105 +ifeq ($(OPENPGP),GPG)
   7.106 +    CXXFLAGS+= -DUSE_GPG $(GPGME_INC)
   7.107 +else ifeq ($(OPENPGP),NETPGP)
   7.108 +    CXXFLAGS+= -DUSE_NETPGP $(NETPGP_INC)
   7.109 +endif
   7.110 +
   7.111 +
   7.112 +EXTRA_LIB_PATHS=.:../src:
   7.113  ifdef ETPAN_LIB
   7.114 -	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
   7.115 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
   7.116  endif
   7.117  ifdef GPGME_LIB
   7.118 -	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
   7.119 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
   7.120  endif
   7.121  ifdef NETPGP_LIB
   7.122 -	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
   7.123 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
   7.124 +endif
   7.125 +ifdef CPPUNIT_LIB
   7.126 +    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(CPPUNIT_LIB)):
   7.127  endif
   7.128  
   7.129  # Remove trailing ':'
   7.130  EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
   7.131  
   7.132 -CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
   7.133 -ifneq ($(MAKECMDGOALS),clean)
   7.134 -	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
   7.135 -		$(error The macro NDEBUG must not be defined for test compilation.)
   7.136 -	endif
   7.137 +ifeq ($(BUILD_FOR),Darwin)
   7.138 +    LIBPATH=DYLD_LIBRARY_PATH
   7.139 +else
   7.140 +    LIBPATH=LD_LIBRARY_PATH
   7.141  endif
   7.142  
   7.143 -CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
   7.144 -ifneq ($(MAKECMDGOALS),clean)
   7.145 -	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
   7.146 -		$(error The macro NDEBUG must not be defined for test compilation.)
   7.147 -	endif
   7.148 -endif
   7.149 +# FIXME: this forces a path on execution which overrides system paths for
   7.150 +#        libraries like iconv and causes runtime errors.
   7.151 +#TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
   7.152 +TEST_CMD_PFX=
   7.153  
   7.154 -CPPFLAGS += $(INC_FLAGS) -MMD -MP
   7.155  
   7.156 -all: suitemaker $(TARGET) test_home_ scripts
   7.157 -	
   7.158 -%.o: %.cc
   7.159 -	$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
   7.160 +.PHONY: all
   7.161 +all: suitemaker $(TARGET) scripts
   7.162 +
   7.163 +%.d: %.cc
   7.164 +	$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
   7.165  
   7.166  $(TARGET): $(OBJS)
   7.167 -	$(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
   7.168 +	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
   7.169  
   7.170  .PHONY: suitemaker
   7.171  suitemaker:
   7.172 @@ -114,27 +117,23 @@
   7.173  	$(PY_ENV) gensuitemaker.py --exclude=$(EXCLUDE)
   7.174  endif
   7.175  endif
   7.176 -		
   7.177 -.PHONY: test_home_
   7.178 -test_home_: 
   7.179 -	
   7.180  
   7.181  .PHONY: scripts
   7.182 -scripts: 
   7.183 +scripts:
   7.184  ifdef PY_ENV
   7.185  	$(PY_ENV) genscripts.py
   7.186  endif
   7.187  
   7.188  .PHONY: test
   7.189  test: all
   7.190 -	ulimit -n 20000; $(TEST_DEBUGGER) ./$(TARGET)
   7.191 +	$(TEST_CMD_PFX) $(TEST_DEBUGGER) ./$(TARGET)
   7.192  
   7.193  .PHONY: clean
   7.194  clean:
   7.195 -	$(RM) $(TARGET) $(OBJS) $(DEPS)
   7.196 -	$(RM) $(HERE)/*Tests msg_2.0.asc
   7.197 +	$(RM) $(TARGET) $(TARGET).o $(OBJS) $(notdir $(basename $(OBJS))) $(DEPS)
   7.198 +	$(RM) $(HERE)/*Tests msg_2.0.asc $(HERE)/pEp_test_home
   7.199  
   7.200 -
   7.201 -
   7.202 --include $(DEPS)
   7.203 - 
   7.204 +# If only the goal 'clean' is given, do not generate and include the '%.d' files.¬
   7.205 +ifneq ($(MAKECMDGOALS),clean)
   7.206 +    -include $(DEPS)
   7.207 +endif
     8.1 --- a/test/src/engine_tests/SyncTests.cc	Tue Apr 02 11:34:30 2019 +0200
     8.2 +++ b/test/src/engine_tests/SyncTests.cc	Tue Apr 02 11:34:45 2019 +0200
     8.3 @@ -3,6 +3,9 @@
     8.4  
     8.5  #include <stdlib.h>
     8.6  #include <string>
     8.7 +#include <assert.h>
     8.8 +#include <cpptest.h>
     8.9 +#include "test_util.h"
    8.10  
    8.11  #include "pEpEngine.h"
    8.12  
    8.13 @@ -137,7 +140,8 @@
    8.14      free_identity(self);
    8.15  
    8.16      status = init(&sync, Sync_Adapter::messageToSend, Sync_Adapter::inject_sync_event);
    8.17 -    TEST_ASSERT(status == PEP_STATUS_OK);
    8.18 +    if (status != PEP_STATUS_OK)
    8.19 +        throw std::runtime_error((string("init returned ") + tl_status_string(status)).c_str()); 
    8.20  
    8.21      cout << "initialize sync and start first state machine\n";
    8.22      status = register_sync_callbacks(
    8.23 @@ -146,8 +150,11 @@
    8.24              Sync_Adapter::notifyHandshake,
    8.25              Sync_Adapter::retrieve_next_sync_event
    8.26          );
    8.27 -    TEST_ASSERT(status == PEP_STATUS_OK);
    8.28 -    TEST_ASSERT(sync->sync_state.keysync.state == Sole);
    8.29 +    if (status != PEP_STATUS_OK)
    8.30 +        throw std::runtime_error((string("register sync status returned ") + tl_status_string(status)).c_str()); 
    8.31 +    if (sync->sync_state.keysync.state != Sole) 
    8.32 +        throw std::runtime_error((string("keysync.state was supposed to be ") + to_string((int)Sole) + " but was " + to_string((int)(sync->sync_state.keysync.state))).c_str()); 
    8.33 +      
    8.34  
    8.35      cout << "creating thread for sync\n";
    8.36      sync_thread = new thread(Sync_Adapter::sync_thread, sync, &adapter);
    8.37 @@ -176,4 +183,3 @@
    8.38      cout << "check_sync(): cry for unknown key\n";
    8.39      signal_Sync_event(sync, Sync_PR_keysync, CannotDecrypt);
    8.40  }
    8.41 -