Browse Source

Keep me away from the default branch. Reverted to 1954:2f1ed8cf6b6f, because though damiano's Makefile changes are sexy, they'll break ppl.

doc_update_sequoia
Krista Bennett 5 years ago
parent
commit
7de4270748
12 changed files with 178 additions and 369 deletions
  1. +0
    -1
      .hgignore
  2. +18
    -17
      Makefile
  3. +26
    -17
      Makefile.conf
  4. +2
    -1
      README.txt
  5. +17
    -15
      asn.1/Makefile
  6. +0
    -55
      build-config/Darwin.conf
  7. +0
    -54
      build-config/Linux.conf
  8. +0
    -88
      build-config/common.conf
  9. +7
    -11
      db/Makefile
  10. +56
    -44
      src/Makefile
  11. +12
    -15
      sync/Makefile
  12. +40
    -51
      test/Makefile

+ 0
- 1
.hgignore View File

@ -3,7 +3,6 @@ syntax: regexp
^asn\.1/Makefile\.am\.sample$
^asn\.1/libasn1\.a$
.*xcuserdata/
^build/
syntax: glob
*.orig


+ 18
- 17
Makefile View File

@ -1,33 +1,27 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# this file is under GNU General Public License v3.0
# see LICENSE.txt
HERE_REL := $(notdir $(CURDIR))
include Makefile.conf
# YML_PATH is needed in the environment of every call to a program of the YML2 distribution
export YML_PATH=$(YML2_PATH)
# add it to the environment of all executed programs:
export YML_PATH
.PHONY: all
all:
$(MAKE) -C asn.1 generate
$(MAKE) -C asn.1
$(MAKE) -C sync
$(MAKE) -C src all
.PHONY: install
.PHONY: clean build_test test package install uninstall db
install: all
$(MAKE) -C src install
$(MAKE) -C asn.1 install
.PHONY: uninstall
uninstall:
$(MAKE) -C src uninstall
$(MAKE) -C asn.1 uninstall
.PHONY: clean
clean:
$(MAKE) -C src clean
$(MAKE) -C test clean
@ -35,19 +29,26 @@ clean:
$(MAKE) -C sync clean
$(MAKE) -C asn.1 clean
.PHONY: test
test: all
$(MAKE) -C test test
$(MAKE) -C test unit_tests
.PHONY: unit_tests
unit_tests: all
$(MAKE) -C test unit_tests
.PHONY: package
package: clean
cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 "$(HERE_REL)"
cd .. ; COPYFILE_DISABLE=true tar cjf pEpEngine.tar.bz2 pEpEngine
.PHONY: db
db:
$(MAKE) -C db db
windist:
ifneq ($(BUILD_FOR),Windoze)
@echo use BUILD_FOR=Windoze \(did you forget -e ?\)
else
make clean
$(MAKE) all
$(MAKE) -C test all
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
endif

+ 26
- 17
Makefile.conf View File

