From a22b6c26cb0a52ba4e06947a60ddddee3770fb05 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 19 Feb 2026 15:41:57 -0500
Subject: [PATCH v7 7/8] 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 'soversion' 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 d578faefe1c..0efe8a38230 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -35,7 +35,7 @@ ecpg_compat_so = shared_library('libecpg_compat',
   c_args: ecpg_compat_c_args,
   dependencies: [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 81e92151945..cb7288f2ee6 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -46,7 +46,7 @@ ecpglib_so = shared_library('libecpg',
   c_pch: pch_postgres_fe_h,
   dependencies: [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 241fa95e559..5b5205ed095 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -41,7 +41,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes',
   c_pch: pch_postgres_fe_h,
   dependencies: [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 c6d361e7f61..b0ae72167a1 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -77,7 +77,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: [frontend_shlib_code, libpq_deps],
   link_depends: export_file,
-- 
2.43.7

