forked from pEp.foundation/pEpJSONServerAdapter
merge 'default' into this - somewhat older - branch to see whether it makes troubles somewhere...
commit
061e5e8d12
@ -0,0 +1,172 @@
|
||||
# Copyright 2017 pEp Security SA
|
||||
#
|
||||
# This file is part of pEp JSON Server Adapter.
|
||||
#
|
||||
# pEp JSON Server Adapter is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License, version 3, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# pEp JSON Server Adapter is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with pEp JSON Server Adapter. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
include Makefile.conf-old
|
||||
|
||||
ifneq ($(wildcard local.conf-old),)
|
||||
$(info ================================================)
|
||||
$(info Overrides in \`local.conf\` are used.)
|
||||
$(info ================================================)
|
||||
endif
|
||||
|
||||
ifdef BUILD_CONFIG
|
||||
$(info ================================================)
|
||||
$(info Overrides in \`$(BUILD_CONFIG)\` are used.)
|
||||
$(info ================================================)
|
||||
endif
|
||||
|
||||
# These source files shall _not_ be part of the libjson-adapter.a:
|
||||
NO_SOURCE=$(wildcard mini-adapter-*.cc) servertest.cc $(wildcard unittest_*.cc) parse_mail.cc
|
||||
|
||||
ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard json_spirit/*.cpp))
|
||||
ALL_SOURCE+= prefix-config.cc
|
||||
ALL_SOURCE+= $(filter-out $(NO_SOURCE),$(wildcard *.cc))
|
||||
DEPENDS0=$(subst .cpp,.d,$(ALL_SOURCE))
|
||||
DEPENDS=$(subst .cc,.d,$(DEPENDS0))
|
||||
ALL_OBJECTS0=$(subst .cpp,.o,$(ALL_SOURCE))
|
||||
ALL_OBJECTS=$(subst .cc,.o,$(ALL_OBJECTS0))
|
||||
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
LIBPATH=LD_LIBRARY_PATH
|
||||
else
|
||||
LIBPATH=DYLD_LIBRARY_PATH
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
LD_EAGER_VAR=LD_BIND_NOW=placeholder
|
||||
else
|
||||
LD_EAGER_VAR=DYLD_BIND_AT_LAUNCH=placeholder
|
||||
endif
|
||||
|
||||
# Create a list of the extra library paths for the loader.
|
||||
# Note that += can not be used here, as it changes the amount of whitespace
|
||||
EXTRA_LIB_PATHS=$(PREFIX)/lib:
|
||||
ifdef BOOST_LIB
|
||||
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(BOOST_LIB)):
|
||||
endif
|
||||
ifdef ENGINE_LIB
|
||||
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ENGINE_LIB)):
|
||||
endif
|
||||
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 UUID_LIB
|
||||
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(UUID_LIB)):
|
||||
endif
|
||||
# Remove trailing ':'
|
||||
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
|
||||
|
||||
CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
|
||||
|
||||
ifdef DEBUG
|
||||
CMD_PFX+= $(LD_EAGER_VAR)
|
||||
endif
|
||||
|
||||
.PHONY: all lib
|
||||
all: $(TARGET) $(TARGET_TEST) $(TARGET_GTEST) parse_mail
|
||||
|
||||
lib: libjson-adapter.a
|
||||
|
||||
$(TARGET): mini-adapter-main.o mini-adapter-impl.o libjson-adapter.a
|
||||
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
$(TARGET)-static: mini-adapter-main.o mini-adapter-impl.o libjson-adapter.a
|
||||
$(CXX) $(CPPFLAGS) $(LDFLAGS) $^ \
|
||||
/Users/lars/local/lib/libpEpEngine.a \
|
||||
/Users/lars/local/lib/libpEpAdapter.a \
|
||||
/Users/lars/local/lib/libetpan.a \
|
||||
/Users/lars/hg/pEpEngine/asn.1/libasn1.a \
|
||||
/usr/local/Cellar/libiconv/1.16/lib/libiconv.a \
|
||||
/usr/local/lib/libboost_system-mt.a \
|
||||
/usr/local/lib/libboost_filesystem-mt.a \
|
||||
/usr/local/lib/libboost_program_options-mt.a \
|
||||
/usr/local/lib/libboost_thread-mt.a \
|
||||
/usr/local/lib/libboost_regex-mt.a /Users/lars/local/lib/libpEpwebserver.a \
|
||||
/usr/local/Cellar/sqlite/3.33.0/lib/libsqlite3.a \
|
||||
/usr/local/Cellar/zlib/1.2.11/lib/libz.a \
|
||||
/usr/local/Cellar/libiconv/1.16/lib/libiconv.a \
|
||||
/Users/lars/local/lib/libsequoia_ffi.a \
|
||||
-o $@
|
||||
|
||||
$(TARGET_TEST): servertest.o libjson-adapter.a
|
||||
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
$(TARGET_GTEST): unittest_json.o unittest_nfc.o unittest_decompose.o unittest_rpc.o \
|
||||
unittest_logger.o unittest_pEp.o unittest_string.o \
|
||||
gtest-all.o gtest_main.o libjson-adapter.a
|
||||
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
parse_mail: parse_mail.o libjson-adapter.a
|
||||
$(CXX) $(CPPFLAGS) $^ $(LDFLAGS) $(LDLIBS) -o $@
|
||||
|
||||
libjson-adapter.a: $(ALL_OBJECTS)
|
||||
$(AR) rcs $@ $^
|
||||
|
||||
gtest-all.o: $(GTEST_DIR)/src/gtest-all.cc
|
||||
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
gtest_main.o: $(GTEST_DIR)/src/gtest_main.cc
|
||||
$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -o $@ -c $<
|
||||
|
||||
%.o: %.cc %.hh
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
%.d: %.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
||||
%.d: %.cc
|
||||
@set -e; rm -f $@; \
|
||||
$(CXX) -MM $(CPPFLAGS) $(CXXFLAGS) $< > $@.$$$$; \
|
||||
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
|
||||
|
||||
.PHONY: install
|
||||
install: all
|
||||
mkdir -v -p "$(PREFIX)/bin" "$(PREFIX)/lib"
|
||||
mkdir -v -p "$(HTML_DIRECTORY)"
|
||||
cp -v ../html/* "$(HTML_DIRECTORY)"
|
||||
cp -v libjson-adapter.a "$(PREFIX)/lib"
|
||||
cp -v "$(TARGET)" "$(TARGET_TEST)" "$(TARGET_GTEST)" "$(PREFIX)/bin"
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -vf "$(TARGET)" "$(TARGET_TEST)" "$(TARGET_GTEST)" parse_mail
|
||||
rm -vf *.o json_spirit/*.o
|
||||
rm -vf *.a json_spirit/*.a
|
||||
rm -vf *.d json_spirit/*.d
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
@echo "The adapter must be installed for $< to work"
|
||||
$(CMD_PFX) "$(PREFIX)/bin/$(TARGET)"
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
@echo "The adapter must be installed for $< to work"
|
||||
$(CMD_PFX) "$(PREFIX)/bin/$(TARGET_TEST)"
|
||||
$(CMD_PFX) "$(PREFIX)/bin/$(TARGET_GTEST)"
|
@ -0,0 +1,161 @@
|
||||
# Copyright 2017 pEp Security SA
|
||||
#
|
||||
# This file is part of pEp JSON Server Adapter.
|
||||
#
|
||||
# pEp JSON Server Adapter is free software: you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License, version 3, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# pEp JSON Server Adapter is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with pEp JSON Server Adapter. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
|
||||
|
||||
|
||||
######### General #########
|
||||
BUILD_ON:=$(shell uname)
|
||||
|
||||
# This variable specifies the platform that the engine should be cross-compiled for.
|
||||
BUILD_FOR=$(BUILD_ON)
|
||||
|
||||
# Cross-compiling is currently not supported.
|
||||
# Maybe you can hack something with `local.conf`.
|
||||
ifneq ($(BUILD_ON),$(BUILD_FOR))
|
||||
$(error "I don't know how to build for $(BUILD_FOR) on $(BUILD_ON).")
|
||||
endif
|
||||
|
||||
# Installation path prefix for libraries and binaries, except for HTML files
|
||||
PREFIX=/usr
|
||||
|
||||
# Installation path for HTML files
|
||||
HTML_DIRECTORY=$(PREFIX)/share/pEp/json-adapter/html
|
||||
|
||||
# Filename of the pEp JSON Server Adapter binary
|
||||
TARGET=pEp-mini-json-adapter
|
||||
|
||||
# Filename of the pEp JSON Server Adapter testing binary
|
||||
TARGET_TEST=servertest
|
||||
|
||||
# Filename of the unittest binary
|
||||
TARGET_GTEST=unittests
|
||||
|
||||
# If empty, create a release build.
|
||||
# Otherwise, create a debug build.
|
||||
# This variable is ineffective in your local.conf file.
|
||||
DEBUG=placeholder
|
||||
|
||||
# If empty, suppress compiler warnings.
|
||||
# Otherwise, print warnings.
|
||||
# This variable is ineffective in your local.conf file.
|
||||
WARN=placeholder
|
||||
|
||||
|
||||
######### C++ #########
|
||||
TARGET_ARCH=
|
||||
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
CXX=g++ -std=c++14 -pthread -fPIC
|
||||
else ifeq ($(BUILD_FOR),Darwin)
|
||||
# clang issues a warning when "-pthread" is used for linking. So, include it in CXXFLAGS, and not in CXX
|
||||
# "c++" != "clang"
|
||||
CXX=c++ -std=c++14 -fPIC
|
||||
endif
|
||||
|
||||
HTML_DIR ?= "html"
|
||||
|
||||
CPPFLAGS=-isystem $(GTEST_DIR)/include -DHTML_DIR=$(HTML_DIR)
|
||||
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
CXXFLAGS=-fstack-protector-all # -fdiagnostics-color=always
|
||||
ifdef WARN
|
||||
CXXFLAGS+= -Wall
|
||||
else
|
||||
CXXFLAGS+= -w
|
||||
endif
|
||||
ifdef DEBUG
|
||||
CXXFLAGS+= -O0 -g -ggdb -DDEBUG_ENABLED
|
||||
else
|
||||
CXXFLAGS+= -O3 -DNDEBUG
|
||||
endif
|
||||
|
||||
CXXFLAGS+=-fvisibility=hidden
|
||||
else ifeq ($(BUILD_FOR),Darwin)
|
||||
CXXFLAGS=-pthread -fstack-protector-all # -fcolor-diagnostics
|
||||
ifdef WARN
|
||||
CXXFLAGS+= -Wall
|
||||
else
|
||||
CXXFLAGS+= -w
|
||||
endif
|
||||
ifdef DEBUG
|
||||
CXXFLAGS+= -O0 -g -DDEBUG_ENABLED
|
||||
else
|
||||
CXXFLAGS+= -O3 -DNDEBUG
|
||||
endif
|
||||
|
||||
CXXFLAGS+=-fvisibility=hidden
|
||||
endif
|
||||
|
||||
CXXFLAGS+= -Ijson_spirit $(BOOST_INC) $(ENGINE_INC) $(ETPAN_INC) $(GPGME_INC) $(UUID_INC)
|
||||
LDFLAGS+= $(BOOST_LIB) $(ENGINE_LIB) $(ETPAN_LIB) $(GPGME_LIB) $(UUID_LIB)
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
LDLIBS+= -lpEpEngine -lpEpAdapter -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_regex
|
||||
GTEST_DIR=/usr/src/googletest/googletest/
|
||||
else ifeq ($(BUILD_FOR),Darwin)
|
||||
LDLIBS+= -lpEpEngine -lpEpAdapter -lboost_system-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_thread-mt -lboost_regex-mt
|
||||
endif
|
||||
|
||||
LDLIBS+=$(WEBSERVER_LIB)
|
||||
|
||||
ifeq ($(MIME_LIB),etpan)
|
||||
LDLIBS+=-letpan
|
||||
else ifeq ($(MIME_LIB),pEpMIME)
|
||||
LDLIBS+=-lpEpMIME
|
||||
else
|
||||
$(error "You must set MIME_LIB to 'etpan' or 'pEpMIME'!" )
|
||||
endif
|
||||
|
||||
######### Google Test #########
|
||||
#GTEST_DIR=
|
||||
|
||||
|
||||
######### boost #########
|
||||
BOOST_INC=
|
||||
BOOST_LIB=
|
||||
|
||||
|
||||
######### Engine #########
|
||||
ENGINE_INC=-I$(HOME)/code/engine/build/include
|
||||
ENGINE_LIB=-L$(HOME)/code/engine/build/lib
|
||||
|
||||
|
||||
######### Etpan #########
|
||||
ETPAN_INC=-I$(HOME)/code/libetpan/build/include
|
||||
ETPAN_LIB=-L$(HOME)/code/libetpan/build/lib
|
||||
|
||||
|
||||
######### pEp::Webserver #########
|
||||
WEBSERVER_LIB=$(HOME)/local/lib/libpEpwebserver.a
|
||||
|
||||
|
||||
######### GPGME #########
|
||||
GPGME_INC=
|
||||
GPGME_LIB=
|
||||
|
||||
|
||||
######### OSSP uuid #########
|
||||
UUID_INC=
|
||||
UUID_LIB=
|
||||
|
||||
|
||||
######### Footer #########
|
||||
-include $(HERE)/local.conf-old
|
||||
|
||||
ifdef BUILD_CONFIG
|
||||
-include $(BUILD_CONFIG)
|
||||
endif
|
@ -0,0 +1,29 @@
|
||||
#ifndef JSON_ADAPTER_CONFIG
|
||||
#define JSON_ADAPTER_CONFIG
|
||||
|
||||
#if (__cplusplus >= 201606) // std::string_view is C++17.
|
||||
# include <string_view>
|
||||
typedef std::string_view sv;
|
||||
|
||||
#else // in C++11 / C++14 use boost::string_view instead.
|
||||
# include <boost/utility/string_view.hpp>
|
||||
typedef boost::string_view sv;
|
||||
|
||||
// if sv==boost::string_view these operations are not provided, neither by boost nor by the stdlib. :-(
|
||||
inline
|
||||
std::string& operator+=(std::string& s, sv v)
|
||||
{
|
||||
s.append(v.data(), v.size());
|
||||
return s;
|
||||
}
|
||||
|
||||
inline
|
||||
std::string operator+(std::string s, sv v)
|
||||
{
|
||||
return s += v;
|
||||
}
|
||||
|
||||
#endif // C++17 switch
|
||||
|
||||
|
||||
#endif // JSON_ADAPTER_CONFIG
|
Loading…
Reference in New Issue