From e733e72a0091579594457a664f6182a3f593e091 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sun, 15 Feb 2026 16:19:41 -0500
Subject: [PATCH v6 7/7] Fix inconsistencies in the set of installed files.

Install postgres.imp in pkglibdir, where the Makefiles have always
put it.  Also install mkldexport.sh where the Makefiles put it.
These seem to have been pre-existing bugs in the meson logic for AIX.
It's not really surprising that we never noticed given that we
desupported AIX in the same version where meson support was added.

Also suppress bogus installed symlinks for client shared libraries.
As things stand, "meson install" installs libpgtypes.a, plus
a useless symlink libpgtypes.so -> libpgtypes.so.3, and another
useless symlink libpgtypes.so.3 -> libpgtypes.so.3.19;
similarly for the other ecpg libraries and libpq.  Arguably
this is a bug in meson's shared_library function, but it seems
we can work around it by setting 'version' to empty in the
shared_library calls.
---
 src/backend/meson.build                    | 5 ++++-
 src/interfaces/ecpg/compatlib/meson.build  | 2 +-
 src/interfaces/ecpg/ecpglib/meson.build    | 2 +-
 src/interfaces/ecpg/pgtypeslib/meson.build | 2 +-
 src/interfaces/libpq/meson.build           | 2 +-
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/backend/meson.build b/src/backend/meson.build
index 130144a7d5b..fec9f1d03b4 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -101,12 +101,15 @@ elif host_system == 'aix'
     output: 'postgres.imp',
     capture: true,
     install: true,
-    install_dir: dir_lib,
+    install_dir: dir_lib_pkg,
     build_by_default: false,
   )
   # -Wl,-bE:exportfile indicates these symbols are exported by postgres binary
   backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path())
   backend_link_depends += postgres_imp
+  install_data(
+	'port/aix/mkldexport.sh',
+	install_dir: dir_pgxs / 'src/backend/port/aix')
 endif
 
 backend_input = []
diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build
index 94dcc67c03c..fc6fc434e2e 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -34,7 +34,7 @@ ecpg_compat_so = shared_library('libecpg_compat',
   c_args: ecpg_compat_c_args,
   dependencies: [dep_shared_lib, frontend_shlib_code, thread_dep],
   link_with: [ecpglib_so, ecpg_pgtypes_so],
-  soversion: host_system != 'windows' ? '3' : '',
+  soversion: host_system not in ['aix', 'windows'] ? '3' : '',
   darwin_versions: ['3', '3.' + pg_version_major.to_string()],
   version: '3.' + pg_version_major.to_string(),
   link_args: export_fmt.format(export_file.full_path()),
diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build
index a81d772aa69..04ba2c6e2de 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -45,7 +45,7 @@ ecpglib_so = shared_library('libecpg',
   c_pch: pch_postgres_fe_h,
   dependencies: [dep_shared_lib, frontend_shlib_code, libpq, thread_dep],
   link_with: ecpg_pgtypes_so,
-  soversion: host_system != 'windows' ? '6' : '',
+  soversion: host_system not in ['aix', 'windows'] ? '6' : '',
   darwin_versions: ['6', '6.' + pg_version_major.to_string()],
   version: '6.' + pg_version_major.to_string(),
   link_args: export_fmt.format(export_file.full_path()),
diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build
index 897a8febc76..175691d1321 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -40,7 +40,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes',
   c_pch: pch_postgres_fe_h,
   dependencies: [dep_shared_lib, frontend_shlib_code],
   version: '3.' + pg_version_major.to_string(),
-  soversion: host_system != 'windows' ? '3' : '',
+  soversion: host_system not in ['aix', 'windows'] ? '3' : '',
   darwin_versions: ['3', '3.' + pg_version_major.to_string()],
   link_args: export_fmt.format(export_file.full_path()),
   link_depends: export_file,
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index ea98596b936..d3dfa0328e1 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -73,7 +73,7 @@ libpq_so = shared_library('libpq',
   c_args: libpq_c_args + libpq_so_c_args,
   c_pch: pch_postgres_fe_h,
   version: '5.' + pg_version_major.to_string(),
-  soversion: host_system != 'windows' ? '5' : '',
+  soversion: host_system not in ['aix', 'windows'] ? '5' : '',
   darwin_versions: ['5', '5.' + pg_version_major.to_string()],
   dependencies: [dep_shared_lib, frontend_shlib_code, libpq_deps],
   link_depends: export_file,
-- 
2.43.7

