z/OS: Support
Well... It compiles now with the master branch. It's time for a rebase.pull/62/head
parent
026cf763fb
commit
b1a6e790df
|
@ -32,7 +32,10 @@ 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).)
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
$(warning Generating sources for z/OS)
|
||||
endif
|
||||
ONLY_GENERATE=true
|
||||
endif
|
||||
|
||||
# Installation path prefix for libraries and binaries, except for system.db
|
||||
|
@ -85,7 +88,7 @@ endif
|
|||
LDLIBS=
|
||||
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
CC=xlclang -std=c99
|
||||
CC=xlclang
|
||||
else ifeq ($(BUILD_FOR),Linux)
|
||||
CC=gcc -std=c99 -pthread
|
||||
else ifeq ($(BUILD_FOR),Darwin)
|
||||
|
@ -93,7 +96,7 @@ else ifeq ($(BUILD_FOR),Darwin)
|
|||
endif
|
||||
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
CFLAGS+= -Wno-gnu-include-next -qnosearch -I$(HERE) -I.
|
||||
CFLAGS= -Wno-gnu-include-next -qnosearch -I$(HERE) -I.
|
||||
CFLAGS+= -I/usr/lpp/java/J8.0_64/include -I/usr/include
|
||||
CFLAGS+= -DZOS -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112L -qlanglvl=NOLIBEXT
|
||||
else ifeq ($(BUILD_FOR),Linux)
|
||||
|
@ -104,8 +107,18 @@ endif
|
|||
|
||||
# The flag -DNDEBUG will always be removed from CFLAGS for compiling tests.
|
||||
# The tests do not work properly, if compiled with -DNDEBUG
|
||||
CFLAGS=
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
ifdef WARN
|
||||
CFLAGS+= -Wall -pedantic
|
||||
else
|
||||
CFLAGS+= -w
|
||||
endif
|
||||
ifdef DEBUG
|
||||
CFLAGS+= -g -DDEBUG_ERRORSTACK
|
||||
else
|
||||
CFLAGS+= -O3 -DNDEBUG
|
||||
endif
|
||||
else ifeq ($(BUILD_FOR),Linux)
|
||||
ifdef WARN
|
||||
CFLAGS+= -Wall -pedantic -Wstrict-aliasing=3
|
||||
else
|
||||
|
@ -158,7 +171,6 @@ CXXFLAGS+=-pthread
|
|||
# The flag -DNDEBUG will always be removed from CPPFLAGS for compiling tests.
|
||||
#
|
||||
# The tests do not work properly, if compiled with -DNDEBUG
|
||||
CXXFLAGS=
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
CXXFLAGS+= -fdiagnostics-color=auto -Wno-gnu-include-next
|
||||
CXXFLAGS+= -qnosearch -I$(HERE) -I. -I../src -I../asn.1 $(ETPAN_INC) -I/usr/lpp/java/J8.0_64/include -I/usr/include
|
||||
|
@ -203,9 +215,10 @@ endif
|
|||
|
||||
|
||||
######### C and C++ #########
|
||||
ifeq ($(BUILD_FOR),Darwin)
|
||||
CPPFLAGS+=-D_DARWIN_C_SOURCE
|
||||
LDLIBS+=-liconv
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
CPPFLAGS=-W "l,xplink,dll" -W "c,float(ieee),xplink,dll,exportall"
|
||||
else ifeq ($(BUILD_FOR),Darwin)
|
||||
CPPFLAGS=-D_DARWIN_C_SOURCE
|
||||
else
|
||||
LDLIBS+=-luuid
|
||||
endif
|
||||
|
@ -260,7 +273,11 @@ ETPAN_INC=
|
|||
|
||||
######### OpenPGP #########
|
||||
# Selects OpenPGP implementation. must be `SEQUOIA`
|
||||
OPENPGP?=SEQUOIA
|
||||
ifeq ($(BUILD_FOR),OS/390)
|
||||
OPENPGP=NETPGP
|
||||
else
|
||||
OPENPGP=SEQUOIA
|
||||
endif
|
||||
|
||||
# Sequoia-specific variables
|
||||
SEQUOIA_CFLAGS+=
|
||||
|
|
32
src/Makefile
32
src/Makefile
|
@ -5,22 +5,21 @@
|
|||
|
||||
include ../Makefile.conf
|
||||
|
||||
ifdef PER_USER_DIRECTORY
|
||||
EXTRA_MACROS+= -DPER_USER_DIRECTORY=$(PER_USER_DIRECTORY)
|
||||
CFLAGS+= $(ETPAN_INC) $(PEP_MIME_INC) -I../asn.1 $(EXTRA_MACROS)
|
||||
LDFLAGS+= $(ETPAN_LIB) $(PEP_MIME_LIB) -L../asn.1
|
||||
ifneq ($(BUILD_ON),OS/390)
|
||||
LDFLAGS+= -shared
|
||||
endif
|
||||
|
||||
ifdef PER_MACHINE_DIRECTORY
|
||||
EXTRA_MACROS+= -DPER_MACHINE_DIRECTORY=\"$(PER_MACHINE_DIRECTORY)\"
|
||||
endif
|
||||
|
||||
LDLIBS+= -lc -lasn1
|
||||
NO_SOURCE=
|
||||
|
||||
ifndef PEP_MIME
|
||||
CFLAGS+= $(ETPAN_INC)
|
||||
LDFLAGS+= $(ETPAN_LIB)
|
||||
LDLIBS+= -letpan
|
||||
ifeq ($(BUILD_ON),OS/390)
|
||||
LDLIBS+= -letpan-no-mt
|
||||
else
|
||||
LDLIBS+= -letpan
|
||||
endif
|
||||
else
|
||||
LDFLAGS+= -L../pEpMIME -shared
|
||||
LDLIBS+= -lpEpMIME
|
||||
NO_SOURCE+= etpan_mime.c
|
||||
endif
|
||||
|
@ -31,7 +30,11 @@ CPPFLAGS+= -DSQLITE_THREADSAFE=1
|
|||
LDFLAGS+= -L../asn.1 -shared
|
||||
LDLIBS+= -lc -lasn1
|
||||
|
||||
ifeq ($(BUILD_ON),Darwin)
|
||||
|
||||
ifeq ($(BUILD_ON),OS/390)
|
||||
OPENPGP=ZOS
|
||||
SQLITE3_FROM_OS=1
|
||||
else ifeq ($(BUILD_ON),Darwin)
|
||||
ifeq ($(BUILD_FOR),Darwin)
|
||||
LDLIBS+= -lz -liconv -mmacosx-version-min=10.10
|
||||
else
|
||||
|
@ -73,6 +76,9 @@ endif
|
|||
ALL_SOURCE=$(filter-out $(NO_SOURCE),$(wildcard *.c))
|
||||
DEPENDS=$(subst .c,.d,$(ALL_SOURCE))
|
||||
ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
|
||||
ifeq ($(BUILD_ON),OS/390)
|
||||
ALL_OBJECTS+=/usr/lpp/java/J8.0_64/bin/classic/libjvm.x
|
||||
endif
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
|
@ -90,7 +96,7 @@ ifneq ($(MAKECMDGOALS),clean)
|
|||
endif
|
||||
|
||||
$(TARGET): libpEpEngine.a
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(ALL_OBJECTS) $(LDFLAGS) $(LDLIBS) -o $@
|
||||
$(CC) -o $@ $(CPPFLAGS) $(LDFLAGS) $(CFLAGS) $(ALL_OBJECTS) $(LDLIBS)
|
||||
|
||||
.PHONY: objects clean install_headers install uninstall beinstall
|
||||
|
||||
|
|
|
@ -566,7 +566,9 @@ struct mailimf_date_time * timestamp_to_etpantime(const timestamp *ts)
|
|||
result->dt_day = ts->tm_mday;
|
||||
result->dt_month = ts->tm_mon + 1;
|
||||
result->dt_year = ts->tm_year + 1900;
|
||||
#ifndef ZOS
|
||||
result->dt_zone = (int) (ts->tm_gmtoff / 36L);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -585,13 +587,16 @@ timestamp * etpantime_to_timestamp(const struct mailimf_date_time *et)
|
|||
result->tm_mday = et->dt_day;
|
||||
result->tm_mon = et->dt_month - 1;
|
||||
result->tm_year = et->dt_year - 1900;
|
||||
#ifndef ZOS
|
||||
result->tm_gmtoff = 36L * (long) et->dt_zone;
|
||||
#endif
|
||||
|
||||
// Normalize to UTC and then forget the offset.
|
||||
time_t t = timegm_with_gmtoff(result);
|
||||
gmtime_r(&t, result);
|
||||
#ifndef ZOS
|
||||
result->tm_gmtoff = 0;
|
||||
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
// This file is under GNU General Public License 3.0
|
||||
// see LICENSE.txt
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <pthread.h>
|
||||
|
||||
typedef struct _pEpNetPGPSession {
|
||||
pthread_mutex_t curl_mutex;
|
||||
} pEpNetPGPSession;
|
|
@ -0,0 +1,8 @@
|
|||
#ifdef ZOS
|
||||
#ifdef __cplusplus
|
||||
#undef _EXT
|
||||
#define _NO_EXT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include_next <stdlib.h>
|
|
@ -0,0 +1,10 @@
|
|||
#ifdef ZOS
|
||||
#ifndef __cplusplus
|
||||
char * stpcpy (char *dst, const char *src);
|
||||
char * strndup (const char *s, size_t n);
|
||||
size_t strnlen (const char *s, size_t maxlen);
|
||||
#endif
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#include_next <string.h>
|
|
@ -22,13 +22,21 @@ DYNAMIC_API time_t timegm_with_gmtoff(const timestamp* ts)
|
|||
if (!_ts)
|
||||
return -1;
|
||||
|
||||
#if defined(ZOS)
|
||||
const time_t raw_time = mktime(_ts);
|
||||
#else
|
||||
const time_t raw_time = timegm(_ts);
|
||||
#endif
|
||||
if(raw_time==-1)
|
||||
return -1;
|
||||
|
||||
free_timestamp(_ts);
|
||||
|
||||
#if defined(ZOS)
|
||||
return raw_time;
|
||||
#else
|
||||
return raw_time - ts->tm_gmtoff;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@ SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
|
|||
OBJS:=$(addsuffix .o,$(basename $(SRCS)))
|
||||
DEPS:=$(OBJS:.o=.d)
|
||||
|
||||
ifeq ($(BUILD_ON),OS/390)
|
||||
OBJS+=../src/libpEpEngine.x
|
||||
endif
|
||||
|
||||
LDFLAGS+= -L../asn.1 -L../src $(ETPAN_LIB) $(GTEST_LDFLAGS)
|
||||
|
||||
TARGET:=EngineTests
|
||||
|
@ -34,7 +38,12 @@ else
|
|||
LDLIBS+= -letpan
|
||||
endif
|
||||
|
||||
LDLIBS+= -lpEpEngine -lstdc++ -lasn1
|
||||
ifeq ($(BUILD_ON),OS/390)
|
||||
LDLIBS+= -letpan-no-mt
|
||||
else
|
||||
LDLIBS+= -letpan -lpEpEngine -lstdc++
|
||||
endif
|
||||
LDLIBS+= -lasn1
|
||||
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
LDLIBS+= -luuid
|
||||
|
@ -52,8 +61,19 @@ ifdef SQLITE3_FROM_OS
|
|||
LDLIBS+= -lsqlite3
|
||||
endif
|
||||
|
||||
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS)) -I$(GTEST_INC_DIR)
|
||||
CPPFLAGS:=$(filter-out -DNDEBUG,$(CPPFLAGS))
|
||||
ifeq ($(OPENPGP),GPG)
|
||||
#LDLIBS+= -lgpgme
|
||||
else ifeq ($(OPENPGP),NETPGP)
|
||||
LDLIBS+= -lnetpgp
|
||||
ifeq ($(BUILD_FOR),Linux)
|
||||
LDLIBS+= -ltre
|
||||
endif
|
||||
endif
|
||||
|
||||
CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
|
||||
|
||||
# FIXME Possibly missing incdirs: ASN1C_INC
|
||||
CXXFLAGS+= -I$(GTEST_INC_DIR) -I./src -I../sync $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
|
||||
|
||||
CXXFLAGS+= -I./src -I../src -I ../asn.1 -I../sync $(INC_FLAGS) -Wno-deprecated -Wno-unused-variable
|
||||
|
||||
|
@ -88,8 +108,13 @@ all:
|
|||
%.d: %.cc
|
||||
$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< | sed -e 's,\($*\)\.o[ :]*,\1.o $@: ,g' > $@
|
||||
|
||||
LDLIBS+=-lgtest -lgtest_main
|
||||
ifneq ($(BUILD_ON),OS/390)
|
||||
LDLIBS+=-lsequoia_openpgp_ffi
|
||||
endif
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ -lpEpEngine -lgtest -lgtest_main $(LDLIBS)
|
||||
${CXX} ${LDFLAGS} -L${PREFIX}/lib -o $@ $^ $(LDLIBS)
|
||||
|
||||
test: all
|
||||
$(RM) -rf ./pEp_test_home/*
|
||||
|
|
Loading…
Reference in New Issue