On 20.01.26 18:03, Andres Freund wrote:
  ###############################################################
@@ -3499,18 +3513,20 @@ endif
  installed_targets = [
    backend_targets,
    bin_targets,
-  libpq_st,
    pl_targets,
    contrib_targets,
    nls_mo_targets,
    ecpg_targets,
  ]
+if dep_static_lib.found()
+  installed_targets += [libpq_st]
+endif

Wonder if we ought to define installed_targets = [] earlier and allow
different meson.build files to add themselves, instead of putting knowledge
like this into a central spot.

Right. See attached patch 0001. This introduces a variable libpq_targets and populates it in the subdirectories. This moves the knowledge away from the top-level meson.build.

Separately, perhaps it'd be mildly nicer to have a boolean for static libs
instead of using .found() everywhere.

Yeah, after playing with this a bit more, I'm not sure sure this disabler trick is really that good. The idea would have been that you just need to add the disabler to the dependencies and everything else will magically work. But the reason that you need stuff like

+if dep_static_lib.found()
+  installed_targets += [libpq_st]
+endif

is that the disabler sneaks up into other variables and dependencies and has weird effects. For example, if you remove "if" around this and similar lines, then "meson test" breaks in highly confusing ways (probably because tmp_install depends on installed_targets).

So I think, since we have to have these conditionals, we might as well put them around the whole static_library() call. And then we can use a straightforward Boolean variable, like you suggest. See attached patch 0003 (which is on top of 0002, so it would make more sense to view the diff 0001..0003).

This is also more robust because you get explicit errors for example if you use libpq_st or libpq_so when they are disabled, instead of sometimes silently doing nothing.

From 5b1f43d9057b7ce350949c6a66d982fb53d0e383 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 26 Jan 2026 16:47:37 +0100
Subject: [PATCH v2 1/3] meson: Refactor libpq targets variables

---
 meson.build                            | 12 +++---------
 src/interfaces/libpq-oauth/meson.build |  2 ++
 src/interfaces/libpq/meson.build       |  2 ++
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/meson.build b/meson.build
index df907b62da3..824cebbade4 100644
--- a/meson.build
+++ b/meson.build
@@ -3102,6 +3102,7 @@ add_project_link_arguments(ldflags, language: ['c', 
'cpp'])
 # list of targets for various alias targets
 backend_targets = []
 bin_targets = []
+libpq_targets = []
 pl_targets = []
 contrib_targets = []
 testprep_targets = []
@@ -3528,20 +3529,13 @@ endif
 installed_targets = [
   backend_targets,
   bin_targets,
-  libpq_st,
+  libpq_targets,
   pl_targets,
   contrib_targets,
   nls_mo_targets,
   ecpg_targets,
 ]
 
