aboutsummaryrefslogtreecommitdiff
path: root/ports/libpq
diff options
context:
space:
mode:
authorAlexander Neumann <30894796+Neumann-A@users.noreply.github.com>2020-01-14 00:43:36 +0100
committerVictor Romero <romerosanchezv@gmail.com>2020-01-13 15:43:36 -0800
commitbdae0904c41a0ee2c5204d6449038d3b5d551726 (patch)
treeea710e1a326e02ed34a28afef72407d8855bb7bf /ports/libpq
parent5c0b7b55771fe4b40d3f4b7a8069b1c71022490e (diff)
downloadvcpkg-bdae0904c41a0ee2c5204d6449038d3b5d551726.tar.gz
vcpkg-bdae0904c41a0ee2c5204d6449038d3b5d551726.zip
[libpq, openssl, librtmp] libpq 12 and others with openssl 1.1.1d (#8566)
* [ports] Update openssl-unix to 1.1.1c * [ports] Update openssl-unix to 1.1.1d * [ports] openssl-unix platform 'AMD64' is called 'x86_64' on Linux * [ports] fix openssl platform * [ports] openssl-windows update openssl to 1.1.1d * [ports] Fix openssl post build * [ports] openssl add EnableUWPSupport.patch Reference: https://github.com/openssl/openssl/pull/8917 https://github.com/openssl/openssl/pull/9440 * [ports] openssl-uwp update openssl to 1.1.1d * Updated support for OpenSSL v1.1 With OpenSSL v1.1 we need an additional flag for ACE * update to 12.0 and change to vcpkg_configure_make * remove msys line * remove custom cmakelists * use --without-readline on linux * Update CONTROL Fix version * fix portfile * add all possible libpq features * create vcpkg_get_build_depends * create vcpkg_read_dependent_port_info * add vcpkg_write_port_info * fix a few bugs * libpq first succesful x86 build with core features. (files still must be moved) * always write the variable * Fix separate make and install execution error issue. * trigger CI system. * add openssl and win_bison win_flex patch * add configuration dependent patches * add bonjour as a dependency on macosx * apply patches and configure features * more patches to fix the windows build * more install fixes * remove unnecessary code * bit of code cleanup * remove unrelated files * remove unrelated function call. function was removed with last commit * removed hardcoded platform * fix patch * build only the interface libraries and nothing more * forgot to remove tool ecpg from install * seperate minimal install patch from normal install patch and introduce client feature * fix x86 Platform variable being x86 and not Win32 as required by the generated project * make linux build work * make more linux work * openssl return version number directly without calling openssl (should probably be done differently) * fix some more path and platform identification * comments to reduce install. currently libpq installs static and shared libraries and some tools on linux * patch arm * fix platform detection logic * make libpq osx buildable * Rename debug import library after build. (So that we don't affect external CMake users.) * revert debug naming and install a wrapper instead. * fix gdal regression due to name change * fix cutelyst regression due to qt5-base wrapper (why was it not using the target in the first place?) * correct wrapper install path * correct the arm patch. * trying to fix static gdal build * gdal still needs more work * update version of openssl in libpq openssl patch * nmap fix openssl * qt5 fix openssl * gdal fix openssl * librtmp migrate to openssl 1.1.1 * fail in patch since what is intended is not going to work in openssl 1.1.1 * fix static yara build * freedtds deactivate openssl feature until freetds decides to upgrade to 1.1 * fix libwebsockets cmakelists * fix the patch so that the generated targets also include crypt32 * xmlsec add threads dependency * bump control since I am unable to reproduce the regression * add pthread to openssl detection logic * fix freetds linkage missing crypt32 and fix the cmake checks. * fix the openssl wrapper to add the threads library * fix libmysql regression * add threads to openssl libraries. * upgrade libssh to 0.9 * fix nmap regression * fix mosquitto regression * fix openssl wrapper to make libarchive work * fix quickfix * changed patch a bit * improve freetds patch * fix case in librtmp * update control * bump control * fix case * make jasper a dependency of qt5-imageformats to fix flaky CI build. * add jasper libraries explicitly * jasper depends on freeglut so add it as a dependency. turbo_jpeg is also a dependency but that should already be handled in qt5-base * more glut names * bump control for macosx ci retry * fix slikenet regression * fix linebreak in qt5-base * update baseline * Update ci.baseline.txt those ports are not supported on UWP * [libevent] add dependency on libevent[threads] to openssl feature * [pdal,freerdp] Update CI baseline to fail * fix static pdal build * fix freerdp on linux * trying to revert some changes * revert changes in build make * revert x264 version bump Co-authored-by: Force Charlie <6904176+fcharlie@users.noreply.github.com> Co-authored-by: Johnny Willemsen <jwillemsen@remedy.nl> Co-authored-by: Lennart Trunk <lennart.trunk@outlook.de> Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> Co-authored-by: Victor Romero <romerosanchezv@gmail.com>
Diffstat (limited to 'ports/libpq')
-rw-r--r--ports/libpq/CMakeLists.txt164
-rw-r--r--ports/libpq/CONTROL81
-rw-r--r--ports/libpq/config.pl27
-rw-r--r--ports/libpq/patches/linux/configure.patch22
-rw-r--r--ports/libpq/patches/windows/MSBuildProject-static-crt.patch23
-rw-r--r--ports/libpq/patches/windows/MSBuildProject-static-lib.patch13
-rw-r--r--ports/libpq/patches/windows/Mkvcbuild-static-lib.patch13
-rw-r--r--ports/libpq/patches/windows/Solution.patch39
-rw-r--r--ports/libpq/patches/windows/Solution_Debug.patch157
-rw-r--r--ports/libpq/patches/windows/Solution_Release.patch157
-rw-r--r--ports/libpq/patches/windows/arm.patch39
-rw-r--r--ports/libpq/patches/windows/install.patch225
-rw-r--r--ports/libpq/patches/windows/minimize_install.patch35
-rw-r--r--ports/libpq/patches/windows/openssl_exe_path.patch34
-rw-r--r--ports/libpq/patches/windows/win_bison_flex.patch43
-rw-r--r--ports/libpq/pg_config.darwin.h191
-rw-r--r--ports/libpq/pg_config.linux.h173
-rw-r--r--ports/libpq/portfile.cmake282
-rw-r--r--ports/libpq/vcpkg-cmake-wrapper.cmake8
19 files changed, 1182 insertions, 544 deletions
diff --git a/ports/libpq/CMakeLists.txt b/ports/libpq/CMakeLists.txt
deleted file mode 100644
index 6a03da19f..000000000
--- a/ports/libpq/CMakeLists.txt
+++ /dev/null
@@ -1,164 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
-project(libpq VERSION 9.6.1 LANGUAGES C)
-
-if(NOT CMAKE_SYSTEM_PROCESSOR)
- set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
-endif()
-
-find_package(OpenSSL REQUIRED)
-find_program(PERL NAMES perl)
-
-set(CMAKE_STATIC_LIBRARY_PREFIX)
-set(CMAKE_SHARED_LIBRARY_PREFIX)
-set(CMAKE_DEBUG_POSTFIX "d")
-
-file(REMOVE
- ${CMAKE_CURRENT_SOURCE_DIR}/src/include/pg_config.h
- ${CMAKE_CURRENT_SOURCE_DIR}/src/include/pg_config_ext.h
- ${CMAKE_CURRENT_SOURCE_DIR}/src/include/pg_config_os.h
-)
-
-if(WIN32)
- configure_file(src/include/pg_config.h.win32 include/pg_config.h)
- configure_file(src/include/pg_config_ext.h.win32 include/pg_config_ext.h)
- configure_file(src/include/port/win32.h include/pg_config_os.h)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/pg_config_ext.h" "#include <stdint.h>\n#define PG_INT64_TYPE int64_t")
- configure_file("${PORT_DIR}/pg_config.darwin.h" include/pg_config.h COPYONLY)
- configure_file(src/include/port/darwin.h include/pg_config_os.h COPYONLY)
- configure_file(src/backend/port/dynloader/darwin.h include/dynloader.h COPYONLY)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
- if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
- set(DEFINE_PG_INT128_TYPE "#define PG_INT128_TYPE __int128")
- else()
- set(DEFINE_PG_INT128_TYPE "#undef PG_INT128_TYPE")
- endif()
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/pg_config_ext.h" "#include <stdint.h>\n#define PG_INT64_TYPE int64_t")
- configure_file(src/include/port/linux.h include/pg_config_os.h COPYONLY)
- configure_file("${PORT_DIR}/pg_config.linux.h" include/pg_config.h)
- configure_file(src/backend/port/dynloader/linux.h include/dynloader.h COPYONLY)
-else()
- message(FATAL_ERROR "Unknown system: ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
-endif()
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/include/pg_config_paths.h "#define SYSCONFDIR \"\"")
-
-set(INSTALL_INCLUDES ON CACHE BOOL "Install include files")
-
-set(pg_port_src
- src/port/pgstrcasecmp.c
- src/port/pqsignal.c
- src/port/thread.c
- src/port/crypt.c
- src/port/noblock.c
- src/port/chklocale.c
- src/port/snprintf.c
- src/port/dirmod.c
- src/port/pgsleep.c
- src/port/open.c
- src/port/system.c
-)
-if(WIN32)
- list(APPEND pg_port_src
- src/port/dirent.c
- src/port/inet_aton.c
- src/port/inet_net_ntop.c
- src/port/win32error.c
- src/port/win32setlocale.c
- src/port/getaddrinfo.c
- src/port/strlcpy.c
- )
- include_directories(src/include/port/win32 src/include/port/win32_msvc)
-elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- list(APPEND pg_port_src
- src/port/strlcpy.c
- src/port/inet_aton.c
- src/port/inet_net_ntop.c
- src/port/getpeereid.c
- )
-endif()
-
-set(pg_backend_src
- src/backend/libpq/md5.c
- src/backend/libpq/ip.c
- src/backend/utils/mb/wchar.c
- src/backend/utils/mb/encnames.c
-)
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- list(APPEND pg_backend_src
- src/backend/port/dynloader/linux.c
- src/backend/port/sysv_sema.c
- src/backend/port/sysv_shmem.c
- )
-endif()
-if(NOT WIN32)
- add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/utils/errcodes.h
- COMMAND "${PERL}" "${CMAKE_CURRENT_SOURCE_DIR}/src/backend/utils/generate-errcodes.pl" "${CMAKE_CURRENT_SOURCE_DIR}/src/backend/utils/errcodes.txt" > "${CMAKE_CURRENT_BINARY_DIR}/include/utils/errcodes.h"
- VERBATIM
- )
- list(APPEND pg_backend_src
- ${CMAKE_CURRENT_BINARY_DIR}/include/utils/errcodes.h
- )
-endif()
-
-set(pg_libpq_src
- src/interfaces/libpq/fe-auth.c
- src/interfaces/libpq/fe-connect.c
- src/interfaces/libpq/fe-exec.c
- src/interfaces/libpq/fe-lobj.c
- src/interfaces/libpq/fe-misc.c
- src/interfaces/libpq/fe-print.c
- src/interfaces/libpq/fe-protocol2.c
- src/interfaces/libpq/fe-protocol3.c
- src/interfaces/libpq/fe-secure-openssl.c
- src/interfaces/libpq/fe-secure.c
- src/interfaces/libpq/libpq-events.c
- src/interfaces/libpq/pqexpbuffer.c
- src/interfaces/libpq/libpq-dist.rc
-)
-
-if(WIN32)
- list(APPEND pg_libpq_src
- src/interfaces/libpq/pthread-win32.c
- src/interfaces/libpq/win32.c
- )
-endif()
-set(pg_libpq_interface
- src/include/postgres_ext.h
- ${CMAKE_CURRENT_BINARY_DIR}/include/pg_config_ext.h
- ${CMAKE_CURRENT_BINARY_DIR}/include/pg_config.h
- src/interfaces/libpq/libpq-fe.h
- src/interfaces/libpq/libpq-events.h
-)
-set(pg_libpq_catalog_interface
- src/include/catalog/pg_type.h
- src/include/catalog/genbki.h
-)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_DEBUG_POSTFIX "d")
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-add_library(libpq ${pg_port_src} ${pg_backend_src} ${pg_libpq_src})
-
-target_compile_definitions(libpq PRIVATE -DFRONTEND -DENABLE_THREAD_SAFETY -DUSE_OPENSSL -DHAVE_CRYPTO_LOCK -D_CRT_SECURE_NO_WARNINGS)
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- target_compile_definitions(libpq PRIVATE -D_GNU_SOURCE)
-endif()
-
-target_link_libraries(libpq PRIVATE OpenSSL::SSL)
-if(WIN32)
- target_link_libraries(libpq PRIVATE ws2_32 secur32 advapi32 shell32 crypt32)
-endif()
-target_include_directories(libpq PRIVATE src/include src/port ${CMAKE_CURRENT_BINARY_DIR}/include)
-set_target_properties(libpq PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
-
-install(TARGETS libpq
- ARCHIVE DESTINATION lib
- LIBRARY DESTINATION lib
- RUNTIME DESTINATION bin
-)
-
-if(INSTALL_INCLUDES)
- install(FILES ${pg_libpq_interface} DESTINATION include)
- install(DIRECTORY src/include/libpq DESTINATION include)
- install(FILES ${pg_libpq_catalog_interface} DESTINATION include/catalog)
-endif()
diff --git a/ports/libpq/CONTROL b/ports/libpq/CONTROL
index a11b75c36..724d9acd8 100644
--- a/ports/libpq/CONTROL
+++ b/ports/libpq/CONTROL
@@ -1,5 +1,82 @@
Source: libpq
-Version: 9.6.3
+Version: 12.0
+Build-Depends: libpq[bonjour] (osx)
Homepage: https://www.postgresql.org/
Description: The official database access API of postgresql
-Build-Depends: openssl, zlib (linux)
+Default-Features: zlib, openssl
+
+Feature: openssl
+Build-Depends: openssl
+Description: support for encrypted client connections and random number generation on platforms that do not have "/dev/urandom" (except windows) (--with-openssl)
+
+Feature: zlib
+Build-Depends: zlib
+Description: Use zlib (else --without-zlib)
+
+Feature: readline
+Build-Depends: readline
+Description: Use readline (else --without-readline)
+
+Feature: libedit
+Build-Depends: libedit
+Description: prefer libedit (--with-libedit-preferred)
+
+Feature: perl
+Build-Depends: perl
+Description: build the server programming language PL/Perl (dynamic only?) (--with-perl)
+
+Feature: python
+Build-Depends: python
+Description: build the PL/Python server programming language (dynamic only?) (--with-python)
+
+Feature: tcl
+Build-Depends: tcl
+Description: build the PL/Tcl procedural language(dynamic only?) (--with-tcl)
+
+Feature: nls
+Build-Depends: gettext
+Description: Native Language Support (--enable-nls[=LANGUAGES])
+
+Feature: kerberos
+Build-Depends: kerberos
+Description: Kerberos Support (--with-gssapi)
+
+Feature: systemd
+Description: Build with support for systemd service notifications. (--with-systemd)
+
+Feature: ldap
+Build-Depends: openldap (linux)
+Description: LDAP Support (--with-ldap)
+
+Feature: bsd
+Build-Depends: openbsd
+Description: OpenBSD Support (--with-bsd-auth)
+
+Feature: pam
+Build-Depends: pam
+Description: Build with PAM (Pluggable Authentication Modules) support. (--with-pam)
+
+Feature: llvm
+Build-Depends: llvm
+Description: Build with support for LLVM based JIT compilation (--with-llvm)
+
+Feature: icu
+Build-Depends: icu
+Description: Build with support for the ICU library (--with-icu)
+
+Feature: bonjour
+Description: Build with Bonjour support (--with-bonjour)
+
+Feature: uuid
+Description: Build the uuid-ossp module (which provides functions to generate UUIDs) (--with-uuid=LIBRARY LIBRARY=(bsd|e2fs|ossp))
+
+Feature: xml
+Build-Depends: libxml2
+Description: Build with libxml (--with-libxml)
+
+Feature: xslt
+Build-Depends: libxslt
+Description: Build with libxslt (--with-libxslt)
+
+Feature: client
+Description: Build all client tools and libraries. \ No newline at end of file
diff --git a/ports/libpq/config.pl b/ports/libpq/config.pl
new file mode 100644
index 000000000..cbe605ef0
--- /dev/null
+++ b/ports/libpq/config.pl
@@ -0,0 +1,27 @@
+our $config = {
+ asserts => 0, # --enable-cassert
+ # float4byval=>1, # --disable-float4-byval, on by default
+
+ # float8byval=> $platformbits == 64, # --disable-float8-byval,
+ # off by default on 32 bit platforms, on by default on 64 bit platforms
+
+ # blocksize => 8, # --with-blocksize, 8kB by default
+ # wal_blocksize => 8, # --with-wal-blocksize, 8kB by default
+ ldap => undef, # --with-ldap
+ extraver => undef, # --with-extra-version=<string>
+ gss => undef, # --with-gssapi=<path>
+ icu => undef, # --with-icu=<path>
+ nls => undef, # --enable-nls=<path>
+ tap_tests => undef, # --enable-tap-tests
+ tcl => undef, # --with-tcl=<path>
+ perl => undef, # --with-perl
+ python => undef, # --with-python=<path>
+ openssl => undef, # --with-openssl=<path>
+ uuid => undef, # --with-ossp-uuid
+ xml => undef, # --with-libxml=<path>
+ xslt => undef, # --with-libxslt=<path>
+ iconv => undef, # (not in configure, path to iconv)
+ zlib => undef # --with-zlib=<path>
+};
+
+1;
diff --git a/ports/libpq/patches/linux/configure.patch b/ports/libpq/patches/linux/configure.patch
new file mode 100644
index 000000000..84ebcbd21
--- /dev/null
+++ b/ports/libpq/patches/linux/configure.patch
@@ -0,0 +1,22 @@
+diff --git a/configure b/configure
+index 54c852aca..96e2c89ba 100644
+--- a/configure
++++ b/configure
+@@ -11923,7 +11923,7 @@ if ${ac_cv_lib_crypto_CRYPTO_new_ex_data+:} false; then :
+ $as_echo_n "(cached) " >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+-LIBS="-lcrypto $LIBS"
++LIBS="-lcrypto -pthread $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
+@@ -11958,7 +11958,7 @@ if test "x$ac_cv_lib_crypto_CRYPTO_new_ex_data" = xyes; then :
+ #define HAVE_LIBCRYPTO 1
+ _ACEOF
+
+- LIBS="-lcrypto $LIBS"
++ LIBS="-lcrypto -pthread $LIBS"
+
+ else
+ as_fn_error $? "library 'crypto' is required for OpenSSL" "$LINENO" 5
diff --git a/ports/libpq/patches/windows/MSBuildProject-static-crt.patch b/ports/libpq/patches/windows/MSBuildProject-static-crt.patch
new file mode 100644
index 000000000..03bd832f8
--- /dev/null
+++ b/ports/libpq/patches/windows/MSBuildProject-static-crt.patch
@@ -0,0 +1,23 @@
+diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
+index 823357c02..faa3e336f 100644
+--- a/src/tools/msvc/MSBuildProject.pm
++++ b/src/tools/msvc/MSBuildProject.pm
+@@ -84,16 +84,16 @@ EOF
+ defs => "_DEBUG;DEBUG=1",
+ opt => 'Disabled',
+ strpool => 'false',
+- runtime => 'MultiThreadedDebugDLL'
++ runtime => 'MultiThreadedDebug'
+ });
+ $self->WriteItemDefinitionGroup(
+ $f,
+ 'Release',
+ {
+ defs => "",
+ opt => 'Full',
+ strpool => 'true',
+- runtime => 'MultiThreadedDLL'
++ runtime => 'MultiThreaded'
+ });
+ return;
+ }
diff --git a/ports/libpq/patches/windows/MSBuildProject-static-lib.patch b/ports/libpq/patches/windows/MSBuildProject-static-lib.patch
new file mode 100644
index 000000000..ba72a82bf
--- /dev/null
+++ b/ports/libpq/patches/windows/MSBuildProject-static-lib.patch
@@ -0,0 +1,13 @@
+diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
+index 823357c02..e1dc59aa7 100644
+--- a/src/tools/msvc/MSBuildProject.pm
++++ b/src/tools/msvc/MSBuildProject.pm
+@@ -262,7 +262,7 @@ sub WriteConfigurationPropertyGroup
+ my $cfgtype =
+ ($self->{type} eq "exe")
+ ? 'Application'
+- : ($self->{type} eq "dll" ? 'DynamicLibrary' : 'StaticLibrary');
++ : ($self->{type} eq "dll" ? 'StaticLibrary' : 'StaticLibrary');
+
+ print $f <<EOF;
+ <PropertyGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="Configuration">
diff --git a/ports/libpq/patches/windows/Mkvcbuild-static-lib.patch b/ports/libpq/patches/windows/Mkvcbuild-static-lib.patch
new file mode 100644
index 000000000..818134f5c
--- /dev/null
+++ b/ports/libpq/patches/windows/Mkvcbuild-static-lib.patch
@@ -0,0 +1,13 @@
+diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
+index 99f39caa5..4f51c12f2 100644
+--- a/src/tools/msvc/Mkvcbuild.pm
++++ b/src/tools/msvc/Mkvcbuild.pm
+@@ -182,7 +182,7 @@ sub mkvcbuild
+ 'syncrep_gram.y');
+ $postgres->AddFiles('src/backend/utils/adt', 'jsonpath_scan.l',
+ 'jsonpath_gram.y');
+- $postgres->AddDefine('BUILDING_DLL');
++ # $postgres->AddDefine('BUILDING_DLL');
+ $postgres->AddLibrary('secur32.lib');
+ $postgres->AddLibrary('ws2_32.lib');
+ $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap});
diff --git a/ports/libpq/patches/windows/Solution.patch b/ports/libpq/patches/windows/Solution.patch
new file mode 100644
index 000000000..2259e3e8a
--- /dev/null
+++ b/ports/libpq/patches/windows/Solution.patch
@@ -0,0 +1,39 @@
+diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
+index 51711c2bf..d33fdc3b0 100644
+--- a/src/tools/msvc/Solution.pm
++++ b/src/tools/msvc/Solution.pm
+@@ -69,9 +69,15 @@ sub DeterminePlatform
+ my $self = shift;
+
+ # Examine CL help output to determine if we are in 32 or 64-bit mode.
+- my $output = `cl /? 2>&1`;
++ my $output = `cl 2>&1`;
+ $? >> 8 == 0 or die "cl command not found";
+- $self->{platform} = ($output =~ /^\/favor:<.+AMD64/m) ? 'x64' : 'Win32';
++ if ($output =~ m/x64\n/) { $self->{platform} = 'x64';
++ } elsif ($output =~ m/x86\n/) { $self->{platform} = 'Win32';
++ } elsif ($output =~ m/ARM64\n/) { $self->{platform} = 'ARM64';
++ } elsif ($output =~ m/ARM\n/) { $self->{platform} = 'ARM';
++ } else { $self->{platform} = 'Unknown'
++ }
++ print "cl output $output.";
+ print "Detected hardware platform: $self->{platform}\n";
+ return;
+ }
+@@ -526,14 +526,14 @@ EOF
+ || confess "Could not open pg_config_paths.h";
+ print $o <<EOF;
+ #define PGBINDIR "/bin"
+-#define PGSHAREDIR "/share"
++#define PGSHAREDIR "/share/libpq"
+ #define SYSCONFDIR "/etc"
+ #define INCLUDEDIR "/include"
+ #define PKGINCLUDEDIR "/include"
+ #define INCLUDEDIRSERVER "/include/server"
+ #define LIBDIR "/lib"
+ #define PKGLIBDIR "/lib"
+-#define LOCALEDIR "/share/locale"
++#define LOCALEDIR "/share/libpq/locale"
+ #define DOCDIR "/doc"
+ #define HTMLDIR "/doc"
+ #define MANDIR "/man"
diff --git a/ports/libpq/patches/windows/Solution_Debug.patch b/ports/libpq/patches/windows/Solution_Debug.patch
new file mode 100644
index 000000000..646c0407f
--- /dev/null
+++ b/ports/libpq/patches/windows/Solution_Debug.patch
@@ -0,0 +1,157 @@
+diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
+index 51711c2bf..d33fdc3b0 100644
+--- a/src/tools/msvc/Solution.pm
++++ b/src/tools/msvc/Solution.pm
+@@ -650,7 +650,7 @@ sub AddProject
+ if ($self->{options}->{zlib})
+ {
+ $proj->AddIncludeDir($self->{options}->{zlib} . '\include');
+- $proj->AddLibrary($self->{options}->{zlib} . '\lib\zdll.lib');
++ $proj->AddLibrary($self->{options}->{zlib} . '\debug\lib\zlibd.lib'); # This must be updated
+ }
+ if ($self->{options}->{openssl})
+ {
+@@ -661,7 +661,7 @@ sub AddProject
+ # changed their library names from:
+ # - libeay to libcrypto
+ # - ssleay to libssl
+- if ($digit1 >= '1' && $digit2 >= '1' && $digit3 >= '0')
++ if ($digit1 >= '1' && $digit2 >= '1' && $digit3 >= '0') # This must be updated
+ {
+ my $dbgsuffix;
+ my $libsslpath;
+@@ -670,27 +670,27 @@ sub AddProject
+ # The format name of the libraries is slightly
+ # different between the Win32 and Win64 platform, so
+ # adapt.
+- if (-e "$self->{options}->{openssl}/lib/VC/sslcrypto32MD.lib")
++ if (-e "$self->{options}->{openssl}/lib/VC/sslcrypto32MD.lib") # This must be updated
+ {
+ # Win32 here, with a debugging library set.
+ $dbgsuffix = 1;
+- $libsslpath = '\lib\VC\libssl32.lib';
+- $libcryptopath = '\lib\VC\libcrypto32.lib';
++ $libsslpath = '\lib\VC\libssl32.lib'; # This must be updated
++ $libcryptopath = '\lib\VC\libcrypto32.lib'; # This must be updated
+ }
+- elsif (-e "$self->{options}->{openssl}/lib/VC/sslcrypto64MD.lib")
++ elsif (-e "$self->{options}->{openssl}/lib/VC/sslcrypto64MD.lib") # This must be updated
+ {
+ # Win64 here, with a debugging library set.
+ $dbgsuffix = 1;
+- $libsslpath = '\lib\VC\libssl64.lib';
+- $libcryptopath = '\lib\VC\libcrypto64.lib';
++ $libsslpath = '\lib\VC\libssl64.lib'; # This must be updated
++ $libcryptopath = '\lib\VC\libcrypto64.lib'; # This must be updated
+ }
+ else
+ {
+ # On both Win32 and Win64 the same library
+ # names are used without a debugging context.
+ $dbgsuffix = 0;
+- $libsslpath = '\lib\libssl.lib';
+- $libcryptopath = '\lib\libcrypto.lib';
++ $libsslpath = '\debug\lib\libssl.lib'; # This must be updated
++ $libcryptopath = '\debug\lib\libcrypto.lib'; # This must be updated
+ }
+
+ $proj->AddLibrary($self->{options}->{openssl} . $libsslpath,
+@@ -698,16 +698,16 @@ sub AddProject
+ $proj->AddLibrary($self->{options}->{openssl} . $libcryptopath,
+ $dbgsuffix);
+ }
+- else
++ else
+ {
+ # Choose which set of libraries to use depending on if
+ # debugging libraries are in place in the installer.
+- if (-e "$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
++ if (-e "$self->{options}->{openssl}/lib/VC/ssleay32MD.lib") # This must be updated
+ {
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1);
++ $self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1); # This must be updated
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1);
++ $self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1); # This must be updated
+ }
+ else
+ {
+@@ -715,60 +715,60 @@ sub AddProject
+ # to be here, so don't ask for it in last
+ # parameter.
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\ssleay32.lib', 0);
++ $self->{options}->{openssl} . '\debug\lib\ssleay32.lib', 0); # This must be updated
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\libeay32.lib', 0);
++ $self->{options}->{openssl} . '\debug\lib\libeay32.lib', 0); # This must be updated
+ }
+ }
+ }
+ if ($self->{options}->{nls})
+ {
+ $proj->AddIncludeDir($self->{options}->{nls} . '\include');
+- $proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib');
++ $proj->AddLibrary($self->{options}->{nls} . '\debug\lib\libintl.lib'); # This must be updated
+ }
+ if ($self->{options}->{gss})
+ {
+- $proj->AddIncludeDir($self->{options}->{gss} . '\inc\krb5');
+- $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\krb5_32.lib');
+- $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\comerr32.lib');
+- $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\gssapi32.lib');
++ $proj->AddIncludeDir($self->{options}->{gss} . '\inc\krb5'); # This must be updated
++ $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\krb5_32.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\comerr32.lib');# This must be updated
++ $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\gssapi32.lib');# This must be updated
+ }
+ if ($self->{options}->{iconv})
+ {
+ $proj->AddIncludeDir($self->{options}->{iconv} . '\include');
+- $proj->AddLibrary($self->{options}->{iconv} . '\lib\iconv.lib');
++ $proj->AddLibrary($self->{options}->{iconv} . '\debug\lib\iconv.lib'); # This must be updated
+ }
+ if ($self->{options}->{icu})
+ {
+ $proj->AddIncludeDir($self->{options}->{icu} . '\include');
+ if ($self->{platform} eq 'Win32')
+ {
+- $proj->AddLibrary($self->{options}->{icu} . '\lib\icuin.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib\icuuc.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib\icudt.lib');
++ $proj->AddLibrary($self->{options}->{icu} . '\debug\lib\icuind.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\debug\lib\icuucd.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\debug\lib\icudtd.lib'); # This must be updated
+ }
+ else
+ {
+- $proj->AddLibrary($self->{options}->{icu} . '\lib64\icuin.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib64\icuuc.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib64\icudt.lib');
++ $proj->AddLibrary($self->{options}->{icu} . '\debug\lib\icuind.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\debug\lib\icuucd.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\debug\lib\icudtd.lib'); # This must be updated
+ }
+ }
+ if ($self->{options}->{xml})
+ {
+ $proj->AddIncludeDir($self->{options}->{xml} . '\include');
+ $proj->AddIncludeDir($self->{options}->{xml} . '\include\libxml2');
+- $proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib');
++ $proj->AddLibrary($self->{options}->{xml} . '\debug\lib\libxml2.lib'); # This must be updated
+ }
+ if ($self->{options}->{xslt})
+ {
+ $proj->AddIncludeDir($self->{options}->{xslt} . '\include');
+- $proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib');
++ $proj->AddLibrary($self->{options}->{xslt} . '\debug\lib\libxslt.lib'); # This must be updated
+ }
+ if ($self->{options}->{uuid})
+ {
+ $proj->AddIncludeDir($self->{options}->{uuid} . '\include');
+- $proj->AddLibrary($self->{options}->{uuid} . '\lib\uuid.lib');
++ $proj->AddLibrary($self->{options}->{uuid} . '\debug\lib\uuid.lib'); # This must be updated
+ }
+ return $proj;
+ }
diff --git a/ports/libpq/patches/windows/Solution_Release.patch b/ports/libpq/patches/windows/Solution_Release.patch
new file mode 100644
index 000000000..442beb6c7
--- /dev/null
+++ b/ports/libpq/patches/windows/Solution_Release.patch
@@ -0,0 +1,157 @@
+diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
+index 51711c2bf..d33fdc3b0 100644
+--- a/src/tools/msvc/Solution.pm
++++ b/src/tools/msvc/Solution.pm
+@@ -650,7 +650,7 @@ sub AddProject
+ if ($self->{options}->{zlib})
+ {
+ $proj->AddIncludeDir($self->{options}->{zlib} . '\include');
+- $proj->AddLibrary($self->{options}->{zlib} . '\lib\zdll.lib');
++ $proj->AddLibrary($self->{options}->{zlib} . '\lib\zlib.lib'); # This must be updated
+ }
+ if ($self->{options}->{openssl})
+ {
+@@ -661,7 +661,7 @@ sub AddProject
+ # changed their library names from:
+ # - libeay to libcrypto
+ # - ssleay to libssl
+- if ($digit1 >= '1' && $digit2 >= '1' && $digit3 >= '0')
++ if ($digit1 >= '1' && $digit2 >= '1' && $digit3 >= '0') # This must be updated
+ {
+ my $dbgsuffix;
+ my $libsslpath;
+@@ -670,27 +670,27 @@ sub AddProject
+ # The format name of the libraries is slightly
+ # different between the Win32 and Win64 platform, so
+ # adapt.
+- if (-e "$self->{options}->{openssl}/lib/VC/sslcrypto32MD.lib")
++ if (-e "$self->{options}->{openssl}/lib/VC/sslcrypto32MD.lib") # This must be updated
+ {
+ # Win32 here, with a debugging library set.
+ $dbgsuffix = 1;
+- $libsslpath = '\lib\VC\libssl32.lib';
+- $libcryptopath = '\lib\VC\libcrypto32.lib';
++ $libsslpath = '\lib\VC\libssl32.lib'; # This must be updated
++ $libcryptopath = '\lib\VC\libcrypto32.lib'; # This must be updated
+ }
+- elsif (-e "$self->{options}->{openssl}/lib/VC/sslcrypto64MD.lib")
++ elsif (-e "$self->{options}->{openssl}/lib/VC/sslcrypto64MD.lib") # This must be updated
+ {
+ # Win64 here, with a debugging library set.
+ $dbgsuffix = 1;
+- $libsslpath = '\lib\VC\libssl64.lib';
+- $libcryptopath = '\lib\VC\libcrypto64.lib';
++ $libsslpath = '\lib\VC\libssl64.lib'; # This must be updated
++ $libcryptopath = '\lib\VC\libcrypto64.lib'; # This must be updated
+ }
+ else
+ {
+ # On both Win32 and Win64 the same library
+ # names are used without a debugging context.
+ $dbgsuffix = 0;
+- $libsslpath = '\lib\libssl.lib';
+- $libcryptopath = '\lib\libcrypto.lib';
++ $libsslpath = '\lib\libssl.lib'; # This must be updated
++ $libcryptopath = '\lib\libcrypto.lib'; # This must be updated
+ }
+
+ $proj->AddLibrary($self->{options}->{openssl} . $libsslpath,
+@@ -698,16 +698,16 @@ sub AddProject
+ $proj->AddLibrary($self->{options}->{openssl} . $libcryptopath,
+ $dbgsuffix);
+ }
+- else
++ else
+ {
+ # Choose which set of libraries to use depending on if
+ # debugging libraries are in place in the installer.
+- if (-e "$self->{options}->{openssl}/lib/VC/ssleay32MD.lib")
++ if (-e "$self->{options}->{openssl}/lib/VC/ssleay32MD.lib") # This must be updated
+ {
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1);
++ $self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1); # This must be updated
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1);
++ $self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1); # This must be updated
+ }
+ else
+ {
+@@ -715,60 +715,60 @@ sub AddProject
+ # to be here, so don't ask for it in last
+ # parameter.
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\ssleay32.lib', 0);
++ $self->{options}->{openssl} . '\lib\ssleay32.lib', 0); # This must be updated
+ $proj->AddLibrary(
+- $self->{options}->{openssl} . '\lib\libeay32.lib', 0);
++ $self->{options}->{openssl} . '\lib\libeay32.lib', 0); # This must be updated
+ }
+ }
+ }
+ if ($self->{options}->{nls})
+ {
+ $proj->AddIncludeDir($self->{options}->{nls} . '\include');
+- $proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib');
++ $proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib'); # This must be updated
+ }
+ if ($self->{options}->{gss})
+ {
+- $proj->AddIncludeDir($self->{options}->{gss} . '\inc\krb5');
+- $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\krb5_32.lib');
+- $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\comerr32.lib');
+- $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\gssapi32.lib');
++ $proj->AddIncludeDir($self->{options}->{gss} . '\inc\krb5'); # This must be updated
++ $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\krb5_32.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\comerr32.lib');# This must be updated
++ $proj->AddLibrary($self->{options}->{gss} . '\lib\i386\gssapi32.lib');# This must be updated
+ }
+ if ($self->{options}->{iconv})
+ {
+ $proj->AddIncludeDir($self->{options}->{iconv} . '\include');
+- $proj->AddLibrary($self->{options}->{iconv} . '\lib\iconv.lib');
++ $proj->AddLibrary($self->{options}->{iconv} . '\lib\iconv.lib'); # This must be updated
+ }
+ if ($self->{options}->{icu})
+ {
+ $proj->AddIncludeDir($self->{options}->{icu} . '\include');
+ if ($self->{platform} eq 'Win32')
+ {
+- $proj->AddLibrary($self->{options}->{icu} . '\lib\icuin.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib\icuuc.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib\icudt.lib');
++ $proj->AddLibrary($self->{options}->{icu} . '\lib\icuin.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\lib\icuuc.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\lib\icudt.lib'); # This must be updated
+ }
+ else
+ {
+- $proj->AddLibrary($self->{options}->{icu} . '\lib64\icuin.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib64\icuuc.lib');
+- $proj->AddLibrary($self->{options}->{icu} . '\lib64\icudt.lib');
++ $proj->AddLibrary($self->{options}->{icu} . '\lib\icuin.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\lib\icuuc.lib'); # This must be updated
++ $proj->AddLibrary($self->{options}->{icu} . '\lib\icudt.lib'); # This must be updated
+ }
+ }
+ if ($self->{options}->{xml})
+ {
+ $proj->AddIncludeDir($self->{options}->{xml} . '\include');
+ $proj->AddIncludeDir($self->{options}->{xml} . '\include\libxml2');
+- $proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib');
++ $proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib'); # This must be updated
+ }
+ if ($self->{options}->{xslt})
+ {
+ $proj->AddIncludeDir($self->{options}->{xslt} . '\include');
+- $proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib');
++ $proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib'); # This must be updated
+ }
+ if ($self->{options}->{uuid})
+ {
+ $proj->AddIncludeDir($self->{options}->{uuid} . '\include');
+- $proj->AddLibrary($self->{options}->{uuid} . '\lib\uuid.lib');
++ $proj->AddLibrary($self->{options}->{uuid} . '\lib\uuid.lib'); # This must be updated
+ }
+ return $proj;
+ }
diff --git a/ports/libpq/patches/windows/arm.patch b/ports/libpq/patches/windows/arm.patch
new file mode 100644
index 000000000..0e47c34b9
--- /dev/null
+++ b/ports/libpq/patches/windows/arm.patch
@@ -0,0 +1,39 @@
+diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm
+index 99f39caa5..4f51c12f2 100644
+--- a/src/tools/msvc/Mkvcbuild.pm
++++ b/src/tools/msvc/Mkvcbuild.pm
+@@ -110,8 +110,8 @@ sub mkvcbuild
+
+ if ($vsVersion >= '9.00')
+ {
+- push(@pgportfiles, 'pg_crc32c_sse42_choose.c');
+- push(@pgportfiles, 'pg_crc32c_sse42.c');
++ #push(@pgportfiles, 'pg_crc32c_sse42_choose.c');
++ #push(@pgportfiles, 'pg_crc32c_sse42.c');
+ push(@pgportfiles, 'pg_crc32c_sb8.c');
+ }
+ else
+diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
+index 823357c02..625f32bf8 100644
+--- a/src/tools/msvc/MSBuildProject.pm
++++ b/src/tools/msvc/MSBuildProject.pm
+@@ -307,9 +307,8 @@ sub WriteItemDefinitionGroup
+ : ($self->{type} eq "dll" ? 'DynamicLibrary' : 'StaticLibrary');
+ my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';');
+
+- my $targetmachine =
+- $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64';
+-
++ my $targetmachine = $self->{platform} eq 'ARM64' ? 'MachineARM64' : 'MachineARM';
++
+ my $includes = $self->{includes};
+ unless ($includes eq '' or $includes =~ /;$/)
+ {
+@@ -347,7 +349,6 @@ sub WriteItemDefinitionGroup
+ <ProgramDatabaseFile>.\\$cfgname\\$self->{name}\\$self->{name}.pdb</ProgramDatabaseFile>
+ <GenerateMapFile>false</GenerateMapFile>
+ <MapFileName>.\\$cfgname\\$self->{name}\\$self->{name}.map</MapFileName>
+- <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <!-- Permit links to MinGW-built, 32-bit DLLs (default before VS2012). -->
+ <ImageHasSafeExceptionHandlers/>
+ <SubSystem>Console</SubSystem>
diff --git a/ports/libpq/patches/windows/install.patch b/ports/libpq/patches/windows/install.patch
new file mode 100644
index 000000000..206dd1da0
--- /dev/null
+++ b/ports/libpq/patches/windows/install.patch
@@ -0,0 +1,225 @@
+diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
+index d109b2c90..75c7446e6 100644
+--- a/src/tools/msvc/Install.pm
++++ b/src/tools/msvc/Install.pm
+@@ -106,7 +106,7 @@ sub Install
+ }
+ },
+ @top_dir);
+- CopySetOfFiles('config files', $sample_files, $target . '/share/');
++ CopySetOfFiles('config files', $sample_files, $target . '/share/libpq/');
+ CopyFiles(
+ 'Import libraries',
+ $target . '/lib/',
+@@ -78,10 +78,10 @@ sub Install
+ my $majorver = DetermineMajorVersion();
+ print "Installing version $majorver for $conf in $target\n";
+
+- my @client_dirs = ('bin', 'lib', 'share', 'symbols');
++ my @client_dirs = ('bin', 'lib', 'share', 'tools', 'share/libpq', 'tools/libpq');
+ my @all_dirs = (
+- @client_dirs, 'doc', 'doc/contrib', 'doc/extension', 'share/contrib',
+- 'share/extension', 'share/timezonesets', 'share/tsearch_data');
++ @client_dirs, 'doc', 'doc/libpq', 'doc/libpq/contrib', 'doc/libpq/extension', 'share/libpq/contrib',
++ 'share/libpq/extension', 'share/libpq/timezonesets', 'share/libpq/tsearch_data');
+ if ($insttype eq "client")
+ {
+ EnsureDirectories($target, @client_dirs);
+@@ -120,35 +120,35 @@ sub Install
+ CopySetOfFiles(
+ 'timezone names',
+ [ glob('src\timezone\tznames\*.txt') ],
+- $target . '/share/timezonesets/');
++ $target . '/share/libpq/timezonesets/');
+ CopyFiles(
+ 'timezone sets',
+- $target . '/share/timezonesets/',
++ $target . '/share/libpq/timezonesets/',
+ 'src/timezone/tznames/', 'Default', 'Australia', 'India');
+ CopySetOfFiles(
+ 'BKI files',
+ [ glob("src\\backend\\catalog\\postgres.*") ],
+- $target . '/share/');
++ $target . '/share/libpq/');
+ CopySetOfFiles(
+ 'SQL files',
+ [ glob("src\\backend\\catalog\\*.sql") ],
+- $target . '/share/');
++ $target . '/share/libpq/');
+ CopyFiles(
+- 'Information schema data', $target . '/share/',
++ 'Information schema data', $target . '/share/libpq/',
+ 'src/backend/catalog/', 'sql_features.txt');
+ CopyFiles(
+- 'Error code data', $target . '/share/',
++ 'Error code data', $target . '/share/libpq/',
+ 'src/backend/utils/', 'errcodes.txt');
+ GenerateTimezoneFiles($target, $conf);
+ GenerateTsearchFiles($target);
+ CopySetOfFiles(
+ 'Stopword files',
+ [ glob("src\\backend\\snowball\\stopwords\\*.stop") ],
+- $target . '/share/tsearch_data/');
++ $target . '/share/libpq/tsearch_data/');
+ CopySetOfFiles(
+ 'Dictionaries sample files',
+ [ glob("src\\backend\\tsearch\\dicts\\*_sample*") ],
+- $target . '/share/tsearch_data/');
++ $target . '/share/libpq/tsearch_data/');
+
+ my $pl_extension_files = [];
+ my @pldirs = ('src/pl/plpgsql/src');
+@@ -167,7 +167,7 @@ sub Install
+ },
+ @pldirs);
+ CopySetOfFiles('PL Extension files',
+- $pl_extension_files, $target . '/share/extension/');
++ $pl_extension_files, $target . '/share/libpq/extension/');
+ }
+
+ GenerateNLSFiles($target, $config->{nls}, $majorver) if ($config->{nls});
+@@ -282,23 +282,26 @@ sub CopySolutionOutput
+ {
+ if ($1 == 1)
+ {
+- push(@{ $install_list{'bin'} }, "exe");
++ push(@{ $install_list{'tools\\libpq'} }, "exe");
+ }
+ elsif ($1 == 2)
+ {
+- push(@{ $install_list{'lib'} }, "dll");
++ push(@{ $install_list{'bin'} }, "dll");
+ if ($is_sharedlib)
+ {
+ push(@{ $install_list{'bin'} }, "dll");
+ push(@{ $install_list{'lib'} }, "lib");
+ }
++ else
++ {
++ push(@{ $install_list{'lib'} }, "lib");
++ }
+ }
+ else
+ {
+-
++ push(@{ $install_list{'lib'} }, "lib");
+ # Static libraries, such as libpgport, only used internally
+ # during build, don't install.
+- next;
+ }
+ }
+ elsif ($vcproj eq 'vcxproj'
+@@ -306,11 +309,11 @@ sub CopySolutionOutput
+ {
+ if ($1 eq 'Application')
+ {
+- push(@{ $install_list{'bin'} }, "exe");
++ push(@{ $install_list{'tools\\libpq'} }, "exe");
+ }
+ elsif ($1 eq 'DynamicLibrary')
+ {
+- push(@{ $install_list{'lib'} }, "dll");
++ push(@{ $install_list{'bin'} }, "dll");
+ if ($is_sharedlib)
+ {
+ push(@{ $install_list{'bin'} }, "dll");
+@@ -319,10 +322,9 @@ sub CopySolutionOutput
+ }
+ else # 'StaticLibrary'
+ {
+-
++ push(@{ $install_list{'lib'} }, "lib");
+ # Static lib, such as libpgport, only used internally
+ # during build, don't install.
+- next;
+ }
+ }
+ else
+@@ -339,7 +339,7 @@ sub CopySolutionOutput
+ || croak "Could not copy $pf.$ext\n";
+ }
+ }
+- lcopy("$conf\\$pf\\$pf.pdb", "$target\\symbols\\$pf.pdb")
++ lcopy("$conf\\$pf\\$pf.pdb", "$target\\bin\\$pf.pdb")
+ || croak "Could not copy $pf.pdb\n";
+ print ".";
+ }
+@@ -366,7 +366,7 @@ sub GenerateTimezoneFiles
+ print "Generating timezone files...";
+
+ my @args =
+- ("$conf/zic/zic", '-d', "$target/share/timezone", '-p', "$posixrules");
++ ("$conf/zic/zic", '-d', "$target/share/libpq/timezone", '-p', "$posixrules");
+ foreach (@tzfiles)
+ {
+ my $tzfile = $_;
+@@ -391,7 +391,7 @@ sub GenerateTsearchFiles
+ $mf =~ /^LANGUAGES\s*=\s*(.*)$/m
+ || die "Could not find LANGUAGES line in snowball Makefile\n";
+ my @pieces = split /\s+/, $1;
+- open($F, '>', "$target/share/snowball_create.sql")
++ open($F, '>', "$target/share/libpq/snowball_create.sql")
+ || die "Could not write snowball_create.sql";
+ print $F read_file('src/backend/snowball/snowball_func.sql.in');
+
+@@ -476,7 +476,7 @@ sub CopySubdirFiles
+ foreach my $f (split /\s+/, $flist)
+ {
+ lcopy("$subdir/$module/$f.control",
+- "$target/share/extension/$f.control")
++ "$target/share/libpq/extension/$f.control")
+ || croak("Could not copy file $f.control in contrib $module");
+ print '.';
+ }
+@@ -494,7 +494,7 @@ sub CopySubdirFiles
+ foreach my $f (split /\s+/, $flist)
+ {
+ lcopy("$subdir/$module/$f",
+- "$target/share/$moduledir/" . basename($f))
++ "$target/share/libpq/$moduledir/" . basename($f))
+ || croak("Could not copy file $f in contrib $module");
+ print '.';
+ }
+@@ -509,7 +509,7 @@ sub CopySubdirFiles
+ foreach my $f (split /\s+/, $flist)
+ {
+ lcopy("$subdir/$module/$f",
+- "$target/share/tsearch_data/" . basename($f))
++ "$target/share/libpq/tsearch_data/" . basename($f))
+ || croak("Could not copy file $f in $subdir $module");
+ print '.';
+ }
+@@ -572,7 +572,7 @@ sub CopySubdirFiles
+ if ($module eq 'spi');
+ foreach my $f (split /\s+/, $flist)
+ {
+- lcopy("$subdir/$module/$f", "$target/doc/$moduledir/$f")
++ lcopy("$subdir/$module/$f", "$target/doc/libpq/$moduledir/$f")
+ || croak("Could not copy file $f in contrib $module");
+ print '.';
+ }
+@@ -701,7 +701,7 @@ sub GenerateNLSFiles
+ my $majorver = shift;
+
+ print "Installing NLS files...";
+- EnsureDirectories($target, "share/locale");
++ EnsureDirectories($target, "share/libpq/locale");
+ my @flist;
+ File::Find::find(
+ {
+@@ -723,12 +723,12 @@ sub GenerateNLSFiles
+ next unless /([^\/]+)\.po/;
+ $lang = $1;
+
+- EnsureDirectories($target, "share/locale/$lang",
+- "share/locale/$lang/LC_MESSAGES");
++ EnsureDirectories($target, "share/libpq/locale/$lang",
++ "share/libpq/locale/$lang/LC_MESSAGES");
+ my @args = (
+ "$nlspath\\bin\\msgfmt",
+ '-o',
+- "$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo",
++ "$target\\share\\libpq\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo",
+ $_);
+ system(@args) && croak("Could not run msgfmt on $dir\\$_");
+ print ".";
diff --git a/ports/libpq/patches/windows/minimize_install.patch b/ports/libpq/patches/windows/minimize_install.patch
new file mode 100644
index 000000000..1d1eb2b57
--- /dev/null
+++ b/ports/libpq/patches/windows/minimize_install.patch
@@ -0,0 +1,35 @@
+diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm
+index d109b2c90..75c7446e6 100644
+--- a/src/tools/msvc/Install.pm
++++ b/src/tools/msvc/Install.pm
+@@ -19,13 +19,13 @@ our (@ISA, @EXPORT_OK);
+
+ my $insttype;
+ my @client_contribs = ('oid2name', 'pgbench', 'vacuumlo');
+-my @client_program_files = (
+- 'clusterdb', 'createdb', 'createuser', 'dropdb',
+- 'dropuser', 'ecpg', 'libecpg', 'libecpg_compat',
+- 'libpgtypes', 'libpq', 'pg_basebackup', 'pg_config',
+- 'pg_dump', 'pg_dumpall', 'pg_isready', 'pg_receivewal',
+- 'pg_recvlogical', 'pg_restore', 'psql', 'reindexdb',
+- 'vacuumdb', @client_contribs);
++my @client_program_files = ( 'libecpg','libecpg_compat', 'libpgtypes', 'libpq' );
++ # 'clusterdb', 'createdb', 'createuser', 'dropdb',
++ # 'dropuser', 'ecpg', 'libecpg', 'libecpg_compat',
++ #'libpgtypes', 'libpq', 'pg_basebackup', 'pg_config',
++ #'pg_dump', 'pg_dumpall', 'pg_isready', 'pg_receivewal',
++ #'pg_recvlogical', 'pg_restore', 'psql', 'reindexdb',
++ #'vacuumdb', @client_contribs);
+
+ sub lcopy
+ {
+@@ -110,7 +110,7 @@ sub Install
+ CopyFiles(
+ 'Import libraries',
+ $target . '/lib/',
+- "$conf\\", "postgres\\postgres.lib", "libpgcommon\\libpgcommon.lib",
++ "$conf\\", "libpgcommon\\libpgcommon.lib",
+ "libpgport\\libpgport.lib");
+ CopyContribFiles($config, $target);
+ CopyIncludeFiles($target);
+
diff --git a/ports/libpq/patches/windows/openssl_exe_path.patch b/ports/libpq/patches/windows/openssl_exe_path.patch
new file mode 100644
index 000000000..cf2930f7f
--- /dev/null
+++ b/ports/libpq/patches/windows/openssl_exe_path.patch
@@ -0,0 +1,34 @@
+diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
+index 51711c2bf..d33fdc3b0 100644
+--- a/src/tools/msvc/Solution.pm
++++ b/src/tools/msvc/Solution.pm
+@@ -127,19 +127,19 @@ sub GetOpenSSLVersion
+ # openssl.exe is in the specified directory.
+ my $opensslcmd =
+ $self->{options}->{openssl} . "\\bin\\openssl.exe version 2>&1";
+- my $sslout = `$opensslcmd`;
++ #my $sslout = `$opensslcmd`;
+
+- $? >> 8 == 0
+- or croak
+- "Unable to determine OpenSSL version: The openssl.exe command wasn't found.";
++ #$? >> 8 == 0
++ # or croak
++ # "Unable to determine OpenSSL version: The openssl.exe command wasn't found.";
+
+- if ($sslout =~ /(\d+)\.(\d+)\.(\d+)(\D)/m)
+- {
+- return ($1, $2, $3);
+- }
++ #if ($sslout =~ /(\d+)\.(\d+)\.(\d+)(\D)/m)
++ #{
++ return (1, 1, 1);
++ #}
+
+- croak
+- "Unable to determine OpenSSL version: The openssl.exe version could not be determined.";
++ #croak
++ # "Unable to determine OpenSSL version: The openssl.exe version could not be determined.";
+ }
+
+ sub GenerateFiles
diff --git a/ports/libpq/patches/windows/win_bison_flex.patch b/ports/libpq/patches/windows/win_bison_flex.patch
new file mode 100644
index 000000000..95df3f495
--- /dev/null
+++ b/ports/libpq/patches/windows/win_bison_flex.patch
@@ -0,0 +1,43 @@
+diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl
+index aceed5ffd..f6ed215e8 100644
+--- a/src/tools/msvc/pgflex.pl
++++ b/src/tools/msvc/pgflex.pl
+@@ -12,7 +12,7 @@ $ENV{CYGWIN} = 'nodosfilewarning';
+
+ do './src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
+
+-my ($flexver) = `flex -V`; # grab first line
++my ($flexver) = `win_flex -V`; # grab first line
+ $flexver = (split(/\s+/, $flexver))[1];
+ $flexver =~ s/[^0-9.]//g;
+ my @verparts = split(/\./, $flexver);
+@@ -48,7 +47,7 @@ close($mf);
+ my $basetarg = basename($output);
+ my $flexflags = ($make =~ /^$basetarg:\s*FLEXFLAGS\s*=\s*(\S.*)/m ? $1 : '');
+
+-system("flex $flexflags -o$output $input");
++system("win_flex $flexflags -o$output $input");
+ if ($? == 0)
+ {
+
+diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl
+index 895e398c0..f5b524a5d 100644
+--- a/src/tools/msvc/pgbison.pl
++++ b/src/tools/msvc/pgbison.pl
+@@ -9,7 +9,7 @@ use File::Basename;
+
+ do './src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl';
+
+-my ($bisonver) = `bison -V`; # grab first line
++my ($bisonver) = `win_bison -V`; # grab first line
+ $bisonver = (split(/\s+/, $bisonver))[3]; # grab version number
+
+ unless ($bisonver eq '1.875' || $bisonver ge '2.2')
+@@ -45,5 +45,5 @@ close($mf);
+ my $basetarg = basename($output);
+ my $headerflag = ($make =~ /^$basetarg:\s+BISONFLAGS\b.*-d/m ? '-d' : '');
+
+-system("bison $headerflag $input -o $output");
++system("win_bison $headerflag $input -o $output");
+ exit $? >> 8;
+
diff --git a/ports/libpq/pg_config.darwin.h b/ports/libpq/pg_config.darwin.h
deleted file mode 100644
index 5db9f84d2..000000000
--- a/ports/libpq/pg_config.darwin.h
+++ /dev/null
@@ -1,191 +0,0 @@
-#define ACCEPT_TYPE_ARG1 int
-#define ACCEPT_TYPE_ARG2 struct sockaddr *
-#define ACCEPT_TYPE_ARG3 socklen_t
-#define ACCEPT_TYPE_RETURN int
-#define ALIGNOF_DOUBLE 8
-#define ALIGNOF_INT 4
-#define ALIGNOF_LONG 8
-#define ALIGNOF_SHORT 2
-#define BLCKSZ 8192
-#define DEF_PGPORT 5432
-#define DEF_PGPORT_STR "5432"
-#define ENABLE_THREAD_SAFETY 1
-#define FLEXIBLE_ARRAY_MEMBER /**/
-#define FLOAT4PASSBYVAL true
-#define FLOAT8PASSBYVAL true
-#ifdef GETTIMEOFDAY_1ARG
-# define gettimeofday(a,b) gettimeofday(a)
-#endif
-#define HAVE_ATOMICS 1
-#define HAVE_CBRT 1
-#define HAVE_CRYPT 1
-#define HAVE_DECL_FDATASYNC 0
-#define HAVE_DECL_F_FULLFSYNC 1
-#define HAVE_DECL_POSIX_FADVISE 0
-#define HAVE_DECL_SNPRINTF 1
-#define HAVE_DECL_STRLCAT 1
-#define HAVE_DECL_STRLCPY 1
-#define HAVE_DECL_SYS_SIGLIST 1
-#define HAVE_DECL_VSNPRINTF 1
-#define HAVE_DLOPEN 1
-#define HAVE_FDATASYNC 1
-#define HAVE_FLS 1
-#define HAVE_FSEEKO 1
-#define HAVE_FUNCNAME__FUNC 1
-#define HAVE_GCC__ATOMIC_INT32_CAS 1
-#define HAVE_GCC__ATOMIC_INT64_CAS 1
-#define HAVE_GCC__SYNC_CHAR_TAS 1
-#define HAVE_GCC__SYNC_INT32_CAS 1
-#define HAVE_GCC__SYNC_INT32_TAS 1
-#define HAVE_GCC__SYNC_INT64_CAS 1
-#define HAVE_GETADDRINFO 1
-#define HAVE_GETIFADDRS 1
-#define HAVE_GETOPT 1
-#define HAVE_GETOPT_H 1
-#define HAVE_GETOPT_LONG 1
-#define HAVE_GETPEEREID 1
-#define HAVE_GETPWUID_R 1
-#define HAVE_GETRLIMIT 1
-#define HAVE_GETRUSAGE 1
-#define HAVE_HISTORY_TRUNCATE_FILE 1
-#define HAVE_IFADDRS_H 1
-#define HAVE_INET_ATON 1
-#define HAVE_INTPTR_T 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_INT_OPTERR 1
-#define HAVE_INT_OPTRESET 1
-#define HAVE_INT_TIMEZONE 1
-#define HAVE_IPV6 1
-#define HAVE_ISINF 1
-#define HAVE_LANGINFO_H 1
-#define HAVE_LIBM 1
-#define HAVE_LIBREADLINE 1
-#define HAVE_LIBZ 1
-#define HAVE_LOCALE_T 1
-#define HAVE_LONG_INT_64 1
-#define HAVE_LONG_LONG_INT 1
-#define HAVE_MBSTOWCS_L 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MEMORY_H 1
-#define HAVE_MKDTEMP 1
-#define HAVE_NETINET_IN_H 1
-#define HAVE_NETINET_TCP_H 1
-#define HAVE_NET_IF_H 1
-#define HAVE_POLL 1
-#define HAVE_POLL_H 1
-#define HAVE_PTHREAD 1
-#define HAVE_PTHREAD_IS_THREADED_NP 1
-#define HAVE_PTHREAD_PRIO_INHERIT 1
-#define HAVE_PWD_H 1
-#define HAVE_RANDOM 1
-#define HAVE_READLINE_HISTORY_H 1
-#define HAVE_READLINE_READLINE_H 1
-#define HAVE_READLINK 1
-#define HAVE_RINT 1
-#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
-#define HAVE_RL_COMPLETION_MATCHES 1
-#define HAVE_RL_FILENAME_COMPLETION_FUNCTION 1
-#define HAVE_SETSID 1
-#define HAVE_SHM_OPEN 1
-#define HAVE_SNPRINTF 1
-#define HAVE_SPINLOCKS 1
-#define HAVE_SRANDOM 1
-#define HAVE_SSL_GET_CURRENT_COMPRESSION 1
-#define HAVE_STDINT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRERROR 1
-#define HAVE_STRERROR_R 1
-#define HAVE_STRINGS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRLCAT 1
-#define HAVE_STRLCPY 1
-#define HAVE_STRTOLL 1
-#define HAVE_STRTOULL 1
-#define HAVE_STRUCT_ADDRINFO 1
-#define HAVE_STRUCT_OPTION 1
-#define HAVE_STRUCT_SOCKADDR_SA_LEN 1
-#define HAVE_STRUCT_SOCKADDR_STORAGE 1
-#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
-#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1
-#define HAVE_STRUCT_TM_TM_ZONE 1
-#define HAVE_SYMLINK 1
-#define HAVE_SYSLOG 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_IPC_H 1
-#define HAVE_SYS_POLL_H 1
-#define HAVE_SYS_RESOURCE_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_SEM_H 1
-#define HAVE_SYS_SHM_H 1
-#define HAVE_SYS_SOCKET_H 1
-#define HAVE_SYS_SOCKIO_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_UCRED_H 1
-#define HAVE_SYS_UN_H 1
-#define HAVE_TERMIOS_H 1
-#define HAVE_TM_ZONE 1
-#define HAVE_TOWLOWER 1
-#define HAVE_TZNAME 1
-#define HAVE_UINTPTR_T 1
-#define HAVE_UNION_SEMUN 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UNIX_SOCKETS 1
-#define HAVE_UNSETENV 1
-#define HAVE_UNSIGNED_LONG_LONG_INT 1
-#define HAVE_UTIME 1
-#define HAVE_UTIMES 1
-#define HAVE_UTIME_H 1
-#define HAVE_VSNPRINTF 1
-#define HAVE_WCHAR_H 1
-#define HAVE_WCSTOMBS 1
-#define HAVE_WCSTOMBS_L 1
-#define HAVE_WCTYPE_H 1
-#define HAVE__BUILTIN_BSWAP32 1
-#define HAVE__BUILTIN_BSWAP64 1
-#define HAVE__BUILTIN_CONSTANT_P 1
-#define HAVE__BUILTIN_TYPES_COMPATIBLE_P 1
-#define HAVE__BUILTIN_UNREACHABLE 1
-#define HAVE__GET_CPUID 1
-#define HAVE__STATIC_ASSERT 1
-#define HAVE__VA_ARGS 1
-#define INT64_MODIFIER "l"
-#define LOCALE_T_IN_XLOCALE 1
-#define MAXIMUM_ALIGNOF 8
-#define MEMSET_LOOP_LIMIT 1024
-#define PACKAGE_BUGREPORT "pgsql-bugs@postgresql.org"
-#define PACKAGE_NAME "PostgreSQL"
-#define PACKAGE_STRING "PostgreSQL 9.6.3"
-#define PACKAGE_TARNAME "postgresql"
-#define PACKAGE_URL ""
-#define PACKAGE_VERSION "9.6.3"
-#define PG_INT128_TYPE __int128
-#define PG_INT64_TYPE long int
-#define PG_KRB_SRVNAM "postgres"
-#define PG_MAJORVERSION "9.6"
-#define PG_PRINTF_ATTRIBUTE printf
-#define PG_VERSION "9.6.3"
-#define PG_VERSION_NUM 90603
-#define PG_VERSION_STR "PostgreSQL 9.6.3 on x86_64-apple-darwin15.6.0, compiled by Apple LLVM version 7.0.2 (clang-700.1.81), 64-bit"
-#define RELSEG_SIZE 131072
-#define SIZEOF_LONG 8
-#define SIZEOF_OFF_T 8
-#define SIZEOF_SIZE_T 8
-#define SIZEOF_VOID_P 8
-#define STDC_HEADERS 1
-#define STRERROR_R_INT 1
-#define USE_FLOAT4_BYVAL 1
-#define USE_FLOAT8_BYVAL 1
-#define USE_INTEGER_DATETIMES 1
-#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK 1
-#define USE_SYSV_SEMAPHORES 1
-#define USE_SYSV_SHARED_MEMORY 1
-#define WCSTOMBS_L_IN_XLOCALE 1
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#endif
-#define XLOG_BLCKSZ 8192
-#define XLOG_SEG_SIZE (16 * 1024 * 1024)
diff --git a/ports/libpq/pg_config.linux.h b/ports/libpq/pg_config.linux.h
deleted file mode 100644
index 99ebaa716..000000000
--- a/ports/libpq/pg_config.linux.h
+++ /dev/null
@@ -1,173 +0,0 @@
-#define ACCEPT_TYPE_ARG1 int
-#define ACCEPT_TYPE_ARG2 struct sockaddr *
-#define ACCEPT_TYPE_ARG3 socklen_t
-#define ACCEPT_TYPE_RETURN int
-#define ALIGNOF_DOUBLE 8
-#define ALIGNOF_INT 4
-#define ALIGNOF_LONG 8
-#define ALIGNOF_SHORT 2
-#define BLCKSZ 8192
-#define DEF_PGPORT 5432
-#define DEF_PGPORT_STR "5432"
-#define ENABLE_THREAD_SAFETY 1
-#define FLEXIBLE_ARRAY_MEMBER /**/
-#define FLOAT4PASSBYVAL true
-#define FLOAT8PASSBYVAL true
-#ifdef GETTIMEOFDAY_1ARG
-# define gettimeofday(a,b) gettimeofday(a)
-#endif
-#define HAVE_ATOMICS 1
-#define HAVE_CBRT 1
-#define HAVE_CRYPT 1
-#define HAVE_CRYPT_H 1
-#define HAVE_DECL_FDATASYNC 1
-#define HAVE_DECL_F_FULLFSYNC 0
-#define HAVE_DECL_POSIX_FADVISE 1
-#define HAVE_DECL_SNPRINTF 1
-#define HAVE_DECL_STRLCAT 0
-#define HAVE_DECL_STRLCPY 0
-#define HAVE_DECL_SYS_SIGLIST 1
-#define HAVE_DECL_VSNPRINTF 1
-#define HAVE_DLOPEN 1
-#define HAVE_FDATASYNC 1
-#define HAVE_FSEEKO 1
-#define HAVE_FUNCNAME__FUNC 1
-#define HAVE_GCC__ATOMIC_INT32_CAS 1
-#define HAVE_GCC__ATOMIC_INT64_CAS 1
-#define HAVE_GCC__SYNC_CHAR_TAS 1
-#define HAVE_GCC__SYNC_INT32_CAS 1
-#define HAVE_GCC__SYNC_INT32_TAS 1
-#define HAVE_GCC__SYNC_INT64_CAS 1
-#define HAVE_GETADDRINFO 1
-#define HAVE_GETHOSTBYNAME_R 1
-#define HAVE_GETIFADDRS 1
-#define HAVE_GETOPT 1
-#define HAVE_GETOPT_H 1
-#define HAVE_GETOPT_LONG 1
-#define HAVE_GETPWUID_R 1
-#define HAVE_GETRLIMIT 1
-#define HAVE_GETRUSAGE 1
-#define HAVE_IFADDRS_H 1
-#define HAVE_INET_ATON 1
-#define HAVE_INTPTR_T 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_INT_OPTERR 1
-#define HAVE_INT_TIMEZONE 1
-#define HAVE_IPV6 1
-#define HAVE_ISINF 1
-#define HAVE_LANGINFO_H 1
-#define HAVE_LIBM 1
-#define HAVE_LIBZ 1
-#define HAVE_LOCALE_T 1
-#define HAVE_LONG_INT_64 1
-#define HAVE_LONG_LONG_INT 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MEMORY_H 1
-#define HAVE_MKDTEMP 1
-#define HAVE_NETINET_IN_H 1
-#define HAVE_NETINET_TCP_H 1
-#define HAVE_NET_IF_H 1
-#define HAVE_POLL 1
-#define HAVE_POLL_H 1
-#define HAVE_POSIX_FADVISE 1
-#define HAVE_PTHREAD 1
-#define HAVE_PTHREAD_PRIO_INHERIT 1
-#define HAVE_PWD_H 1
-#define HAVE_RANDOM 1
-#define HAVE_READLINK 1
-#define HAVE_RINT 1
-#define HAVE_SETSID 1
-#define HAVE_SHM_OPEN 1
-#define HAVE_SNPRINTF 1
-#define HAVE_SPINLOCKS 1
-#define HAVE_SRANDOM 1
-#define HAVE_SSL_GET_CURRENT_COMPRESSION 1
-#define HAVE_STDINT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRERROR 1
-#define HAVE_STRERROR_R 1
-#define HAVE_STRINGS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRTOLL 1
-#define HAVE_STRTOULL 1
-#define HAVE_STRUCT_ADDRINFO 1
-#define HAVE_STRUCT_OPTION 1
-#define HAVE_STRUCT_SOCKADDR_STORAGE 1
-#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
-#define HAVE_STRUCT_TM_TM_ZONE 1
-#define HAVE_SYMLINK 1
-#define HAVE_SYNC_FILE_RANGE 1
-#define HAVE_SYSLOG 1
-#define HAVE_SYS_EPOLL_H 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_IPC_H 1
-#define HAVE_SYS_POLL_H 1
-#define HAVE_SYS_RESOURCE_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_SEM_H 1
-#define HAVE_SYS_SHM_H 1
-#define HAVE_SYS_SOCKET_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_SYS_UN_H 1
-#define HAVE_TERMIOS_H 1
-#define HAVE_TM_ZONE 1
-#define HAVE_TOWLOWER 1
-#define HAVE_TZNAME 1
-#define HAVE_UINTPTR_T 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UNIX_SOCKETS 1
-#define HAVE_UNSETENV 1
-#define HAVE_UNSIGNED_LONG_LONG_INT 1
-#define HAVE_UTIME 1
-#define HAVE_UTIMES 1
-#define HAVE_UTIME_H 1
-#define HAVE_VSNPRINTF 1
-#define HAVE_WCHAR_H 1
-#define HAVE_WCSTOMBS 1
-#define HAVE_WCTYPE_H 1
-#define HAVE__BUILTIN_BSWAP32 1
-#define HAVE__BUILTIN_BSWAP64 1
-#define HAVE__BUILTIN_CONSTANT_P 1
-#define HAVE__BUILTIN_TYPES_COMPATIBLE_P 1
-#define HAVE__BUILTIN_UNREACHABLE 1
-#define HAVE__GET_CPUID 1
-#define HAVE__STATIC_ASSERT 1
-#define HAVE__VA_ARGS 1
-#define INT64_MODIFIER "l"
-#define MAXIMUM_ALIGNOF 8
-#define MEMSET_LOOP_LIMIT 1024
-#define PACKAGE_BUGREPORT "pgsql-bugs@postgresql.org"
-#define PACKAGE_NAME "PostgreSQL"
-#define PACKAGE_STRING "PostgreSQL 9.6.3"
-#define PACKAGE_TARNAME "postgresql"
-#define PACKAGE_URL ""
-#define PACKAGE_VERSION "9.6.3"
-${DEFINE_PG_INT128_TYPE}
-#define PG_INT64_TYPE long int
-#define PG_KRB_SRVNAM "postgres"
-#define PG_MAJORVERSION "9.6"
-#define PG_PRINTF_ATTRIBUTE gnu_printf
-#define PG_VERSION "9.6.3"
-#define PG_VERSION_NUM 90603
-#define PG_VERSION_STR "PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.1-2ubuntu1~16.04) 5.4.1 20160904, 64-bit"
-#define RELSEG_SIZE 131072
-#define SIZEOF_LONG 8
-#define SIZEOF_OFF_T 8
-#define SIZEOF_SIZE_T 8
-#define SIZEOF_VOID_P 8
-#define STDC_HEADERS 1
-#define USE_FLOAT4_BYVAL 1
-#define USE_FLOAT8_BYVAL 1
-#define USE_INTEGER_DATETIMES 1
-#define USE_SSE42_CRC32C_WITH_RUNTIME_CHECK 1
-#define USE_SYSV_SEMAPHORES 1
-#define USE_SYSV_SHARED_MEMORY 1
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-# endif
-#endif
-#define XLOG_BLCKSZ 8192
-#define XLOG_SEG_SIZE (16 * 1024 * 1024)
diff --git a/ports/libpq/portfile.cmake b/ports/libpq/portfile.cmake
index 48e6ad71a..2ef9309a2 100644
--- a/ports/libpq/portfile.cmake
+++ b/ports/libpq/portfile.cmake
@@ -2,29 +2,283 @@ if(VCPKG_TARGET_IS_UWP)
message(FATAL_ERROR "${PORT} currently only supports being built for desktop")
endif()
+macro(feature_unsupported)
+ foreach(_feat ${ARGN})
+ if("${FEATURES}" MATCHES "${_feat}")
+ message(FATAL_ERROR "Feature ${_feat} not supported by configure script on the target platform")
+ endif()
+ endforeach()
+endmacro()
+
+macro(feature_not_implemented_yet)
+ foreach(_feat ${ARGN})
+ if("${FEATURES}" MATCHES "${_feat}")
+ message(FATAL_ERROR "Feature ${_feat} is not yet implement on the target platform")
+ endif()
+ endforeach()
+endmacro()
+
+if(VCPKG_TARGET_IS_WINDOWS)
+ # on windows libpq seems to only depend on openssl gss(kerberos) and ldap on the soruce site_name
+ # the configuration header depends on zlib, nls, ldap, uuid, xml, xlst,gss,openssl,icu
+ feature_unsupported(readline bonjour libedit kerberos bsd systemd llvm pam)
+ feature_not_implemented_yet(perl python tcl uuid)
+elseif(VCPKG_TARGET_IS_OSX)
+ feature_not_implemented_yet(readline libedit kerberos bsd systemd llvm pam perl python tcl uuid)
+else()
+ feature_not_implemented_yet(readline bonjour libedit kerberos bsd systemd llvm pam perl python tcl uuid)
+endif()
+
+## Download and extract sources
vcpkg_download_distfile(ARCHIVE
- URLS "https://ftp.postgresql.org/pub/source/v9.6.3/postgresql-9.6.3.tar.bz2"
- FILENAME "postgresql-9.6.3.tar.bz2"
- SHA512 97141972e154e6b0e756ee6a4e20f26e82022a9fd4c56305314a3a5567a79ece638e4ac3d513b46138737ae6bd27a098f30013a94767db151181aac9c01290a1
+ URLS "https://ftp.postgresql.org/pub/source/v12.0/postgresql-12.0.tar.bz2"
+ FILENAME "postgresql-12.0.tar.bz2"
+ SHA512 231a0b5c181c33cb01c3f39de1802319b79eceec6997935ab8605dea1f4583a52d0d16e5a70fcdeea313462f062503361d543433ee03d858ba332c72a665f696
)
+set(PATCHES
+ patches/windows/install.patch
+ patches/windows/win_bison_flex.patch
+ patches/windows/openssl_exe_path.patch
+ patches/windows/Solution.patch
+ patches/linux/configure.patch)
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
+ list(APPEND PATCHES patches/windows/MSBuildProject-static-lib.patch)
+ list(APPEND PATCHES patches/windows/Mkvcbuild-static-lib.patch)
+endif()
+if(VCPKG_CRT_LINKAGE STREQUAL static)
+ list(APPEND PATCHES patches/windows/MSBuildProject-static-crt.patch)
+endif()
+if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm")
+ list(APPEND PATCHES patches/windows/arm.patch)
+endif()
+if(NOT "${FEATURES}" MATCHES "client")
+ list(APPEND PATCHES patches/windows/minimize_install.patch)
+else()
+ set(HAS_TOOLS TRUE)
+endif()
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
+ PATCHES ${PATCHES}
+
)
+unset(buildenv_contents)
+# Get paths to required programs
+foreach(program_name BISON FLEX PERL)
+ # Need to rename win_bison and win_flex to just bison and flex
+ vcpkg_find_acquire_program(${program_name})
+ get_filename_component(${program_name}_EXE_PATH ${${program_name}} DIRECTORY)
+ vcpkg_add_to_path(PREPEND "${${program_name}_EXE_PATH}")
+ set(buildenv_contents "${buildenv_contents}\n\$ENV{PATH}=\$ENV{PATH} . ';${${program_name}_EXE_PATH}';")
+endforeach()
-file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+## Setup build types
-vcpkg_configure_cmake(
- SOURCE_PATH ${SOURCE_PATH}
- PREFER_NINJA
- OPTIONS
- "-DPORT_DIR=${CMAKE_CURRENT_LIST_DIR}"
- OPTIONS_DEBUG
- -DINSTALL_INCLUDES=OFF
-)
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE MATCHES "[Rr][Ee][Ll][Ee][Aa][Ss][Ee]")
+ set(_buildtype RELEASE)
+ set(_short rel)
+ list(APPEND port_config_list ${_buildtype})
+ set(INSTALL_PATH_SUFFIX_${_buildtype} "")
+ set(BUILDPATH_${_buildtype} "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${_short}")
+ set(PACKAGE_DIR_${_buildtype} ${CURRENT_PACKAGES_DIR})
+ unset(_short)
+ unset(_buildtype)
+endif()
+if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
+ set(_buildtype DEBUG)
+ set(_short dbg)
+ list(APPEND port_config_list ${_buildtype})
+ set(INSTALL_PATH_SUFFIX_${_buildtype} "/debug")
+ set(BUILDPATH_${_buildtype} "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${_short}")
+ set(PACKAGE_DIR_${_buildtype} ${CURRENT_PACKAGES_DIR}${INSTALL_PATH_SUFFIX_${_buildtype}})
+ unset(_short)
+ unset(_buildtype)
+endif()
+
+file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/${PORT})
+
+## Do the build
+if(VCPKG_TARGET_IS_WINDOWS)
+ file(GLOB SOURCE_FILES ${SOURCE_PATH}/*)
+ foreach(_buildtype ${port_config_list})
+ # Copy libpq sources.
+ message(STATUS "Copying libpq source files to ${BUILDPATH_${_buildtype}}...")
+ foreach(SOURCE_FILE ${SOURCE_FILES})
+ file(COPY ${SOURCE_FILE} DESTINATION "${BUILDPATH_${_buildtype}}")
+ endforeach()
+ message(STATUS "Copying libpq source files... done")
+
+ vcpkg_apply_patches(
+ SOURCE_PATH "${BUILDPATH_${_buildtype}}"
+ PATCHES patches/windows/Solution_${_buildtype}.patch
+ )
+ message(STATUS "Patches applied!")
+ file(COPY "${CURRENT_PORT_DIR}/config.pl" DESTINATION "${BUILDPATH_${_buildtype}}/src/tools/msvc")
+ set(CONFIG_FILE "${BUILDPATH_${_buildtype}}/src/tools/msvc/config.pl")
+ file(READ "${CONFIG_FILE}" _contents)
+
+ ## ldap => undef, # --with-ldap ##done
+ ## extraver => undef, # --with-extra-version=<string>
+ ## gss => undef, # --with-gssapi=<path>
+ ## icu => undef, # --with-icu=<path> ##done
+ ## nls => undef, # --enable-nls=<path> ##done
+ ## tap_tests => undef, # --enable-tap-tests
+ ## tcl => undef, # --with-tcl=<path>
+ ## perl => undef, # --with-perl
+ ## python => undef, # --with-python=<path>
+ ## openssl => undef, # --with-openssl=<path> ##done
+ ## uuid => undef, # --with-ossp-uuid
+ ## xml => undef, # --with-libxml=<path> ##done
+ ## xslt => undef, # --with-libxslt=<path> ##done
+ ## iconv => undef, # (not in configure, path to iconv) ##done (needed by xml)
+ ## zlib => undef # --with-zlib=<path> ##done
+
+ ## Setup external dependencies
+ ##"-DFEATURES=core;openssl;zlib" "-DALL_FEATURES=openssl;zlib;readline;libedit;perl;python;tcl;nls;kerberos;systemd;ldap;bsd;pam;llvm;icu;bonjour;uuid;xml;xslt;"
+ if("${FEATURES}" MATCHES "ldap")
+ string(REPLACE "ldap => undef" "ldap => 1" _contents "${_contents}")
+ endif()
+ if("${FEATURES}" MATCHES "icu")
+ string(REPLACE "icu => undef" "icu => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ endif()
+ if("${FEATURES}" MATCHES "nls")
+ string(REPLACE "nls => undef" "nls => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ endif()
+ if("${FEATURES}" MATCHES "openssl")
+ set(buildenv_contents "${buildenv_contents}\n\$ENV{PATH}=\$ENV{PATH} . ';${CURRENT_INSTALLED_DIR}/tools/openssl';")
+ #set(_contents "${_contents}\n\$ENV{PATH}=\$ENV{PATH} . ';${CURRENT_INSTALLED_DIR}/tools/openssl';")
+ string(REPLACE "openssl => undef" "openssl => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ endif()
+
+ if("${FEATURES}" MATCHES "xml")
+ string(REPLACE "xml => undef" "xml => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ string(REPLACE "iconv => undef" "iconv => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ endif()
+
+ if("${FEATURES}" MATCHES "xslt")
+ string(REPLACE "xslt => undef" "xslt => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ endif()
+
+ if("${FEATURES}" MATCHES "zlib")
+ string(REPLACE "zlib => undef" "zlib => \"${CURRENT_INSTALLED_DIR}\"" _contents "${_contents}")
+ endif()
+
+ file(WRITE "${CONFIG_FILE}" "${_contents}")
+ file(WRITE "${BUILDPATH_${_buildtype}}/src/tools/msvc/buildenv.pl" "${buildenv_contents}")
+ vcpkg_get_windows_sdk(VCPKG_TARGET_PLATFORM_VERSION)
+ set(ENV{MSBFLAGS} "/p:PlatformToolset=${VCPKG_PLATFORM_TOOLSET}
+ /p:VCPkgLocalAppDataDisabled=true
+ /p:UseIntelMKL=No
+ /p:WindowsTargetPlatformVersion=${VCPKG_TARGET_PLATFORM_VERSION}
+ /m
+ /p:ForceImportBeforeCppTargets=${SCRIPTS}/buildsystems/msbuild/vcpkg.targets
+ /p:VcpkgTriplet=${TARGET_TRIPLET}"
+ )
+ if(HAS_TOOLS)
+ if(VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
+ set(ENV{MSBFLAGS} "$ENV{MSBFLAGS} /p:Platform=Win32")
+ endif()
+ message(STATUS "Building libpq ${TARGET_TRIPLET}-${_buildtype}...")
+ vcpkg_execute_required_process(
+ COMMAND ${PERL} build.pl ${_buildtype}
+ WORKING_DIRECTORY ${BUILDPATH_${_buildtype}}/src/tools/msvc
+ LOGNAME build-${TARGET_TRIPLET}-${_buildtype}
+ )
+ message(STATUS "Building libpq ${TARGET_TRIPLET}-${_buildtype}... done")
+ else()
+ set(build_libs libpq libecpg_compat)
+ foreach(build_lib ${build_libs})
+ message(STATUS "Building ${build_lib} ${TARGET_TRIPLET}-${_buildtype}...")
+ vcpkg_execute_required_process(
+ COMMAND ${PERL} build.pl ${_buildtype} ${build_lib}
+ WORKING_DIRECTORY ${BUILDPATH_${_buildtype}}/src/tools/msvc
+ LOGNAME build-${build_lib}-${TARGET_TRIPLET}-${_buildtype}
+ )
+ message(STATUS "Building ${build_lib} ${TARGET_TRIPLET}-${_buildtype}... done")
+ endforeach()
+ endif()
+
+ message(STATUS "Installing libpq ${TARGET_TRIPLET}-${_buildtype}...")
+ vcpkg_execute_required_process(
+ COMMAND ${PERL} install.pl ${CURRENT_PACKAGES_DIR}${INSTALL_PATH_SUFFIX_${_buildtype}} client
+ WORKING_DIRECTORY ${BUILDPATH_${_buildtype}}/src/tools/msvc
+ LOGNAME install-${TARGET_TRIPLET}-${_buildtype}
+ )
+ message(STATUS "Installing libpq ${TARGET_TRIPLET}-${_buildtype}... done")
+ endforeach()
+
+
+ message(STATUS "Cleanup libpq ${TARGET_TRIPLET}...")
+ #Cleanup
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/doc)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/tools)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/symbols)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/symbols)
+
+ if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
+ endif()
+
+ if(NOT HAS_TOOLS)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/tools)
+ else()
+ vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
+ endif()
+ #file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/${PORT}/)
+ #vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT})
+ message(STATUS "Cleanup libpq ${TARGET_TRIPLET}... - done")
+else()
+ if("${FEATURES}" MATCHES "openssl")
+ list(APPEND BUILD_OPTS --with-openssl)
+ endif()
+ if(NOT "${FEATURES}" MATCHES "zlib")
+ list(APPEND BUILD_OPTS --without-zlib)
+ endif()
+ if(NOT "${FEATURES}" MATCHES "readline")
+ list(APPEND BUILD_OPTS --without-readline)
+ endif()
+ vcpkg_configure_make(
+ SOURCE_PATH ${SOURCE_PATH}
+ OPTIONS
+ ${BUILD_OPTS}
+ --with-includes=${CURRENT_INSTALLED_DIR}/include
+ OPTIONS_RELEASE
+ --exec-prefix=${CURRENT_PACKAGES_DIR}/tools/${PORT}
+ --datarootdir=${CURRENT_PACKAGES_DIR}/share/${PORT}
+ --with-libraries=${CURRENT_INSTALLED_DIR}/lib
+ OPTIONS_DEBUG
+ --exec-prefix=${CURRENT_PACKAGES_DIR}/debug/tools/${PORT}
+ --datarootdir=${CURRENT_PACKAGES_DIR}/debug/share/${PORT}
+ --with-libraries=${CURRENT_INSTALLED_DIR}/debug/lib
+ --enable-debug
+ )
+
+ vcpkg_install_make()
+ # instead?
+ # make -C src/include install
+ # make -C src/interfaces install
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
+ if(NOT HAS_TOOLS)
+ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
+ else()
+ file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/${PORT})
+ file(RENAME ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/tools/${PORT})
+ endif()
+endif()
+#vcpkg_copy_pdbs()
-vcpkg_install_cmake()
-vcpkg_copy_pdbs()
+#if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/libpq.lib")
+ #RENAME debug library due to CMake. In general that is a bad idea but it will have consquences for the generated cmake targets
+ # of other ports if not renamed. Maybe a vcpkg_cmake_wrapper is required here to correct the target information if the rename is removed?
+# file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/libpq.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/libpqd.lib")
+#endif()
+file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/postgresql)
+file(INSTALL ${CURRENT_PORT_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/postgresql)
file(INSTALL ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
diff --git a/ports/libpq/vcpkg-cmake-wrapper.cmake b/ports/libpq/vcpkg-cmake-wrapper.cmake
new file mode 100644
index 000000000..4ce0f8579
--- /dev/null
+++ b/ports/libpq/vcpkg-cmake-wrapper.cmake
@@ -0,0 +1,8 @@
+# Give the CMake module a little bit of help to find the debug libraries
+find_library(PostgreSQL_LIBRARY_DEBUG
+NAMES pq
+PATHS
+ "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib"
+NO_DEFAULT_PATH
+)
+_find_package(${ARGS}) \ No newline at end of file