@ -1,21 +1,30 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
# this file is in the Public Domain
# 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.
BUILD_ON=$(shell uname)
BUILD_FOR=$(BUILD_ON)
OPTIMIZE=-g -Wall -O0 -fPIC -DDEBUG_ERRORSTACK
#OPTIMIZE=-O3 -Wall -DNDEBUG -std=c99
LD=$(CC)
#CC=gcc-mp-4.9 -std=c99 -fstrict-aliasing -Wstrict-aliasing=3
#LD=gcc-mp-4.9
SYSTEM_DB=/usr/local/share/pEp/system.db
PREFIX=$(HOME)
YML2PROC=$(HOME)/yml2/yml2proc
YML_OPTS=--encoding=utf8
YML_PATH=$(HOME)/yml2
ASN1C=asn1c
ASN1C_INCLUDE=/opt/local/share/asn1c
#ETPAN_IN=$(HOME)
#LIBGPGME=/opt/local/lib/libgpgme.11.dylib
# 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.
# C makros (not environment variables) to overwrite:
#
# DEFAULT_KEYSERVER - string with default keyserver
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
BUILD_CONFIG:=$(dir $(lastword $(MAKEFILE_LIST)))build-config
#EXTRAMACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
include $(BUILD_CONFIG)/common.conf
# cross-compiling is currently not supported, but maybe you can hack something with `PLATFORM_OVERRIDE`
ifeq ($(BUILD_ON),$(BUILD_FOR))
include $(BUILD_CONFIG)/$(BUILD_ON).conf
else
$(error I don't know how to build for $(BUILD_FOR) on $(BUILD_ON))
endif
ifdef PLATFORM_OVERRIDE
include $(BUILD_CONFIG)/$(PLATFORM_OVERRIDE).conf
endif
# second instance for testing
#EXTRAMACROS=-DLOCAL_DB_FILENAME=\".pEp_management2.db\"
#TARGET=libpEpEngine2.dylib

+ 2
- 1
README.txt View File

@ -60,7 +60,8 @@ p≡p engine is depending on the following FOSS libraries:
* NetPGP/p≡p, see https://cacert.pep.foundation/dev/repos/netpgp-et/
* 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.
* Asn1c, download from https://lionet.info/soft/asn1c-0.9.27.tar.gz
(Debian's version 0.9.24 does not work)
* yml2, which needs lxml (where to get?)


+ 17
- 15
asn.1/Makefile View File

@ -1,35 +1,37 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# This file is under GNU General Public License 3.0
# see LICENSE.txt
include ../Makefile.conf
ALL_SOURCE=$(wildcard *.c)
ifeq ($(BUILD_ON),Linux)
ifeq ($(BUILD_FOR),Linux)
CC=gcc
CFLAGS?=-fPIC
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
endif
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
libasn1.a: $(ALL_OBJECTS)
ar -rc $@ $^
ar -rc $@ $(ALL_OBJECTS)
# "converter-sample.c" is the example file containing a "main()" function generated by ans1c.
.PHONY: generate
generate: Sync-Protocols.c
rm -f converter-sample.c
%.o: %.c %.h
$(CC) $(CFLAGS) $(CFLAGS_GENERATED) -I. $(ASN1C_INC) -c $< -o $@
$(CC) $(CFLAGS) $(OPTIMIZE) -I. -I$(ASN1C_INCLUDE) -c $< -o $@
Sync-Protocols.c: pEp.asn1 devicegroup.asn1 protocols.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message $^
Sync-Protocols.c: protocols.asn1 devicegroup.asn1 pEp.asn1
$(ASN1C) -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 devicegroup.asn1 $<
.PHONY: clean
clean:
rm -f *.a *.o *.c *.h *.sample
.PHONY: install
install: libasn1.a
cp $< $(PREFIX)/lib/
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/lib/libasn1.a

+ 0
- 55
build-config/Darwin.conf View File

@ -1,55 +0,0 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
######### General #########
TARGET=libpEpEngine.dylib
######### C #########
# clang issues a warning when "-pthread" is used for linking. So, include it in CFLAGS, and not in CC
CC=clang -std=c99
CFLAGS=-pthread -fPIC -fstrict-aliasing -fcolor-diagnostics
ifdef WARN
CFLAGS+= -Wall -pedantic
else
CFLAGS+= -w
endif
ifdef DEBUG
CFLAGS+= -O0 -g -DDEBUG_ERRORSTACK
else
CFLAGS+= -O3 -DNDEBUG
endif
CFLAGS_GENERATED=
######### C++ #########
# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
CXX=clang -std=c++11
CXXFLAGS=-pthread -fcolor-diagnostics -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
CXXFLAGS+= -w
endif
ifdef DEBUG
CXXFLAGS+= -O0 -g
else
CXXFLAGS+= -O3 -DNDEBUG
endif
######### C and C++ #########
######### YML2 #########
######### asn1c #########
######### libetpan #########
######### OpenPGP #########
LIBGPGME=libgpgme.dylib
GPGME_LIB=-L/opt/local/lib
GPGME_INC=-I/opt/local/include
######### Engine internals #########
######### Misc #########

+ 0
- 54
build-config/Linux.conf View File

@ -1,54 +0,0 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
######### General #########
TARGET=libpEpEngine.so
######### C #########
CC=gcc -std=c99 -pthread
CFLAGS=-fPIC -fstrict-aliasing -fdiagnostics-color=always
ifdef WARN
CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
else
CFLAGS+= -w
endif
ifdef DEBUG
CFLAGS+= -Og -ggdb -DDEBUG_ERRORSTACK
else
CFLAGS+= -O3 -DNDEBUG
endif
# '-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.
CFLAGS_GENERATED=-Wno-cpp
######### C++ #########
CXX=g++ -std=gnu++11 -pthread
CXXFLAGS=-fdiagnostics-color=always -I../src -I../asn.1 $(ETPAN_INC)
ifdef WARN
CXXFLAGS+=
else
CXXFLAGS+= -w
endif
ifdef DEBUG
CXXFLAGS+= -Og -ggdb
else
CXXFLAGS+= -O3 -DNDEBUG
endif
######### C and C++ #########
######### YML2 #########
######### asn1c #########
######### libetpan #########
######### OpenPGP #########
LIBGPGME=libgpgme.so.11
GPGME_LIB=
GPGME_INC=
######### Engine internals #########
######### Misc #########

+ 0
- 88
build-config/common.conf View File

@ -1,88 +0,0 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
# General remark: to use (only) system libraries, set all the *_INC and *_LIB variables to the empty string.
######### General #########
BUILD_ON:=$(shell uname)
BUILD_FOR=$(BUILD_ON)
# Installation path prefix for libraries and binaries, except for system.db
PREFIX=$(HOME)
# Installation path for system.db
SYSTEM_DB=/usr/local/share/pEp/system.db
# Filename of the pEpEngine library
#TARGET This option is platform-specific
# If not empty, create a debug build
DEBUG=placeholder
# If not empty, print compiler warnings
WARN=placeholder
######### C #########
#CC This option is platform-specific
CPPFLAGS=
#CFLAGS This option is platform-specific
# Additional CFLAGS used for compiling ASN1C-generated code
#CFLAGS_GENERATED This option is platform-specific
######### C++ #########
#CXX This option is platform-specific
#CXXFLAGS This option is platform-specific
######### C and C++ #########
TARGET_ARCH=
# The following two variables will be appended to. You can thus not set them to a fixed value here.
LDFLAGS=
LDLIBS=
######### YML2 #########
YML2_PATH=$(HOME)/yml2
YML2_PROC=$(YML2_PATH)/yml2proc
YML2_OPTS=--encoding=utf8
######### asn1c #########
# asn1c binary
ASN1C=asn1c
# asn1c include search flag
ASN1C_INC=
#ASN1C_INC= -I$(HOME)/include
######### libetpan #########
# libetpan library search flag
ETPAN_LIB=-L$(PREFIX)/lib
# libetpan include search flag
ETPAN_INC=-I$(PREFIX)/include
######### OpenPGP #########
# Path of GPG binary
GPG_CMD=gpg
ifneq ($(shell which gpg2),)
GPG_CMD = gpg2
endif
# Selects OpenPGP implementation. must be either `GPG` or `NETPGP`
OPENPGP=GPG
# Path of libGPGME binary
#LIBGPGME This option is platform-specific
# libGPGME library search flag
#GPGME_LIB= This option is platform-specific
# libGPGME include search flag
#GPGME_INC= This option is platform-specific
# NETPGP library search flag
NETPGP_LIB=
#NETPGP_LIB=-L$(PREFIX)/lib
# libGPGME include search flag
NETPGP_INC=
#NETPGP_INC=-I$(PREFIX)/include
######### Engine internals #########
# C macros (not environment variables) that can be overridden:
# DEFAULT_KEYSERVER - string with default keyserver
# CRASHDUMP_DEFAULT_LINES - number of log lines to deliver for crashdumps
# Example:
# EXTRA_MACROS=-DDEFAULT_KEYSERVER=\"default-server.org\" -DCRASHDUMP_DEFAULT_LINES=23
EXTRA_MACROS=
######### Misc #########
# FIXME Maybe include these variables here. Check how they are used throughout the project before setting them here
#LLDB_BIN

+ 7
- 11
db/Makefile View File

@ -1,26 +1,22 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# This file is under GNU General Public License 3.0
# see LICENSE.txt
include ../Makefile.conf
.PHONY: db
db: system.db
DICOS = $(wildcard *.csv)
dicos=$(wildcard *.csv)
# The 'mv' keeps a backup db around
system.db: create_system_db.sql $(DICOS)
system.db: create_system_db.sql $(dicos)
-mv -f $@ $@~
sqlite3 -batch $@ < $<
for c in $(DICOS) ; do echo "$$c" ; echo .import "$$c" wordlist | sqlite3 -batch -csv $@ ; done
for c in $(dicos); do echo $$c ; echo .import "$$c" wordlist | sqlite3 -batch -csv $@ ; done
.PHONY: clean install
.PHONY: install
install: system.db
mkdir -p `dirname $(SYSTEM_DB)`
cp system.db $(SYSTEM_DB)
.PHONY: clean
clean:
rm -f system.db system.db~
rm -f system.db

+ 56
- 44
src/Makefile View File

@ -1,55 +1,70 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
include ../Makefile.conf
CFLAGS+= $(ETPAN_INC) -I../asn.1 -DSYSTEM_DB=\"$(SYSTEM_DB)\" $(EXTRA_MACROS)
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -shared
LDLIBS+= -lc -lasn1 -letpan
ETPAN_IN?=$(HOME)
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)
CFLAGS+= -DSQLITE_THREADSAFE=1
#LDFLAGS+= -L/opt/local/lib
LDLIBS+= -lsqlite3 -lz -liconv
else
$(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
ifeq ($(BUILD_FOR),Darwin)
TARGET?=libpEpEngine.dylib
MACOSX_VERSION_MIN=10.6
LIBGPGME?=libgpgme.dylib
CC?=clang -std=c99 -pthread
LD?=clang
CFLAGS?= -I$(ETPAN_IN)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
-DSYSTEM_DB=\"$(SYSTEM_DB)\" -I../asn.1 $(EXTRAMACROS)
LDFLAGS?= -lc -shared -arch x86_64 \
-L$(ETPAN_IN)/lib -L/usr/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1 -lz -liconv
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else ifeq ($(BUILD_ON),Linux)
ifeq ($(BUILD_FOR),Linux)
CFLAGS+= -DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
LDLIBS+= -ldl -luuid
else
$(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
ifeq ($(BUILD_FOR),Linux)
TARGET=libpEpEngine.so
LIBGPGME?=libgpgme.so.11
CC=gcc -std=c99
CFLAGS?= -I$(ETPAN_IN)/include $(OPTIMIZE) -fPIC -pedantic -DSYSTEM_DB=\"$(SYSTEM_DB)\" \
-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE -I../asn.1 $(EXTRAMACROS)
LDFLAGS?= -L$(ETPAN_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1 -luuid
else
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
else
$(error I don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
$(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif
ifeq ($(OPENPGP),GPG)
DEBUG?=NO
ifeq ("$(DEBUG)","NO")
CFLAGS+= -DNDEBUG
endif
OPENPGP?=GPG
ifeq ("$(OPENPGP)","GPG")
NO_SOURCE=pgp_netpgp.c
CFLAGS+= -DUSE_GPG $(GPGME_INC) -DLIBGPGME=\"$(LIBGPGME)\"
LDFLAGS+= $(GPGME_LIB)
# No extra LDLIBS are needed here, because GPGME is dynamically loaded
else ifeq ($(OPENPGP),NETPGP)
GPGME_IN?=$(HOME)
CFLAGS+= -DUSE_GPG -I$(GPGME_IN)/include -DLIBGPGME=\"$(LIBGPGME)\"
#LDFLAGS+= -L$(GPGME_IN)/lib -lgpgme
else ifeq ("$(OPENPGP)","NETPGP")
NO_SOURCE=pgp_gpg.c
CFLAGS+= -DUSE_NETPGP $(NETGPG_INC)
LDFLAGS+= $(NETGPG_LIB)
LDLIBS+= -lnetpgp -lcurl
NETPGP_IN?=$(HOME)
CFLAGS+= -DUSE_NETPGP -I$(NETPGP_IN)/include
LDFLAGS+= -L$(NETPGP_IN)/lib -lnetpgp -lcurl
else
$(error Unknown OpenPGP library: $(OPENPGP))
$(error Unknown OpenPGP library : $(OPENPGP))
endif
ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
.PHONY: all
all: $(TARGET)
-include Makefile.protocols
include Makefile.protocols
%.d: %.c
@set -e; rm -f $@; \
@ -57,32 +72,29 @@ all: $(TARGET)
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
# If only the goal 'clean' is given, do not generate and include the '%.d' files.
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPENDS)
endif
-include $(DEPENDS)
#platform_windows.o: platform_windows.cpp
# $(CXX) $(CXX_FLAGS) -o $@ -c $<
$(TARGET): libpEpEngine.a
$(CC) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
$(LD) $(ALL_OBJECTS) $(LDFLAGS) -o $@
.PHONY: objects
objects: $(ALL_OBJECTS)
libpEpEngine.a: $(ALL_OBJECTS)
ar -rc $@ $^
ar -r $@ $(ALL_OBJECTS)
.PHONY: clean
clean:
rm -f *.d *.o *.a $(TARGET) *.dll *.so *.zip *.d.* *.def *~
.PHONY: install
install: $(TARGET)
mkdir -p "$(PREFIX)/lib/"
cp $< $(PREFIX)/lib/
mkdir -p $(PREFIX)/include/pEp
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/
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/lib/$(TARGET)
rm -rf $(PREFIX)/include/pEp

+ 12
- 15
sync/Makefile View File

@ -1,38 +1,35 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# This file is under GNU General Public License 3.0
# see LICENSE.txt
include ../Makefile.conf
.PHONY: all
all: .codegen
# Currently not in use, kept for historic reasons
skeleton: .actions
.codegen: .statemachines .actions
cp -f generated/*.* ../src
touch $@
touch .codegen
.actions: devicegroup.fsm gen_actions.ysl2 fsm.yml2 functions.ysl2
$(YML2_PROC) $(YML2_OPTS) -y gen_actions.ysl2 $< -o $@
$(YML2PROC) $(YML_OPTS) -y gen_actions.ysl2 $< -o $@
.statemachines: devicegroup.fsm gen_statemachine.ysl2 fsm.yml2 functions.ysl2
$(YML2_PROC) $(YML2_OPTS) -y gen_statemachine.ysl2 $< -o $@
$(YML2PROC) $(YML_OPTS) -y gen_statemachine.ysl2 $< -o $@
.PHONY: clean
clean:
rm -f *.xml *.xsl *.dot *.svg \
$(patsubst generated/%,../src/%,$(wildcard generated/*.*)) \
../generated/* ../skeletons/* .statemachines .actions .codegen \
generated/Makefile.protocols
rm -f *.xml *.xsl \
$(pathsub generated/%, ../src/% $(wildcard generated/*.*)) \
../generated/* ../skeletons/* .statemachines .actions *.dot *.svg
%.xml: %.fsm
$(YML2_PATH)/yml2c $< -o $@
yml2c $< -o $@
%.dot: gen_dot.ysl2 devicegroup.fsm
$(YML2_PROC) $(YML2_OPTS) -y $^
%.dot: devicegroup.fsm gen_dot.ysl2
$(YML2PROC) $(YML_OPTS) -y gen_dot.ysl2 $<
%.svg: %.dot
dot -Tsvg -o $@ $<

+ 40
- 51
test/Makefile View File

@ -1,65 +1,59 @@
# Copyright 2017, pEp Foundation
# This file is part of pEpEngine
# This file may be used under the terms of the GNU General Public License version 3
# This file is under GNU General Public License 3.0
# see LICENSE.txt
HERE:=$(CURDIR)
HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include ../Makefile.conf
TARGET=pEpEngineTest
unexport GNUPGHOME
TEST_HOME=$(HERE)/test_home
TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
CC?=g++ -std=gnu++11 -pthread
CXX?=g++ -std=gnu++11 -pthread
LD?=$(CXX)
LDFLAGS?=-L$(HOME)/lib
LDLIBS?=-letpan -lpEpEngine -lstdc++ -L../asn.1 -lasn1
ifeq ($(BUILD_FOR),Linux)
LDLIBS+= -luuid
LDLIBS+= -luuid
endif
CXXFLAGS?=-std=c++11 -g -O0 -I../src -I../asn.1
# CXXFLAGS=-O3 -DNDEBUG
ifeq ($(OPENPGP),NETPGP)
LDLIBS+= -lnetpgp
ifeq ("$(OPENPGP)","NETPGP")
LDLIBS+= -lnetpgp
endif
ifeq ($(shell uname),Darwin)
LIBPATH=DYLD_LIBRARY_PATH
LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
else
LIBPATH=LD_LIBRARY_PATH
LLDB_BIN=lldb
endif
# 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.
# Note that += can not be used here, as it changes the amount of whitespace
EXTRA_LIB_PATHS=../src:
ifdef ETPAN_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
endif
ifdef GPGME_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
endif
ifdef NETPGP_LIB
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
endif
# Remove trailing ':'
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME)
TARGET=pEpEngineTest
UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
.PHONY: all
all: $(TARGET) $(UNIT_TESTS)
.PHONY: clean
# don't delete .o files!
.PRECIOUS: %.o
.PHONY: test_home_
unexport GNUPGHOME;
TEST_HOME=$(HERE)/test_home
TEST_GNUPGHOME=$(TEST_HOME)/.gnupg
ifeq ($(shell which gpg2), )
GPG_CMD = gpg
else
GPG_CMD = gpg2
endif
ifeq ($(shell uname), Darwin)
LIBPATH = DYLD_LIBRARY_PATH
LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
else
LIBPATH = LD_LIBRARY_PATH
LLDB_BIN = lldb
endif
TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
test_home_:
-gpgconf --kill gpg-agent
-HOME=$(TEST_HOME) gpgconf --kill gpg-agent
@ -68,17 +62,15 @@ test_home_:
mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
.PHONY: clean
clean:
rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
.PHONY: test
test: $(TARGET) test_home_
$(TEST_CMD_PFX) ./$<
test: pEpEngineTest test_home_
$(TEST_CMD_PFX) ./pEpEngineTest
%_test : %_test.o test_util.o
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
%_run : % test_home_
$(TEST_CMD_PFX) ./$<
@ -92,10 +84,7 @@ test: $(TARGET) test_home_
%_gdb : % test_home_
$(TEST_CMD_PFX) gdb ./$<
.PHONY: unit_tests
unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
# Installs the engine, not the test binaries
.PHONY: install
install:
$(MAKE) -C .. install
make -C .. install

Loading…
Cancel
Save