summaryrefslogtreecommitdiff
path: root/databases/postgresql10
diff options
context:
space:
mode:
authoradam <adam@pkgsrc.org>2017-10-23 20:33:49 +0000
committeradam <adam@pkgsrc.org>2017-10-23 20:33:49 +0000
commitb45ad1d9394592ccf214a31d1e490d5c423c3c12 (patch)
tree569e2f79e9c2e9ffc1107a4e19a01fd335aaa124 /databases/postgresql10
parent0639431d94995a943e1883bc35c9c43d9a3b2ccd (diff)
downloadpkgsrc-b45ad1d9394592ccf214a31d1e490d5c423c3c12.tar.gz
postgresql10: added version 10.0
Major enhancements in PostgreSQL 10 include: Logical replication using publish/subscribe Declarative table partitioning Improved query parallelism Significant general performance improvements Stronger password authentication based on SCRAM-SHA-256 Improved monitoring and control The above items are explained in more detail in the sections below.
Diffstat (limited to 'databases/postgresql10')
-rw-r--r--databases/postgresql10/DESCR9
-rw-r--r--databases/postgresql10/Makefile14
-rw-r--r--databases/postgresql10/Makefile.common135
-rw-r--r--databases/postgresql10/PLIST2
-rw-r--r--databases/postgresql10/distinfo19
-rw-r--r--databases/postgresql10/files/GNUmakefile.libpq20
-rw-r--r--databases/postgresql10/files/dynloader-ltdl.h17
-rw-r--r--databases/postgresql10/options.mk39
-rw-r--r--databases/postgresql10/patches/patch-config_missing13
-rw-r--r--databases/postgresql10/patches/patch-config_perl.m415
-rw-r--r--databases/postgresql10/patches/patch-configure34
-rw-r--r--databases/postgresql10/patches/patch-contrib_dblink_dblink.c13
-rw-r--r--databases/postgresql10/patches/patch-src_Makefile.global.in28
-rw-r--r--databases/postgresql10/patches/patch-src_Makefile.shlib61
-rw-r--r--databases/postgresql10/patches/patch-src_backend_Makefile24
-rw-r--r--databases/postgresql10/patches/patch-src_backend_utils_adt_datetime.c14
-rw-r--r--databases/postgresql10/patches/patch-src_interfaces_ecpg_pgtypeslib_interval.c15
-rw-r--r--databases/postgresql10/patches/patch-src_interfaces_libpq_Makefile13
-rw-r--r--databases/postgresql10/patches/patch-src_makefiles_Makefile.solaris10
-rw-r--r--databases/postgresql10/patches/patch-src_pl_plperl_GNUmakefile21
-rw-r--r--databases/postgresql10/patches/patch-src_pl_plperl_plperl.h27
21 files changed, 543 insertions, 0 deletions
diff --git a/databases/postgresql10/DESCR b/databases/postgresql10/DESCR
new file mode 100644
index 00000000000..9f6b5b5b0f9
--- /dev/null
+++ b/databases/postgresql10/DESCR
@@ -0,0 +1,9 @@
+PostgreSQL is a robust, next-generation, Object-Relational DBMS (ORDBMS),
+derived from the Berkeley Postgres database management system. While
+PostgreSQL retains the powerful object-relational data model, rich data types
+and easy extensibility of Postgres, it replaces the PostQuel query language
+with an extended subset of SQL.
+
+PostgreSQL is free and the complete source is available.
+
+This is the meta-package for the PostgreSQL database system.
diff --git a/databases/postgresql10/Makefile b/databases/postgresql10/Makefile
new file mode 100644
index 00000000000..bd4113e4125
--- /dev/null
+++ b/databases/postgresql10/Makefile
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+PKGNAME= ${DISTNAME:C/-/10-/}
+COMMENT= Robust, next generation, object-relational DBMS
+
+DEPENDS+= postgresql10-client>=${PKGVERSION_NOREV}:../../databases/postgresql10-client
+DEPENDS+= postgresql10-docs>=${PKGVERSION_NOREV}:../../databases/postgresql10-docs
+DEPENDS+= postgresql10-server>=${PKGVERSION_NOREV}:../../databases/postgresql10-server
+
+META_PACKAGE= yes
+
+.include "Makefile.common"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/databases/postgresql10/Makefile.common b/databases/postgresql10/Makefile.common
new file mode 100644
index 00000000000..53f43c0c6ba
--- /dev/null
+++ b/databases/postgresql10/Makefile.common
@@ -0,0 +1,135 @@
+# $NetBSD: Makefile.common,v 1.1 2017/10/23 20:33:49 adam Exp $
+#
+# This Makefile fragment is included by all PostgreSQL packages built from
+# the main sources of the PostgreSQL distribution except jdbc-postgresql.
+#
+# The PostgreSQL package naming scheme, aside from the obvious piecewise
+# packages, is as follows:
+# <lang>-postgresql client-side interface to PostgreSQL
+# postgresql-<lang> server-side module for PostgreSQL backend
+#
+# used by databases/postgresql10-client/Makefile
+# used by databases/postgresql10-contrib/Makefile
+# used by databases/postgresql10-docs/Makefile
+# used by databases/postgresql10-plperl/Makefile
+# used by databases/postgresql10-plpython/Makefile
+# used by databases/postgresql10-pltcl/Makefile
+# used by databases/postgresql10-server/Makefile
+
+DISTNAME= postgresql-10.0
+CATEGORIES= databases
+MASTER_SITES= ${MASTER_SITE_PGSQL:=source/v${PKGVERSION_NOREV}/}
+EXTRACT_SUFX= .tar.bz2
+
+MAINTAINER?= adam@NetBSD.org
+HOMEPAGE= https://www.postgresql.org/
+LICENSE= postgresql-license
+
+CONFLICTS+= postgresql-[0-9]*
+CONFLICTS+= postgresql[2-9][0-9]-[0-9]*
+
+.if !empty(PKGNAME:M*-*-*)
+module= ${PKGNAME:C/-[0-9].*$//:C/^.*-//}
+CONFLICTS+= postgresql[2-9][0-9]-${module}-[0-9]*
+.endif
+
+DISTINFO_FILE?= ${.CURDIR}/../../databases/postgresql10/distinfo
+COMMON_FILESDIR?= ${.CURDIR}/../../databases/postgresql10/files
+PATCHDIR?= ${.CURDIR}/../../databases/postgresql10/patches
+
+USE_PKGLOCALEDIR= yes
+USE_TOOLS+= bison gmake lex msgfmt
+PKG_SYSCONFSUBDIR= postgresql
+
+.include "../../mk/bsd.prefs.mk"
+
+PG_TEMPLATE.SunOS= solaris
+PG_TEMPLATE.IRIX= irix5
+PG_TEMPLATE.MirBSD= openbsd
+.if !defined(PG_TEMPLATE.${OPSYS})
+PG_TEMPLATE.${OPSYS}= ${LOWER_OPSYS}
+.endif
+
+PG_DATA_DIR= ${PREFIX}/share/postgresql
+PG_DOC_DIR= ${PREFIX}/share/doc/postgresql
+PG_LOCALE_DIR= ${PREFIX}/${PKGLOCALEDIR}/locale
+PG_ETC_DIR= ${PKG_SYSCONFDIR}
+
+GNU_CONFIGURE= yes
+CONFIGURE_ARGS+= --sysconfdir=${PG_ETC_DIR}
+CONFIGURE_ARGS+= --datadir=${PG_DATA_DIR}
+CONFIGURE_ARGS+= --docdir=${PG_DOC_DIR}
+CONFIGURE_ARGS+= --localedir=${PG_LOCALE_DIR}
+CONFIGURE_ARGS+= --with-template=${PG_TEMPLATE.${OPSYS}}
+
+CONFIGURE_ARGS+= --enable-nls
+CONFIGURE_ARGS+= --with-gssapi
+CONFIGURE_ARGS+= --with-libxml
+CONFIGURE_ARGS+= --with-readline
+CONFIGURE_ARGS+= --without-perl
+CONFIGURE_ARGS+= --without-python
+CONFIGURE_ARGS+= --without-tcl
+
+# avoid pointing to a wrapper
+CONFIGURE_ENV+= MSGFMT=${TOOLS_PATH.msgfmt}
+
+# sys/ucred.h shouldn't be included on Solaris, causes conflicts between
+# procfs and largefile.
+.if ${OPSYS} == "SunOS"
+CONFIGURE_ENV+= ac_cv_header_sys_ucred_h=no
+.endif
+
+# configure fails on OpenBSD and MirBSD if thread safety is enabled.
+.if ${OPSYS} == "OpenBSD" || ${OPSYS} == "MirBSD"
+CONFIGURE_ARGS+= --disable-thread-safety
+.endif
+
+# PGSQL_BLCKSZ is the size in bytes of a PostgreSQL disk page or block.
+# This also limits the size of a tuple. The valid values are powers
+# of 2 up to 32768, and the default size is 8196. Please don't change
+# this value unless you know what you are doing.
+BUILD_DEFS+= PGSQL_BLCKSZ
+.if defined(PGSQL_BLCKSZ)
+CONFIGURE_ARGS+= --with-blocksize=${PGSQL_BLCKSZ}
+.endif
+
+# PostgreSQL explicitly forbids any use of -ffast-math
+BUILDLINK_TRANSFORM+= rm:-ffast-math
+
+# USE_LIBLTDL is "yes" or "no" depending on whether we're using libltdl
+# to provide "dlopen" functionality for the PostgreSQL backend.
+.if ${OPSYS} == "Interix"
+USE_LIBLTDL?= yes
+.endif
+USE_LIBLTDL?= no
+
+.include "../../devel/gettext-lib/buildlink3.mk"
+LIBS.SunOS+= -lintl
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../textproc/libxml2/buildlink3.mk"
+
+.include "../../mk/readline.buildlink3.mk"
+.if ${READLINE_TYPE} == "editline"
+CONFIGURE_ARGS+= --with-libedit-preferred
+.endif
+
+.if !defined(META_PACKAGE)
+post-extract:
+. if !empty(USE_LIBLTDL:M[yY][eE][sS])
+ cp -f ${COMMON_FILESDIR}/dynloader-ltdl.h \
+ ${WRKSRC}/src/backend/port/dynloader/${PG_TEMPLATE.${OPSYS}:Q}.h
+ ${ECHO} "static int dummy = 0;" \
+ > ${WRKSRC}/src/backend/port/dynloader/${PG_TEMPLATE.${OPSYS}:Q}.c
+. endif
+ touch ${WRKSRC}/src/template/dragonfly
+ cp ${WRKSRC}/src/backend/port/dynloader/freebsd.c \
+ ${WRKSRC}/src/backend/port/dynloader/dragonfly.c
+ cp ${WRKSRC}/src/backend/port/dynloader/freebsd.h \
+ ${WRKSRC}/src/backend/port/dynloader/dragonfly.h
+ cp ${WRKSRC}/src/include/port/freebsd.h \
+ ${WRKSRC}/src/include/port/dragonfly.h
+ cp ${WRKSRC}/src/makefiles/Makefile.freebsd \
+ ${WRKSRC}/src/makefiles/Makefile.dragonfly
+.endif
+
+.include "../../databases/postgresql10/options.mk"
diff --git a/databases/postgresql10/PLIST b/databases/postgresql10/PLIST
new file mode 100644
index 00000000000..5f70befcc89
--- /dev/null
+++ b/databases/postgresql10/PLIST
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2017/10/23 20:33:49 adam Exp $
+@comment this plist intentionally left empty
diff --git a/databases/postgresql10/distinfo b/databases/postgresql10/distinfo
new file mode 100644
index 00000000000..92695aa39a4
--- /dev/null
+++ b/databases/postgresql10/distinfo
@@ -0,0 +1,19 @@
+$NetBSD: distinfo,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+SHA1 (postgresql-10.0.tar.bz2) = 4c26f81278f7da12f46f2ff4fda5b0311e191b95
+RMD160 (postgresql-10.0.tar.bz2) = d8995f0f4072d5bee91274f508e18a2155ef346f
+SHA512 (postgresql-10.0.tar.bz2) = 88295af13db77a85a604c925aa627d383fdac62c1185119bba87753ce4167a13aed0f055a7a1329b3051f8757c6ba7529baed00a564ef0cfbee685720f282678
+Size (postgresql-10.0.tar.bz2) = 19639147 bytes
+SHA1 (patch-config_missing) = c2d7d742922ba6861e7660c75b7b53f09e564813
+SHA1 (patch-config_perl.m4) = e035132b1c281a75752d570ac5e29a11176c25c5
+SHA1 (patch-configure) = 59fe9a768caf8a5d308acac60c28bc6bb2c40632
+SHA1 (patch-contrib_dblink_dblink.c) = a6f87ab9f2c28a72608d70267b71bd77437b0921
+SHA1 (patch-src_Makefile.global.in) = 335b57afff23a9684ab0a09257665810c1ba2d1e
+SHA1 (patch-src_Makefile.shlib) = 46b3a8591678f92892d3837cd31fa44e8a7e21b3
+SHA1 (patch-src_backend_Makefile) = 91aa620b3a26f3da66c22aef78611a352a8793b6
+SHA1 (patch-src_backend_utils_adt_datetime.c) = d1ea70986634d3bfb663eff789425252656e1289
+SHA1 (patch-src_interfaces_ecpg_pgtypeslib_interval.c) = a15012ae34d4ecd1eb2bc29e4d2c40098ea236fd
+SHA1 (patch-src_interfaces_libpq_Makefile) = 61bcf84eb69b6ec9faabab0b61913766f4b20f8c
+SHA1 (patch-src_makefiles_Makefile.solaris) = 0168f5bc105ffc89d5db40907a08966d8465f5a0
+SHA1 (patch-src_pl_plperl_GNUmakefile) = 6ee3e431f46ce5c2a94df499504b2b8bd458bbef
+SHA1 (patch-src_pl_plperl_plperl.h) = 0e7daec79a00d7378326e56525e50cfe61cfc174
diff --git a/databases/postgresql10/files/GNUmakefile.libpq b/databases/postgresql10/files/GNUmakefile.libpq
new file mode 100644
index 00000000000..7be697c4242
--- /dev/null
+++ b/databases/postgresql10/files/GNUmakefile.libpq
@@ -0,0 +1,20 @@
+# $NetBSD: GNUmakefile.libpq,v 1.1 2017/10/23 20:33:49 adam Exp $
+#
+# This GNUmakefile overrides the `all' target of $(libpq_srcdir)/Makefile
+# to be empty if INSTALLED_LIBPQ is defined. This handles the submake
+# targets sprinkled throughout the PostgreSQL Makefiles that execute
+#
+# @$(MAKE) -C $(libpq_builddir) all
+#
+# to ensure that the libpq libraries are built first. If INSTALLED_LIBPQ
+# is defined, then have the `all' target simple return success.
+
+ifdef INSTALLED_LIBPQ
+all:
+ @test -f libpq.a || touch libpq.a
+endif
+
+%: force
+ @$(MAKE) -f Makefile $@
+
+force: ;
diff --git a/databases/postgresql10/files/dynloader-ltdl.h b/databases/postgresql10/files/dynloader-ltdl.h
new file mode 100644
index 00000000000..0bbd3f7043b
--- /dev/null
+++ b/databases/postgresql10/files/dynloader-ltdl.h
@@ -0,0 +1,17 @@
+/* $NetBSD: dynloader-ltdl.h,v 1.1 2017/10/23 20:33:49 adam Exp $ */
+
+/*
+ * dynamic loader based on libltdl
+ */
+#ifndef PORT_PROTOS_H
+#define PORT_PROTOS_H
+
+#include <ltdl.h>
+#include "utils/dynamic_loader.h"
+
+#define pg_dlopen(a) ((void *)lt_dlopen(a))
+#define pg_dlsym(a,b) lt_dlsym((lt_dlhandle)(a), (b))
+#define pg_dlclose(a) lt_dlclose((lt_dlhandle)(a))
+#define pg_dlerror lt_dlerror
+
+#endif /* PORT_PROTOS_H */
diff --git a/databases/postgresql10/options.mk b/databases/postgresql10/options.mk
new file mode 100644
index 00000000000..fb48e4cbe59
--- /dev/null
+++ b/databases/postgresql10/options.mk
@@ -0,0 +1,39 @@
+# $NetBSD: options.mk,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+PKG_OPTIONS_VAR= PKG_OPTIONS.postgresql10
+PKG_SUPPORTED_OPTIONS= bonjour dtrace icu ldap pam
+
+.include "../../mk/bsd.options.mk"
+
+# Bonjour support
+.if !empty(PKG_OPTIONS:Mbonjour)
+CONFIGURE_ARGS+= --with-bonjour
+. if ${OPSYS} != "Darwin"
+LIBS+= -ldns_sd
+. endif
+. include "../../net/mDNSResponder/buildlink3.mk"
+.endif
+
+# Dtrace support
+.if !empty(PKG_OPTIONS:Mdtrace)
+CONFIGURE_ARGS+= --enable-dtrace
+.endif
+
+# ICU collatium support
+.if !empty(PKG_OPTIONS:Micu)
+USE_TOOLS+= pkg-config
+CONFIGURE_ARGS+= --with-icu
+. include "../../textproc/icu/buildlink3.mk"
+.endif
+
+# LDAP authentication for the PostgreSQL backend
+.if !empty(PKG_OPTIONS:Mldap)
+. include "../../databases/openldap-client/buildlink3.mk"
+CONFIGURE_ARGS+= --with-ldap
+.endif
+
+# PAM authentication for the PostgreSQL backend
+.if !empty(PKG_OPTIONS:Mpam)
+. include "../../mk/pam.buildlink3.mk"
+CONFIGURE_ARGS+= --with-pam
+.endif
diff --git a/databases/postgresql10/patches/patch-config_missing b/databases/postgresql10/patches/patch-config_missing
new file mode 100644
index 00000000000..bed1b72fb52
--- /dev/null
+++ b/databases/postgresql10/patches/patch-config_missing
@@ -0,0 +1,13 @@
+$NetBSD: patch-config_missing,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- config/missing.orig 2012-10-05 12:14:55.000000000 +0000
++++ config/missing
+@@ -40,7 +40,7 @@ pre-packaged $1 output.
+ ERROR: Perl is missing on your system. It is needed unless you are building
+ from an unmodified official distribution of PostgreSQL.
+ ***" >&2
+- exit 1
++ exit 0
+ ;;
+
+ *)
diff --git a/databases/postgresql10/patches/patch-config_perl.m4 b/databases/postgresql10/patches/patch-config_perl.m4
new file mode 100644
index 00000000000..6662d1036f2
--- /dev/null
+++ b/databases/postgresql10/patches/patch-config_perl.m4
@@ -0,0 +1,15 @@
+$NetBSD: patch-config_perl.m4,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- config/perl.m4.orig 2013-09-02 20:53:17.000000000 +0000
++++ config/perl.m4
+@@ -62,9 +62,7 @@ if test "$PORTNAME" = "win32" ; then
+ perl_lib=`basename $perl_archlibexp/CORE/perl[[5-9]]*.lib .lib`
+ test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
+ else
+-pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
+-pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
+-perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e ["s/ -arch [-a-zA-Z0-9_]*//g"]`
++perl_embed_ldflags=`$PERL -MExtUtils::Embed -e ldopts`
+ fi
+ AC_SUBST(perl_embed_ldflags)dnl
+ if test -z "$perl_embed_ldflags" ; then
diff --git a/databases/postgresql10/patches/patch-configure b/databases/postgresql10/patches/patch-configure
new file mode 100644
index 00000000000..cc8fadae207
--- /dev/null
+++ b/databases/postgresql10/patches/patch-configure
@@ -0,0 +1,34 @@
+$NetBSD: patch-configure,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+Finally, native solaris uses -lgss for gssapi on mit-krb5.
+
+--- configure.orig 2014-12-16 01:07:34.000000000 +0000
++++ configure
+@@ -2852,6 +2852,7 @@ case $host_os in
+ darwin*) template=darwin ;;
+ dragonfly*) template=netbsd ;;
+ freebsd*) template=freebsd ;;
++ dragonfly*) template=dragonfly ;;
+ hpux*) template=hpux ;;
+ linux*|gnu*|k*bsd*-gnu)
+ template=linux ;;
+@@ -7310,9 +7311,7 @@ if test "$PORTNAME" = "win32" ; then
+ perl_lib=`basename $perl_archlibexp/CORE/perl[5-9]*.lib .lib`
+ test -e "$perl_archlibexp/CORE/$perl_lib.lib" && perl_embed_ldflags="-L$perl_archlibexp/CORE -l$perl_lib"
+ else
+-pgac_tmp1=`$PERL -MExtUtils::Embed -e ldopts`
+-pgac_tmp2=`$PERL -MConfig -e 'print $Config{ccdlflags}'`
+-perl_embed_ldflags=`echo X"$pgac_tmp1" | sed -e "s/^X//" -e "s%$pgac_tmp2%%" -e "s/ -arch [-a-zA-Z0-9_]*//g"`
++perl_embed_ldflags=`$PERL -MExtUtils::Embed -e ldopts`
+ fi
+ if test -z "$perl_embed_ldflags" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+@@ -8407,7 +8406,7 @@ return gss_init_sec_context ();
+ return 0;
+ }
+ _ACEOF
+-for ac_lib in '' gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'; do
++for ac_lib in '' gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto' 'gss -lkrb5 lcrypto'; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
diff --git a/databases/postgresql10/patches/patch-contrib_dblink_dblink.c b/databases/postgresql10/patches/patch-contrib_dblink_dblink.c
new file mode 100644
index 00000000000..6335cd5e0b4
--- /dev/null
+++ b/databases/postgresql10/patches/patch-contrib_dblink_dblink.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-contrib_dblink_dblink.c,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- contrib/dblink/dblink.c.orig 2013-04-01 18:20:36.000000000 +0000
++++ contrib/dblink/dblink.c
+@@ -52,7 +52,7 @@
+ #include "parser/scansup.h"
+ #include "utils/acl.h"
+ #include "utils/builtins.h"
+-#include "utils/fmgroids.h"
++#include "postgresql/server/utils/fmgroids.h"
+ #include "utils/guc.h"
+ #include "utils/lsyscache.h"
+ #include "utils/memutils.h"
diff --git a/databases/postgresql10/patches/patch-src_Makefile.global.in b/databases/postgresql10/patches/patch-src_Makefile.global.in
new file mode 100644
index 00000000000..6c30ed5a0d8
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_Makefile.global.in
@@ -0,0 +1,28 @@
+$NetBSD: patch-src_Makefile.global.in,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+Do not store CONFIGURE_ARGS, as these may contain working directory references.
+Fix building on Cygwin.
+
+--- src/Makefile.global.in.orig 2017-10-02 21:09:15.000000000 +0000
++++ src/Makefile.global.in
+@@ -74,8 +74,6 @@ endif # not PGXS
+
+ vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
+
+-# Saved arguments from configure
+-configure_args = @configure_args@
+
+
+ ##########################################################################
+@@ -641,6 +639,11 @@ ifeq ($(PORTNAME),win32)
+ LIBS += -lws2_32
+ endif
+
++# missing for link on cygwin ?
++ifeq ($(PORTNAME),cygwin)
++LIBS += $(LDAP_LIBS_BE)
++endif
++
+ # Not really standard libc functions, used by the backend.
+ TAS = @TAS@
+
diff --git a/databases/postgresql10/patches/patch-src_Makefile.shlib b/databases/postgresql10/patches/patch-src_Makefile.shlib
new file mode 100644
index 00000000000..009dd2d98a3
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_Makefile.shlib
@@ -0,0 +1,61 @@
+$NetBSD: patch-src_Makefile.shlib,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/Makefile.shlib.orig 2016-02-08 21:12:28.000000000 +0000
++++ src/Makefile.shlib
+@@ -151,17 +151,11 @@ endif
+
+ ifeq ($(PORTNAME), freebsd)
+ ifdef ELF_SYSTEM
+- ifdef SO_MAJOR_VERSION
+- shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+- endif
+ LINK.shared = $(COMPILER) -shared
+ ifdef soname
+ LINK.shared += -Wl,-x,-soname,$(soname)
+ endif
+ else
+- ifdef SO_MAJOR_VERSION
+- shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
+- endif
+ LINK.shared = $(LD) -x -Bshareable -Bforcearchive
+ endif
+ endif
+@@ -177,6 +171,17 @@ ifeq ($(PORTNAME), netbsd)
+ endif
+ endif
+
++ifeq ($(PORTNAME), dragonfly)
++ ifdef ELF_SYSTEM
++ LINK.shared = $(COMPILER) -shared
++ ifdef soname
++ LINK.shared += -Wl,-x,-soname,$(soname)
++ endif
++ else
++ LINK.shared = $(LD) -x -Bshareable -Bforcearchive
++ endif
++endif
++
+ ifeq ($(PORTNAME), hpux)
+ ifdef SO_MAJOR_VERSION
+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+@@ -474,8 +479,10 @@ ifdef soname
+ # we don't install $(shlib) on AIX
+ # (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at)
+ ifneq ($(PORTNAME), aix)
++ifeq ($(PORTNAME), cygwin)
++ $(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
++else
+ $(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
+-ifneq ($(PORTNAME), cygwin)
+ ifneq ($(PORTNAME), win32)
+ ifneq ($(shlib), $(shlib_major))
+ cd '$(DESTDIR)$(libdir)' && \
+@@ -488,7 +495,7 @@ ifneq ($(shlib), $(shlib_bare))
+ $(LN_S) $(shlib) $(shlib_bare)
+ endif
+ endif # not win32
+-endif # not cygwin
++endif # cygwin
+ endif # not aix
+ ifneq (,$(findstring $(PORTNAME),win32 cygwin))
+ $(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
diff --git a/databases/postgresql10/patches/patch-src_backend_Makefile b/databases/postgresql10/patches/patch-src_backend_Makefile
new file mode 100644
index 00000000000..00bc1a46ed4
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_backend_Makefile
@@ -0,0 +1,24 @@
+$NetBSD: patch-src_backend_Makefile,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/backend/Makefile.orig 2017-10-02 21:09:15.000000000 +0000
++++ src/backend/Makefile
+@@ -17,6 +17,10 @@ subdir = src/backend
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+
++CFLAGS+= $(DL_CFLAGS)
++LDFLAGS+= $(DL_LDFLAGS)
++LIBS+= $(DL_LIBS)
++
+ SUBDIRS = access bootstrap catalog parser commands executor foreign lib libpq \
+ main nodes optimizer port postmaster regex replication rewrite \
+ statistics storage tcop tsearch utils $(top_builddir)/src/timezone
+@@ -119,6 +123,8 @@ submake-errcodes: $(top_builddir)/src/in
+
+ $(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
+
++$(top_builddir)/src/common/libpgcommon_srv.a: | submake-libpgport
++
+
+ # The postgres.o target is needed by the rule in Makefile.global that
+ # creates the exports file when MAKE_EXPORTS = true.
diff --git a/databases/postgresql10/patches/patch-src_backend_utils_adt_datetime.c b/databases/postgresql10/patches/patch-src_backend_utils_adt_datetime.c
new file mode 100644
index 00000000000..3ba6a87a0a7
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_backend_utils_adt_datetime.c
@@ -0,0 +1,14 @@
+$NetBSD: patch-src_backend_utils_adt_datetime.c,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/backend/utils/adt/datetime.c.orig 2014-12-16 01:07:34.000000000 +0000
++++ src/backend/utils/adt/datetime.c
+@@ -31,6 +31,9 @@
+ #include "utils/memutils.h"
+ #include "utils/tzparser.h"
+
++#if defined(__NetBSD__)
++#define strtoi pg_strtoi
++#endif
+
+ static int DecodeNumber(int flen, char *field, bool haveTextMonth,
+ int fmask, int *tmask,
diff --git a/databases/postgresql10/patches/patch-src_interfaces_ecpg_pgtypeslib_interval.c b/databases/postgresql10/patches/patch-src_interfaces_ecpg_pgtypeslib_interval.c
new file mode 100644
index 00000000000..5d58cb0b737
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_interfaces_ecpg_pgtypeslib_interval.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-src_interfaces_ecpg_pgtypeslib_interval.c,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/interfaces/ecpg/pgtypeslib/interval.c.orig 2016-05-09 20:50:23.000000000 +0000
++++ src/interfaces/ecpg/pgtypeslib/interval.c
+@@ -14,6 +14,10 @@
+ #include "pgtypes_error.h"
+ #include "pgtypes_interval.h"
+
++#if defined(__NetBSD__)
++#define strtoi pg_strtoi
++#endif
++
+ /* copy&pasted from .../src/backend/utils/adt/datetime.c */
+ static int
+ strtoint(const char *nptr, char **endptr, int base)
diff --git a/databases/postgresql10/patches/patch-src_interfaces_libpq_Makefile b/databases/postgresql10/patches/patch-src_interfaces_libpq_Makefile
new file mode 100644
index 00000000000..f97779ae9a9
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_interfaces_libpq_Makefile
@@ -0,0 +1,13 @@
+$NetBSD: patch-src_interfaces_libpq_Makefile,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/interfaces/libpq/Makefile.orig 2016-02-08 21:12:28.000000000 +0000
++++ src/interfaces/libpq/Makefile
+@@ -49,7 +49,7 @@ OBJS += fe-secure-openssl.o
+ endif
+
+ ifeq ($(PORTNAME), cygwin)
+-override shlib = cyg$(NAME)$(DLSUFFIX)
++override shlib = cyg$(NAME)-$(SO_MAJOR_VERSION)$(DLSUFFIX)
+ endif
+
+ ifeq ($(PORTNAME), win32)
diff --git a/databases/postgresql10/patches/patch-src_makefiles_Makefile.solaris b/databases/postgresql10/patches/patch-src_makefiles_Makefile.solaris
new file mode 100644
index 00000000000..75ad3cae6c6
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_makefiles_Makefile.solaris
@@ -0,0 +1,10 @@
+$NetBSD: patch-src_makefiles_Makefile.solaris,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/makefiles/Makefile.solaris.orig 2011-09-23 00:00:48.000000000 +0200
++++ src/makefiles/Makefile.solaris 2011-10-11 11:53:51.948565783 +0200
+@@ -23,5 +23,3 @@ ifeq ($(GCC), yes)
+ else
+ $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SL) -G -o $@ $<
+ endif
+-
+-sqlmansect = 5sql
diff --git a/databases/postgresql10/patches/patch-src_pl_plperl_GNUmakefile b/databases/postgresql10/patches/patch-src_pl_plperl_GNUmakefile
new file mode 100644
index 00000000000..351e41fe91b
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_pl_plperl_GNUmakefile
@@ -0,0 +1,21 @@
+$NetBSD: patch-src_pl_plperl_GNUmakefile,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/pl/plperl/GNUmakefile.orig 2013-09-02 20:53:17.000000000 +0000
++++ src/pl/plperl/GNUmakefile
+@@ -55,7 +55,6 @@ XSUBPPDIR = $(shell $(PERL) -e 'use List
+
+ include $(top_srcdir)/src/Makefile.shlib
+
+-plperl.o: perlchunks.h plperl_opmask.h plperl_helpers.h
+
+ plperl_opmask.h: plperl_opmask.pl
+ @if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch --with-perl was not specified."; exit 1; fi
+@@ -65,7 +64,7 @@ perlchunks.h: $(PERLCHUNKS)
+ @if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch --with-perl was not specified."; exit 1; fi
+ $(PERL) $(srcdir)/text2macro.pl --strip='^(\#.*|\s*)$$' $^ > $@
+
+-all: all-lib
++all: perlchunks.h plperl_opmask.h plperl_helpers.h all-lib
+
+ SPI.c: SPI.xs plperl_helpers.h
+ @if [ x"$(perl_privlibexp)" = x"" ]; then echo "configure switch --with-perl was not specified."; exit 1; fi
diff --git a/databases/postgresql10/patches/patch-src_pl_plperl_plperl.h b/databases/postgresql10/patches/patch-src_pl_plperl_plperl.h
new file mode 100644
index 00000000000..b10cbb5d60f
--- /dev/null
+++ b/databases/postgresql10/patches/patch-src_pl_plperl_plperl.h
@@ -0,0 +1,27 @@
+$NetBSD: patch-src_pl_plperl_plperl.h,v 1.1 2017/10/23 20:33:49 adam Exp $
+
+--- src/pl/plperl/plperl.h.orig 2017-08-07 21:19:50.000000000 +0000
++++ src/pl/plperl/plperl.h
+@@ -44,6 +44,10 @@
+ #undef vsnprintf
+ #endif
+
++#ifdef __sun
++#define list_head sun_list_head
++#define list_tail sun_list_tail
++#endif
+
+ /*
+ * Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code
+@@ -62,6 +66,11 @@
+ #include "XSUB.h"
+ #endif
+
++#ifdef __sun
++#undef list_head
++#undef list_tail
++#endif
++
+ /* put back our snprintf and vsnprintf */
+ #ifdef USE_REPL_SNPRINTF
+ #ifdef snprintf