postgresql: build with meson

This commit is contained in:
مهدي شينون (Mehdi Chinoune)
2023-09-15 07:08:57 +01:00
committed by مهدي شينون (Mehdi Chinoune)
parent 93776d1476
commit ffff095448
7 changed files with 46 additions and 310 deletions

View File

@@ -4,7 +4,7 @@ _realname=postgresql
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=17.0
pkgrel=1
pkgrel=2
pkgdesc="Libraries for use with PostgreSQL (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
@@ -16,42 +16,34 @@ msys2_references=(
)
license=('spdx:PostgreSQL')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-autotools"
"${MINGW_PACKAGE_PREFIX}-meson"
"${MINGW_PACKAGE_PREFIX}-pkgconf"
"${MINGW_PACKAGE_PREFIX}-gettext-tools"
"${MINGW_PACKAGE_PREFIX}-libxslt"
#"${MINGW_PACKAGE_PREFIX}-llvm"
"${MINGW_PACKAGE_PREFIX}-perl"
"${MINGW_PACKAGE_PREFIX}-python"
"${MINGW_PACKAGE_PREFIX}-tcl")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-gettext-runtime"
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime"
"${MINGW_PACKAGE_PREFIX}-icu"
"${MINGW_PACKAGE_PREFIX}-libxml2"
"${MINGW_PACKAGE_PREFIX}-lz4"
"${MINGW_PACKAGE_PREFIX}-openssl"
#"${MINGW_PACKAGE_PREFIX}-readline"
"${MINGW_PACKAGE_PREFIX}-readline"
#"${MINGW_PACKAGE_PREFIX}-wineditline"
"${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-zstd"
"winpty")
optdepends=("${MINGW_PACKAGE_PREFIX}-python: for PL/Python support"
optdepends=("${MINGW_PACKAGE_PREFIX}-libxslt: XML plugin"
"${MINGW_PACKAGE_PREFIX}-perl: for PL/Perl support"
"${MINGW_PACKAGE_PREFIX}-python: for PL/Python support"
"${MINGW_PACKAGE_PREFIX}-tcl: for PL/Tcl support")
source=("https://ftp.postgresql.org/pub/source/v${pkgver}/postgresql-${pkgver}.tar.bz2"
postgresql-12.0-mingw-link.patch
postgresql-9.5.1-pl-perl.patch
postgresql-9.5.1-pl-python.patch
postgresql-9.4.1-pl-tcl.patch
postgresql-9.4.1-mingw-enable-readline.patch
postgresql-13.1-disable-wsa-invalid-event-static-assert.patch
postgresql-13.1-pgevent-def.patch
postgresql-14.0-use-mingw-setjmp-on-ucrt.patch
postgresql-17.0-fix-build-on-mingw64.patch)
sha256sums=('7e276131c0fdd6b62588dbad9b3bb24b8c3498d5009328dba59af16e819109de'
'54958a6116e401d13b2394c7b428a039d8a185bf2aaedf7b89e3ee203dc8f324'
'99e6c8b9d58a9615c7bb1e7471b8e9c074add7bffc7d2cf742bafa38e9654e1f'
'6354cebd87b943180e7976b641365617c10dbd32c685b3c6c637bc1b853788f0'
'8d8fda45b654d89a5f62cdaec1e8319b721dbc20613dfd7201be7b8f5383bb4e'
'cd52d56833c60afdce98d91eece73c11978762671e36be7bd9c31a1ea0a0282d'
'72c14a78eeafdd3c9a13c3e124b1941b5da090488c7bd73f08b3cd78bacd07d5'
'5941c74c6ab66d42d6ac6e7d5da358d44e479fd519bd4e025f08eba06bf30752'
'fe336eac7892b23988189be0178efc95449d8d08493db83754058f5f37bb8ea9'
'949406ec785dc4c062e9b94c49927060595b63d72fe35c7e86f2b67b3e91044d')
@@ -65,90 +57,61 @@ apply_patch_with_msg() {
}
prepare() {
cd ${srcdir}/postgresql-${pkgver}
cd ${srcdir}/${_realname}-${pkgver}
apply_patch_with_msg \
postgresql-12.0-mingw-link.patch \
postgresql-9.5.1-pl-perl.patch \
postgresql-9.5.1-pl-python.patch \
postgresql-9.4.1-pl-tcl.patch \
postgresql-13.1-disable-wsa-invalid-event-static-assert.patch \
postgresql-13.1-pgevent-def.patch \
postgresql-14.0-use-mingw-setjmp-on-ucrt.patch \
postgresql-17.0-fix-build-on-mingw64.patch
#patch -p1 -i ${srcdir}/postgresql-9.4.1-mingw-enable-readline.patch
autoreconf -fiv
}
build() {
mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"
mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}
export PYTHON=${MINGW_PREFIX}/bin/python
declare -a _extra_config
if check_option "debug" "n"; then
_extra_config+=("--buildtype=release")
else
_extra_config+=("--buildtype=debug")
fi
../postgresql-${pkgver}/configure \
MSYS2_ARG_CONV_EXCL="--prefix=" \
${MINGW_PREFIX}/bin/meson setup \
--prefix=${MINGW_PREFIX} \
--enable-thread-safety \
--enable-integer-datetimes \
--enable-nls \
--disable-rpath \
--with-ldap \
--with-libxml \
--with-libxslt \
--with-lz4 \
--with-ssl=openssl \
--with-python \
--with-zstd \
--without-perl \
--with-tcl \
--with-tclconfig=${MINGW_PREFIX}/lib
#--with-libedit-preferred
--default-library=shared \
-Drpath=false \
-Dicu=enabled \
-Dldap=enabled \
-Dlibxml=enabled \
-Dlibxslt=enabled \
-Dllvm=disabled \
-Dlz4=enabled \
-Dnls=enabled \
-Dplperl=enabled \
-Dplpython=enabled \
-Dpltcl=enabled \
-Dreadline=enabled \
-Dssl=openssl \
-Dzlib=enabled \
-Dzstd=enabled \
"${_extra_config[@]}" \
../${_realname}-${pkgver}
#for dir in src/interfaces src/bin/pg_config src/bin/psql src/bin/pg_dump; do
# make -C ${dir}
#done
make
${MINGW_PREFIX}/bin/meson compile
}
check() {
cd "${srcdir}/build-${MSYSTEM}"
make check
cd "${srcdir}"/build-${MSYSTEM}
${MINGW_PREFIX}/bin/meson test
}
package() {
cd "${srcdir}/build-${MSYSTEM}"
mkdir -p "${pkgdir}${MINGW_PREFIX}/"{bin,include,lib}
cd "${srcdir}"/build-${MSYSTEM}
make DESTDIR="${pkgdir}" install
# install libs
DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install
#for dir in src/interfaces src/bin/pg_config src/bin/psql src/bin/pg_dump; do
# make -C ${dir} DESTDIR="${pkgdir}" install
#done
# Move dll's to bin directory
mv "${pkgdir}${MINGW_PREFIX}/lib/"*.dll "${pkgdir}${MINGW_PREFIX}/bin/"
# Rename the .a files to .dll.a as they're actually import libraries and not static libraries
#for implib in "${pkgdir}${MINGW_PREFIX}/lib/"*.a; do
# mv $implib ${implib/.a/.dll.a}
#done
# these headers are needed by the not-so-public headers of the interfaces
mkdir -p "${pkgdir}${MINGW_PREFIX}"/include/{libpq,postgresql/internal/libpq}
install -m644 ${srcdir}/postgresql-${pkgver}/src/include/c.h "${pkgdir}${MINGW_PREFIX}/include/postgresql/internal/"
install -m644 ${srcdir}/postgresql-${pkgver}/src/include/port.h "${pkgdir}${MINGW_PREFIX}/include/postgresql/internal/"
install -m644 ${srcdir}/postgresql-${pkgver}/src/include/postgres_fe.h "${pkgdir}${MINGW_PREFIX}/include/postgresql/internal/"
install -m644 ${srcdir}/postgresql-${pkgver}/src/include/libpq/pqcomm.h "${pkgdir}${MINGW_PREFIX}/include/postgresql/internal/libpq/"
# these headers are needed by the public headers of the interfaces
# install -m644 pg_config.h "${pkgdir}${MINGW_PREFIX}/include/"
# install -m644 pg_config_os.h "${pkgdir}${MINGW_PREFIX}/include/"
# install -m644 pg_config_ext.h "${pkgdir}${MINGW_PREFIX}/include/"
# cd "${srcdir}/postgresql-$pkgver/src/include"
# install -m644 postgres_ext.h "${pkgdir}${MINGW_PREFIX}/include/"
# install -m644 libpq/libpq-fs.h "${pkgdir}${MINGW_PREFIX}/include/libpq/"
# install -m644 pg_config_manual.h "${pkgdir}${MINGW_PREFIX}/include/"
# Remove unneeded import libraries for plugins/modules
rm -f "${pkgdir}"${MINGW_PREFIX}/lib/postgresql/*.dll.a
# Use winpty-git script to invoke utilities. Please don't move this into a patch as
# hopefully one day we won't need this hack.

View File

@@ -1,54 +0,0 @@
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -85,7 +85,7 @@
# Naming convention for dynamically loadable modules
shlib = $(NAME)$(DLSUFFIX)
endif
-stlib = lib$(NAME).a
+stlib = lib$(NAME).dll.a
ifndef soname
# additional flags for backend modules
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -87,11 +87,11 @@
LIBS += -lsecur32
postgres: $(OBJS) $(WIN32RES)
- $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@$(X)
+ $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.dll.a $(LIBS) -o $@$(X)
# libpostgres.a is actually built in the preceding rule, but we need this to
# ensure it's newer than postgres; see notes in src/backend/parser/Makefile
-libpostgres.a: postgres
+libpostgres.dll.a: postgres
touch $@
endif # win32
@@ -196,7 +196,7 @@
endif
ifeq ($(PORTNAME), win32)
ifeq ($(MAKE_DLL), true)
- $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
+ $(INSTALL_DATA) libpostgres.dll.a '$(DESTDIR)$(libdir)/libpostgres.dll.a'
endif
endif
$(MAKE) -C catalog install-data
@@ -255,7 +255,7 @@
endif
ifeq ($(PORTNAME), win32)
ifeq ($(MAKE_DLL), true)
- rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
+ rm -f '$(DESTDIR)$(libdir)/libpostgres.dll.a'
endif
endif
$(MAKE) -C catalog uninstall-data
@@ -277,7 +277,7 @@
rm -f postgres.dll libpostgres.a
endif
ifeq ($(PORTNAME), win32)
- rm -f postgres.dll libpostgres.a $(WIN32RES)
+ rm -f postgres.dll libpostgres.dll.a $(WIN32RES)
endif
distclean: clean

View File

@@ -1,12 +0,0 @@
--- a/src/bin/pgevent/Makefile
+++ b/src/bin/pgevent/Makefile
@@ -30,6 +30,9 @@
include $(top_srcdir)/src/Makefile.shlib
+libpgeventdll.def: pgevent.def
+ cp -f $< $@
+
pgmsgevent.o: pgmsgevent.rc
$(WINDRES) $< -o $@ --include-dir=$(top_builddir)/src/include --include-dir=$(top_srcdir)/src/include --include-dir=$(srcdir) --include-dir=.

View File

@@ -1,18 +0,0 @@
--- a/configure.ac
+++ b/configure.ac
@@ -938,15 +938,6 @@
#
PGAC_ARG_BOOL(with, readline, yes,
[do not use GNU Readline nor BSD Libedit for editing])
-# readline on MinGW has problems with backslashes in psql and other bugs.
-# This is particularly a problem with non-US code pages.
-# Therefore disable its use until we understand the cause. 2004-07-20
-if test "$PORTNAME" = "win32"; then
- if test "$with_readline" = yes; then
- AC_MSG_WARN([*** Readline does not work on MinGW --- disabling])
- with_readline=no
- fi
-fi
AC_SUBST(with_readline)

View File

@@ -1,45 +0,0 @@
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -13,10 +13,7 @@
override CPPFLAGS := -I. -I$(srcdir) $(TCL_INCLUDE_SPEC) $(CPPFLAGS)
-# On Windows, we don't link directly with the Tcl library; see below
-ifneq ($(PORTNAME), win32)
SHLIB_LINK = $(TCL_LIB_SPEC) $(TCL_LIBS)
-endif
PGFILEDESC = "PL/Tcl - procedural language"
@@ -32,23 +29,6 @@
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=pltcl
REGRESS = pltcl_setup pltcl_queries pltcl_trigger pltcl_call pltcl_start_proc pltcl_subxact pltcl_unicode pltcl_transaction
-# Tcl on win32 ships with import libraries only for Microsoft Visual C++,
-# which are not compatible with mingw gcc. Therefore we need to build a
-# new import library to link with.
-ifeq ($(PORTNAME), win32)
-
-tclwithver = $(subst -l,,$(filter -l%, $(TCL_LIB_SPEC)))
-TCLDLL = $(dir $(TCLSH))/$(tclwithver).dll
-
-OBJS += lib$(tclwithver).a
-
-lib$(tclwithver).a: $(tclwithver).def
- dlltool --dllname $(tclwithver).dll --def $(tclwithver).def --output-lib lib$(tclwithver).a
-
-$(tclwithver).def: $(TCLDLL)
- gendef - $^ > $@
-
-endif # win32
include $(top_srcdir)/src/Makefile.shlib
@@ -92,7 +72,4 @@
clean distclean: clean-lib
rm -f $(OBJS)
rm -rf $(pg_regress_clean_files)
-ifeq ($(PORTNAME), win32)
- rm -f $(tclwithver).def
-endif
rm -f pltclerrcodes.h

View File

@@ -1,37 +0,0 @@
--- postgresql-9.5.1/src/pl/plperl/GNUmakefile.orig 2015-02-10 21:34:31.287600000 +0300
+++ postgresql-9.5.1/src/pl/plperl/GNUmakefile 2015-02-10 21:35:06.732800000 +0300
@@ -36,27 +36,6 @@
PERLCHUNKS = plc_perlboot.pl plc_trusted.pl
-# Perl on win32 ships with import libraries only for Microsoft Visual C++,
-# which are not compatible with mingw gcc. Therefore we need to build a
-# new import library to link with.
-ifeq ($(PORTNAME), win32)
-
-perlwithver := $(subst -l,,$(filter -l%, $(perl_embed_ldflags)))
-PERLDLL := $(dir $(subst ',,$(PERL)))$(perlwithver).dll
-# we no longer want to include the original -l spec in SHLIB_LINK
-override perl_embed_ldflags :=
-
-OBJS += lib$(perlwithver).a
-
-lib$(perlwithver).a: $(perlwithver).def
- dlltool --dllname $(perlwithver).dll --def $(perlwithver).def --output-lib lib$(perlwithver).a
-
-$(perlwithver).def: $(PERLDLL)
- gendef - $^ > $@
-
-endif # win32
-
-
SHLIB_LINK = $(perl_embed_ldflags)
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-extension=plperl --load-extension=plperlu
@@ -117,6 +117,3 @@
clean distclean maintainer-clean: clean-lib
rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
rm -rf $(pg_regress_clean_files)
-ifeq ($(PORTNAME), win32)
- rm -f $(perlwithver).def
-endif

View File

@@ -1,61 +0,0 @@
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -5,11 +5,6 @@
include $(top_builddir)/src/Makefile.global
-# On Windows we have to remove -lpython from the link since we are
-# building our own
-ifeq ($(PORTNAME), win32)
-override python_libspec =
-endif
override CPPFLAGS := -I. -I$(srcdir) $(python_includespec) $(CPPFLAGS)
@@ -53,25 +48,6 @@
plpy_typeio.h \
plpy_util.h
-# Python on win32 ships with import libraries only for Microsoft Visual C++,
-# which are not compatible with mingw gcc. Therefore we need to build a
-# new import library to link with.
-ifeq ($(PORTNAME), win32)
-
-pytverstr=$(subst .,,${python_version})
-PYTHONDLL=$(subst \,/,$(WINDIR))/system32/python${pytverstr}.dll
-
-OBJS += libpython${pytverstr}.a
-
-libpython${pytverstr}.a: python${pytverstr}.def
- dlltool --dllname python${pytverstr}.dll --def python${pytverstr}.def --output-lib libpython${pytverstr}.a
-
-python${pytverstr}.def:
- gendef - $(PYTHONDLL) > $@
-
-endif # win32
-
-
SHLIB_LINK = $(python_libspec) $(python_additional_libs) $(filter -lintl,$(LIBS))
REGRESS_OPTS = --dbname=$(PL_TESTDB)
@@ -140,9 +116,6 @@
clean distclean: clean-lib
rm -f $(OBJS)
rm -rf $(pg_regress_clean_files)
-ifeq ($(PORTNAME), win32)
- rm -f python${pytverstr}.def
-endif
rm -f spiexceptions.h
--- a/config/python.m4
+++ b/config/python.m4
@@ -96,7 +96,7 @@
python_ldlibrary=`${PYTHON} -c "import sysconfig; print(' '.join(filter(None,sysconfig.get_config_vars('LDLIBRARY'))))"`
# If LDLIBRARY exists and has a shlib extension, use it verbatim.
-ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
+ldlibrary=`echo "${python_ldlibrary}" | sed -e 's/\.so$//' -e 's/\.dll$//' -e 's/\.dll.a$//' -e 's/\.dylib$//' -e 's/\.sl$//'`
if test -e "${python_libdir}/${python_ldlibrary}" -a x"${python_ldlibrary}" != x"${ldlibrary}"
then
ldlibrary=`echo "${ldlibrary}" | sed "s/^lib//"`