-if oauth_flow_supported
-  installed_targets += [
-    libpq_oauth_so,
-    libpq_oauth_st,
-  ]
-endif
-
 # all targets that require building code
 all_built = [
   installed_targets,
@@ -3878,7 +3872,7 @@ add_test_setup('running',
 ###############################################################
 
 alias_target('backend', backend_targets)
-alias_target('bin', bin_targets + [libpq_st])
+alias_target('bin', bin_targets + libpq_targets)
 alias_target('pl', pl_targets)
 alias_target('contrib', contrib_targets)
 alias_target('testprep', testprep_targets)
diff --git a/src/interfaces/libpq-oauth/meson.build 
b/src/interfaces/libpq-oauth/meson.build
index d8a0c04095a..e573d36f20e 100644
--- a/src/interfaces/libpq-oauth/meson.build
+++ b/src/interfaces/libpq-oauth/meson.build
@@ -32,6 +32,7 @@ libpq_oauth_st = static_library('libpq-oauth',
   ],
   kwargs: default_lib_args,
 )
+libpq_targets += libpq_oauth_st
 
 # This is an internal module; we don't want an SONAME and therefore do not set
 # SO_MAJOR_VERSION.
@@ -47,6 +48,7 @@ libpq_oauth_so = shared_module(libpq_oauth_name,
   link_args: export_fmt.format(export_file.full_path()),
   kwargs: default_lib_args,
 )
+libpq_targets += libpq_oauth_so
 
 libpq_oauth_test_deps = []
 
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index c5ecd9c3a87..0b8dd3e1f5e 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -65,6 +65,7 @@ libpq_st = static_library('libpq',
   dependencies: [frontend_stlib_code, libpq_deps],
   kwargs: default_lib_args,
 )
+libpq_targets += libpq_st
 
 libpq_so = shared_library('libpq',
   libpq_sources + libpq_so_sources,
@@ -79,6 +80,7 @@ libpq_so = shared_library('libpq',
   link_args: export_fmt.format(export_file.full_path()),
   kwargs: default_lib_args,
 )
+libpq_targets += libpq_so
 
 libpq = declare_dependency(
   link_with: [libpq_so],

base-commit: 6ceef9408c26b6e188ec88c4303e9bad8ce33bff
-- 
2.52.0

From 78d8bcfbe57396da8122a6c34af1f3c724790462 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 27 Jan 2026 13:36:45 +0100
Subject: [PATCH v2 2/3] meson: Allow disabling static libraries

---
 .cirrus.tasks.yml                          |  1 +
 meson.build                                | 14 ++++++++++++++
 src/common/meson.build                     |  1 +
 src/fe_utils/meson.build                   |  4 +++-
 src/interfaces/ecpg/compatlib/meson.build  | 12 ++++++++----
 src/interfaces/ecpg/ecpglib/meson.build    | 12 ++++++++----
 src/interfaces/ecpg/pgtypeslib/meson.build | 12 ++++++++----
 src/interfaces/libpq-oauth/meson.build     | 11 ++++++++---
 src/interfaces/libpq/meson.build           | 12 ++++++++----
 src/port/meson.build                       |  1 +
 10 files changed, 60 insertions(+), 20 deletions(-)

diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml
index 2a821593ce5..4841a204248 100644
--- a/.cirrus.tasks.yml
+++ b/.cirrus.tasks.yml
@@ -133,6 +133,7 @@ task:
       meson setup \
         --buildtype=debug \
         --auto-features=disabled \
+        -Ddefault_library=shared \
         -Dtap_tests=enabled \
         build
     EOF
diff --git a/meson.build b/meson.build
index 824cebbade4..78918301d53 100644
--- a/meson.build
+++ b/meson.build
@@ -20,6 +20,7 @@ project('postgresql',
     'warning_level=1', #-Wall equivalent
     'b_pch=false',
     'buildtype=debugoptimized', # -O2 + debug
+    'default_library=both',
     # For compatibility with the autoconf build, set a default prefix. This
     # works even on windows, where it's a drive-relative path (i.e. when on
     # d:/somepath it'll install to d:/usr/local/pgsql)
@@ -50,6 +51,19 @@ not_found_dep = dependency('', required: false)
 thread_dep = dependency('threads')
 auto_features = get_option('auto_features')
 
+# Declare dependencies to disable static or shared libraries.  This
+# makes the 'default_library' option work even though we don't use the
+# library() function but instead shared_library() and static_library()
+# separately.
+default_library_opt = get_option('default_library')
+dep_shared_lib = declare_dependency()
+dep_static_lib = declare_dependency()
+if default_library_opt == 'shared'
+  dep_static_lib = disabler()
+elif default_library_opt == 'static'
+  dep_shared_lib = disabler()
+endif
+
 
 
 ###############################################################
diff --git a/src/common/meson.build b/src/common/meson.build
index b757618a9c9..1417ac3bbb7 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -192,6 +192,7 @@ foreach name, opts : pgcommon_variants
           opts.get('include_directories', []),
         ],
         'dependencies': opts['dependencies'] + [ssl],
+        'install': dep_static_lib.found(),
       }
     )
   pgcommon += {name: lib}
diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build
index a2420ea2d5c..9c9e0bcc0da 100644
--- a/src/fe_utils/meson.build
+++ b/src/fe_utils/meson.build
@@ -35,5 +35,7 @@ fe_utils = static_library('libpgfeutils',
   include_directories: [postgres_inc, libpq_inc],
   c_args: host_system == 'windows' ? ['-DFD_SETSIZE=1024'] : [],
   dependencies: frontend_common_code,
-  kwargs: default_lib_args,
+  kwargs: default_lib_args + {
+            'install': dep_static_lib.found(),
+          },
 )
diff --git a/src/interfaces/ecpg/compatlib/meson.build 
b/src/interfaces/ecpg/compatlib/meson.build
index 6cb1be73407..861cb67205e 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -20,17 +20,19 @@ ecpg_compat_st = static_library('libecpg_compat',
   ecpg_compat_sources,
   include_directories: ecpg_compat_inc,
   c_args: ecpg_compat_c_args,
-  dependencies: [frontend_stlib_code, thread_dep],
+  dependencies: [dep_static_lib, frontend_stlib_code, thread_dep],
   link_with: [ecpglib_st, ecpg_pgtypes_st],
   kwargs: default_lib_args,
 )
-ecpg_targets += ecpg_compat_st
+if dep_static_lib.found()
+  ecpg_targets += ecpg_compat_st
+endif
 
 ecpg_compat_so = shared_library('libecpg_compat',
   ecpg_compat_sources + ecpg_compat_so_sources,
   include_directories: ecpg_compat_inc,
   c_args: ecpg_compat_c_args,
-  dependencies: [frontend_shlib_code, thread_dep],
+  dependencies: [dep_shared_lib, frontend_shlib_code, thread_dep],
   link_with: [ecpglib_so, ecpg_pgtypes_so],
   soversion: host_system != 'windows' ? '3' : '',
   darwin_versions: ['3', '3.' + pg_version_major.to_string()],
@@ -39,7 +41,9 @@ ecpg_compat_so = shared_library('libecpg_compat',
   link_depends: export_file,
   kwargs: default_lib_args,
 )
-ecpg_targets += ecpg_compat_so
+if dep_shared_lib.found()
+  ecpg_targets += ecpg_compat_so
+endif
 
 pkgconfig.generate(
   name: 'libecpg_compat',
diff --git a/src/interfaces/ecpg/ecpglib/meson.build 
b/src/interfaces/ecpg/ecpglib/meson.build
index 889bd9efd65..d0841e99a19 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -30,18 +30,20 @@ ecpglib_st = static_library('libecpg',
   include_directories: ecpglib_inc,
   c_args: ecpglib_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [frontend_stlib_code, thread_dep, libpq],
+  dependencies: [dep_static_lib, frontend_stlib_code, thread_dep, libpq],
   link_with: [ecpg_pgtypes_st],
   kwargs: default_lib_args,
 )
-ecpg_targets += ecpglib_st
+if dep_static_lib.found()
+  ecpg_targets += ecpglib_st
+endif
 
 ecpglib_so = shared_library('libecpg',
   ecpglib_sources + ecpglib_so_sources,
   include_directories: ecpglib_inc,
   c_args: ecpglib_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [frontend_shlib_code, libpq, thread_dep],
+  dependencies: [dep_shared_lib, frontend_shlib_code, libpq, thread_dep],
   link_with: ecpg_pgtypes_so,
   soversion: host_system != 'windows' ? '6' : '',
   darwin_versions: ['6', '6.' + pg_version_major.to_string()],
@@ -50,7 +52,9 @@ ecpglib_so = shared_library('libecpg',
   link_depends: export_file,
   kwargs: default_lib_args,
 )
-ecpg_targets += ecpglib_so
+if dep_shared_lib.found()
+  ecpg_targets += ecpglib_so
+endif
 
 pkgconfig.generate(
   name: 'libecpg',
diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build 
b/src/interfaces/ecpg/pgtypeslib/meson.build
index 6b78f529e53..7b79da2368b 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -26,17 +26,19 @@ ecpg_pgtypes_st = static_library('libpgtypes',
   include_directories: ecpg_pgtypes_inc,
   c_args: ecpg_pgtypes_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: frontend_stlib_code,
+  dependencies: [dep_static_lib, frontend_stlib_code],
   kwargs: default_lib_args,
 )
-ecpg_targets += ecpg_pgtypes_st
+if dep_static_lib.found()
+  ecpg_targets += ecpg_pgtypes_st
+endif
 
 ecpg_pgtypes_so = shared_library('libpgtypes',
   ecpg_pgtypes_sources + ecpg_pgtypes_so_sources,
   include_directories: ecpg_pgtypes_inc,
   c_args: ecpg_pgtypes_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: frontend_shlib_code,
+  dependencies: [dep_shared_lib, frontend_shlib_code],
   version: '3.' + pg_version_major.to_string(),
   soversion: host_system != 'windows' ? '3' : '',
   darwin_versions: ['3', '3.' + pg_version_major.to_string()],
@@ -44,7 +46,9 @@ ecpg_pgtypes_so = shared_library('libpgtypes',
   link_depends: export_file,
   kwargs: default_lib_args,
 )
-ecpg_targets += ecpg_pgtypes_so
+if dep_shared_lib.found()
+  ecpg_targets += ecpg_pgtypes_so
+endif
 
 pkgconfig.generate(
   name: 'libpgtypes',
diff --git a/src/interfaces/libpq-oauth/meson.build 
b/src/interfaces/libpq-oauth/meson.build
index e573d36f20e..9c8cb90d989 100644
--- a/src/interfaces/libpq-oauth/meson.build
+++ b/src/interfaces/libpq-oauth/meson.build
@@ -26,13 +26,16 @@ libpq_oauth_st = static_library('libpq-oauth',
   include_directories: [libpq_oauth_inc, postgres_inc],
   c_pch: pch_postgres_fe_h,
   dependencies: [
+    dep_static_lib,
     frontend_stlib_code,
     libpq_oauth_deps,
     ssl, # libpq-int.h includes OpenSSL headers
   ],
   kwargs: default_lib_args,
 )
-libpq_targets += libpq_oauth_st
+if dep_static_lib.found()
+  libpq_targets += libpq_oauth_st
+endif
 
 # This is an internal module; we don't want an SONAME and therefore do not set
 # SO_MAJOR_VERSION.
@@ -43,12 +46,14 @@ libpq_oauth_so = shared_module(libpq_oauth_name,
   include_directories: [libpq_oauth_inc, postgres_inc],
   c_args: libpq_oauth_so_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [frontend_shlib_code, libpq, libpq_oauth_deps],
+  dependencies: [dep_shared_lib, frontend_shlib_code, libpq, libpq_oauth_deps],
   link_depends: export_file,
   link_args: export_fmt.format(export_file.full_path()),
   kwargs: default_lib_args,
 )
-libpq_targets += libpq_oauth_so
+if dep_shared_lib.found()
+  libpq_targets += libpq_oauth_so
+endif
 
 libpq_oauth_test_deps = []
 
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index 0b8dd3e1f5e..647d7e2ae7c 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -62,10 +62,12 @@ libpq_st = static_library('libpq',
   include_directories: [libpq_inc],
   c_args: libpq_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [frontend_stlib_code, libpq_deps],
+  dependencies: [dep_static_lib, frontend_stlib_code, libpq_deps],
   kwargs: default_lib_args,
 )
-libpq_targets += libpq_st
+if dep_static_lib.found()
+  libpq_targets += libpq_st
+endif
 
 libpq_so = shared_library('libpq',
   libpq_sources + libpq_so_sources,
@@ -75,12 +77,14 @@ libpq_so = shared_library('libpq',
   version: '5.' + pg_version_major.to_string(),
   soversion: host_system != 'windows' ? '5' : '',
   darwin_versions: ['5', '5.' + pg_version_major.to_string()],
-  dependencies: [frontend_shlib_code, libpq_deps],
+  dependencies: [dep_shared_lib, frontend_shlib_code, libpq_deps],
   link_depends: export_file,
   link_args: export_fmt.format(export_file.full_path()),
   kwargs: default_lib_args,
 )
-libpq_targets += libpq_so
+if dep_shared_lib.found()
+  libpq_targets += libpq_so
+endif
 
 libpq = declare_dependency(
   link_with: [libpq_so],
diff --git a/src/port/meson.build b/src/port/meson.build
index d7d4e705b89..a8d92937581 100644
--- a/src/port/meson.build
+++ b/src/port/meson.build
@@ -192,6 +192,7 @@ foreach name, opts : pgport_variants
       c_pch: pch_c_h,
       kwargs: opts + {
         'dependencies': opts['dependencies'] + [ssl],
+        'install': dep_static_lib.found(),
       }
     )
   pgport += {name: lib}
-- 
2.52.0

From 7bff4686cd5f4a297173ada26cc8f41c79029a65 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 27 Jan 2026 13:54:20 +0100
Subject: [PATCH v2 3/3] meson: Allow disabling static libraries (variant 2)

---
 meson.build                                | 10 +++++-----
 src/common/meson.build                     |  2 +-
 src/fe_utils/meson.build                   |  2 +-
 src/interfaces/ecpg/compatlib/meson.build  | 12 ++++++------
 src/interfaces/ecpg/ecpglib/meson.build    | 12 ++++++------
 src/interfaces/ecpg/pgtypeslib/meson.build | 12 ++++++------
 src/interfaces/libpq-oauth/meson.build     | 11 +++++------
 src/interfaces/libpq/meson.build           | 12 ++++++------
 src/port/meson.build                       |  2 +-
 9 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/meson.build b/meson.build
index 78918301d53..cb1c9e6f6b2 100644
--- a/meson.build
+++ b/meson.build
@@ -51,17 +51,17 @@ not_found_dep = dependency('', required: false)
 thread_dep = dependency('threads')
 auto_features = get_option('auto_features')
 
-# Declare dependencies to disable static or shared libraries.  This
+# Declare variables to disable static or shared libraries.  This
 # makes the 'default_library' option work even though we don't use the
 # library() function but instead shared_library() and static_library()
 # separately.
 default_library_opt = get_option('default_library')
-dep_shared_lib = declare_dependency()
-dep_static_lib = declare_dependency()
+build_shared_lib = true
+build_static_lib = true
 if default_library_opt == 'shared'
-  dep_static_lib = disabler()
+  build_static_lib = false
 elif default_library_opt == 'static'
-  dep_shared_lib = disabler()
+  build_shared_lib = false
 endif
 
 
diff --git a/src/common/meson.build b/src/common/meson.build
index 1417ac3bbb7..59caaf454c7 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -192,7 +192,7 @@ foreach name, opts : pgcommon_variants
           opts.get('include_directories', []),
         ],
         'dependencies': opts['dependencies'] + [ssl],
-        'install': dep_static_lib.found(),
+        'install': build_static_lib,
       }
     )
   pgcommon += {name: lib}
diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build
index 9c9e0bcc0da..c6265028107 100644
--- a/src/fe_utils/meson.build
+++ b/src/fe_utils/meson.build
@@ -36,6 +36,6 @@ fe_utils = static_library('libpgfeutils',
   c_args: host_system == 'windows' ? ['-DFD_SETSIZE=1024'] : [],
   dependencies: frontend_common_code,
   kwargs: default_lib_args + {
-            'install': dep_static_lib.found(),
+            'install': build_static_lib,
           },
 )
diff --git a/src/interfaces/ecpg/compatlib/meson.build 
b/src/interfaces/ecpg/compatlib/meson.build
index 861cb67205e..d578faefe1c 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -16,23 +16,24 @@ if host_system == 'windows'
 endif
 
 # see src/interfaces/libpq/meson.build
+if build_static_lib
 ecpg_compat_st = static_library('libecpg_compat',
   ecpg_compat_sources,
   include_directories: ecpg_compat_inc,
   c_args: ecpg_compat_c_args,
-  dependencies: [dep_static_lib, frontend_stlib_code, thread_dep],
+  dependencies: [frontend_stlib_code, thread_dep],
   link_with: [ecpglib_st, ecpg_pgtypes_st],
   kwargs: default_lib_args,
 )
-if dep_static_lib.found()
-  ecpg_targets += ecpg_compat_st
+ecpg_targets += ecpg_compat_st
 endif
 
+if build_shared_lib
 ecpg_compat_so = shared_library('libecpg_compat',
   ecpg_compat_sources + ecpg_compat_so_sources,
   include_directories: ecpg_compat_inc,
   c_args: ecpg_compat_c_args,
-  dependencies: [dep_shared_lib, frontend_shlib_code, thread_dep],
+  dependencies: [frontend_shlib_code, thread_dep],
   link_with: [ecpglib_so, ecpg_pgtypes_so],
   soversion: host_system != 'windows' ? '3' : '',
   darwin_versions: ['3', '3.' + pg_version_major.to_string()],
@@ -41,8 +42,7 @@ ecpg_compat_so = shared_library('libecpg_compat',
   link_depends: export_file,
   kwargs: default_lib_args,
 )
-if dep_shared_lib.found()
-  ecpg_targets += ecpg_compat_so
+ecpg_targets += ecpg_compat_so
 endif
 
 pkgconfig.generate(
diff --git a/src/interfaces/ecpg/ecpglib/meson.build 
b/src/interfaces/ecpg/ecpglib/meson.build
index d0841e99a19..81e92151945 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -25,25 +25,26 @@ if host_system == 'windows'
 endif
 
 # see src/interfaces/libpq/meson.build
+if build_static_lib
 ecpglib_st = static_library('libecpg',
   ecpglib_sources,
   include_directories: ecpglib_inc,
   c_args: ecpglib_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [dep_static_lib, frontend_stlib_code, thread_dep, libpq],
+  dependencies: [frontend_stlib_code, thread_dep, libpq],
   link_with: [ecpg_pgtypes_st],
   kwargs: default_lib_args,
 )
-if dep_static_lib.found()
-  ecpg_targets += ecpglib_st
+ecpg_targets += ecpglib_st
 endif
 
+if build_shared_lib
 ecpglib_so = shared_library('libecpg',
   ecpglib_sources + ecpglib_so_sources,
   include_directories: ecpglib_inc,
   c_args: ecpglib_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [dep_shared_lib, frontend_shlib_code, libpq, thread_dep],
+  dependencies: [frontend_shlib_code, libpq, thread_dep],
   link_with: ecpg_pgtypes_so,
   soversion: host_system != 'windows' ? '6' : '',
   darwin_versions: ['6', '6.' + pg_version_major.to_string()],
@@ -52,8 +53,7 @@ ecpglib_so = shared_library('libecpg',
   link_depends: export_file,
   kwargs: default_lib_args,
 )
-if dep_shared_lib.found()
-  ecpg_targets += ecpglib_so
+ecpg_targets += ecpglib_so
 endif
 
 pkgconfig.generate(
diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build 
b/src/interfaces/ecpg/pgtypeslib/meson.build
index 7b79da2368b..241fa95e559 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -21,24 +21,25 @@ if host_system == 'windows'
 endif
 
 # see src/interfaces/libpq/meson.build
+if build_static_lib
 ecpg_pgtypes_st = static_library('libpgtypes',
   ecpg_pgtypes_sources,
   include_directories: ecpg_pgtypes_inc,
   c_args: ecpg_pgtypes_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [dep_static_lib, frontend_stlib_code],
+  dependencies: [frontend_stlib_code],
   kwargs: default_lib_args,
 )
-if dep_static_lib.found()
-  ecpg_targets += ecpg_pgtypes_st
+ecpg_targets += ecpg_pgtypes_st
 endif
 
+if build_shared_lib
 ecpg_pgtypes_so = shared_library('libpgtypes',
   ecpg_pgtypes_sources + ecpg_pgtypes_so_sources,
   include_directories: ecpg_pgtypes_inc,
   c_args: ecpg_pgtypes_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [dep_shared_lib, frontend_shlib_code],
+  dependencies: [frontend_shlib_code],
   version: '3.' + pg_version_major.to_string(),
   soversion: host_system != 'windows' ? '3' : '',
   darwin_versions: ['3', '3.' + pg_version_major.to_string()],
@@ -46,8 +47,7 @@ ecpg_pgtypes_so = shared_library('libpgtypes',
   link_depends: export_file,
   kwargs: default_lib_args,
 )
-if dep_shared_lib.found()
-  ecpg_targets += ecpg_pgtypes_so
+ecpg_targets += ecpg_pgtypes_so
 endif
 
 pkgconfig.generate(
diff --git a/src/interfaces/libpq-oauth/meson.build 
b/src/interfaces/libpq-oauth/meson.build
index 9c8cb90d989..27aca2bc324 100644
--- a/src/interfaces/libpq-oauth/meson.build
+++ b/src/interfaces/libpq-oauth/meson.build
@@ -21,38 +21,37 @@ export_file = custom_target('libpq-oauth.exports',
 # port needs to be in include path due to pthread-win32.h
 libpq_oauth_inc = include_directories('.', '../libpq', '../../port')
 
+if build_static_lib
 libpq_oauth_st = static_library('libpq-oauth',
   libpq_oauth_sources,
   include_directories: [libpq_oauth_inc, postgres_inc],
   c_pch: pch_postgres_fe_h,
   dependencies: [
-    dep_static_lib,
     frontend_stlib_code,
     libpq_oauth_deps,
     ssl, # libpq-int.h includes OpenSSL headers
   ],
   kwargs: default_lib_args,
 )
-if dep_static_lib.found()
-  libpq_targets += libpq_oauth_st
+libpq_targets += libpq_oauth_st
 endif
 
 # This is an internal module; we don't want an SONAME and therefore do not set
 # SO_MAJOR_VERSION.
 libpq_oauth_name = 'libpq-oauth-@0@'.format(pg_version_major)
 
+if build_shared_lib
 libpq_oauth_so = shared_module(libpq_oauth_name,
   libpq_oauth_sources + libpq_oauth_so_sources,
   include_directories: [libpq_oauth_inc, postgres_inc],
   c_args: libpq_oauth_so_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [dep_shared_lib, frontend_shlib_code, libpq, libpq_oauth_deps],
+  dependencies: [frontend_shlib_code, libpq, libpq_oauth_deps],
   link_depends: export_file,
   link_args: export_fmt.format(export_file.full_path()),
   kwargs: default_lib_args,
 )
-if dep_shared_lib.found()
-  libpq_targets += libpq_oauth_so
+libpq_targets += libpq_oauth_so
 endif
 
 libpq_oauth_test_deps = []
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index 647d7e2ae7c..2b95098187e 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -57,18 +57,19 @@ libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH']
 # We could try to avoid building the source files twice, but it probably adds
 # more complexity than its worth (reusing object files requires also linking
 # to the library on windows or breaks precompiled headers).
+if build_static_lib
 libpq_st = static_library('libpq',
   libpq_sources,
   include_directories: [libpq_inc],
   c_args: libpq_c_args,
   c_pch: pch_postgres_fe_h,
-  dependencies: [dep_static_lib, frontend_stlib_code, libpq_deps],
+  dependencies: [frontend_stlib_code, libpq_deps],
   kwargs: default_lib_args,
 )
-if dep_static_lib.found()
-  libpq_targets += libpq_st
+libpq_targets += libpq_st
 endif
 
+if build_shared_lib
 libpq_so = shared_library('libpq',
   libpq_sources + libpq_so_sources,
   include_directories: [libpq_inc, postgres_inc],
@@ -77,13 +78,12 @@ libpq_so = shared_library('libpq',
   version: '5.' + pg_version_major.to_string(),
   soversion: host_system != 'windows' ? '5' : '',
   darwin_versions: ['5', '5.' + pg_version_major.to_string()],
-  dependencies: [dep_shared_lib, frontend_shlib_code, libpq_deps],
+  dependencies: [frontend_shlib_code, libpq_deps],
   link_depends: export_file,
   link_args: export_fmt.format(export_file.full_path()),
   kwargs: default_lib_args,
 )
-if dep_shared_lib.found()
-  libpq_targets += libpq_so
+libpq_targets += libpq_so
 endif
 
 libpq = declare_dependency(
diff --git a/src/port/meson.build b/src/port/meson.build
index a8d92937581..eb9151e4619 100644
--- a/src/port/meson.build
+++ b/src/port/meson.build
@@ -192,7 +192,7 @@ foreach name, opts : pgport_variants
       c_pch: pch_c_h,
       kwargs: opts + {
         'dependencies': opts['dependencies'] + [ssl],
-        'install': dep_static_lib.found(),
+        'install': build_static_lib,
       }
     )
   pgport += {name: lib}
-- 
2.52.0

Reply via email to