]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: automate .standalone variant generation via extended 'install' field
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Jul 2026 19:16:02 +0000 (04:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Jul 2026 07:29:53 +0000 (16:29 +0900)
Extend the 'install' keyword for executable definitions to accept four
modes—'yes', 'no', 'both', and 'static'—to elegantly manage the creation
and installation of both shared and statically-linked (.standalone) binaries.

- 'yes' / 'no': Standard behavior (mapped to true/false).
- 'both': Installs both the shared and static variants.
- 'static': Installs the static variant under the original name, while
  suffixing the uninstalled shared variant with '.shared'.

With this change, any arbitrary executable can now have its `.standalone`
variant built on demand simply by invoking `ninja <target>.standalone`.
For example, `varlinkctl` did not previously support a standalone variant,
but it can now be built explicitly via `ninja varlinkctl.standalone`.

These `.standalone` binaries are not built by default unless explicitly
specified as a ninja target or enabled via `-Dstandalone-binaries=true`.
Thus, the default build time should remain unaffected.

This centralisation eliminates a massive amount of boilerplate and duplicated
target declarations across almost all subdirectories (e.g., systemd-repart,
systemd-tmpfiles, systemd-shutdown, and systemd-report tools).

19 files changed:
meson.build
src/analyze/meson.build
src/bless-boot/meson.build
src/bootctl/meson.build
src/core/meson.build
src/hwdb/meson.build
src/journal-remote/meson.build
src/journal/meson.build
src/network/meson.build
src/portable/meson.build
src/repart/meson.build
src/report/meson.build
src/shutdown/meson.build
src/systemctl/meson.build
src/sysusers/meson.build
src/test/meson.build
src/timesync/meson.build
src/tmpfiles/meson.build
src/udev/meson.build

index 81bf99f4153129107ae9b130017dd49a8d03b7a6..6850298a316fa6fe4e824155f6a262334f668ed4 100644 (file)
@@ -2019,11 +2019,21 @@ endif
 
 #####################################################################
 
+# The 'install' field is extended to also control whether the automatically
+# added variant, which is statically linked with libsystemd-shared, is installed:
+#   'yes'    : Mapped to true. The static variant will not be installed.
+#   'no'     : Mapped to false. The static variant will not be installed either.
+#   'both'   : Mapped to true. The static variant will also be installed.
+#   'static' : Mapped to false, and its target name is suffixed with '.shared'.
+#              The static variant will be installed instead using the original name
+#              (without the '.standalone' suffix).
+# Currently, test and fuzzer executables only support 'yes' or 'no'.
 executable_template = {
         'include_directories' : includes,
-        'link_with' : libshared,
+        'link_with' : [libshared],
         'install_rpath' : pkglibdir,
-        'install' : true,
+        'install' : 'yes',
+        'build_by_default' : true,
 }
 
 generator_template = executable_template + {
@@ -2040,7 +2050,7 @@ executable_additional_kwargs = {
 
 test_template = executable_template + {
         'build_by_default' : want_tests != 'false',
-        'install' : install_tests,
+        'install' : install_tests ? 'yes' : 'no',
         'install_dir' : unittestsdir,
 }
 
@@ -2051,7 +2061,7 @@ test_additional_kwargs = {
 
 fuzz_template = executable_template + {
         'build_by_default' : want_fuzz_tests,
-        'install' : false,
+        'install' : 'no',
 }
 
 if want_ossfuzz
@@ -2263,7 +2273,6 @@ foreach dict : executables
 
         is_test = name.startswith('test-')
         is_fuzz = name.startswith('fuzz-')
-        is_standalone = name.endswith('.standalone')
 
         build = true
         foreach cond : dict.get('conditions', [])
@@ -2276,20 +2285,22 @@ foreach dict : executables
                 continue
         endif
 
-        exe_sources = dict.get('sources', []) + dict.get('export', [])
+        exe_sources_static = dict.get('sources', [])
 
         foreach bpf_name : dict.get('bpf_programs', [])
                 if bpf_name in bpf_programs_by_name
-                        exe_sources += bpf_programs_by_name[bpf_name]
+                        exe_sources_static += bpf_programs_by_name[bpf_name]
                 endif
         endforeach
 
+        exe_sources = exe_sources_static + dict.get('export', [])
+
         kwargs = {}
         foreach key, val : dict
                 if key in ['name', 'dbus', 'public', 'conditions', 'type', 'suite',
                            'timeout', 'parallel', 'sources', 'import', 'export',
                            'include_directories', 'build_by_default', 'install',
-                           'bpf_programs']
+                           'bpf_programs', 'link_args_static']
                         continue
                 endif
 
@@ -2329,30 +2340,54 @@ foreach dict : executables
                 endforeach
         endif
 
-        build_by_default = dict.get('build_by_default',
-                                    have_standalone_binaries or not is_standalone)
-
-        if not is_standalone
-                install = dict.get('install', true)
+        name_shared = name
+        name_static = name + '.standalone'
+        install = dict.get('install')
+        build_by_default = dict.get('build_by_default')
+        if install == 'yes'
+                install_shared = true
+                install_static = false
+                build_by_default_shared = build_by_default
+                build_by_default_static = false
+        elif install == 'no'
+                install_shared = false
+                install_static = false
+                build_by_default_shared = build_by_default
+                build_by_default_static = false
+        elif install == 'both'
+                if is_test or is_fuzz
+                        error('Install mode "@0@" is not supported for test or fuzzer target "@1@"'.format(install, name))
+                endif
+                install_shared = true
+                install_static = true
+                build_by_default_shared = build_by_default
+                build_by_default_static = build_by_default
+        elif install == 'static'
+                if is_test or is_fuzz
+                        error('Install mode "@0@" is not supported for test or fuzzer target "@1@"'.format(install, name))
+                endif
+                name_shared = name + '.shared'
+                name_static = name
+                install_shared = false
+                install_static = true
+                build_by_default_shared = false
+                build_by_default_static = build_by_default
         else
-                install = have_standalone_binaries
+                error('Unknown install mode "@0@" for target "@1@"'.format(install, name))
         endif
 
         exe = executable(
-                name,
+                name_shared,
                 sources : exe_sources,
                 kwargs : kwargs,
                 implicit_include_directories : false,
                 include_directories : include_directories,
-                build_by_default: build_by_default,
-                install: install,
+                build_by_default: build_by_default_shared,
+                install: install_shared,
         )
 
-        executables_by_name += { name : exe }
-
-        if not is_standalone
-                sources += exe_sources
-        endif
+        executables_by_name += { name_shared : exe }
+        sources += exe_sources
 
         if 'export' in dict
                 exported_by_name += {
@@ -2363,7 +2398,7 @@ foreach dict : executables
                 }
         endif
 
-        if build_by_default
+        if build_by_default_shared
                 if dict.get('dbus', false)
                         dbus_programs += exe
                 endif
@@ -2372,6 +2407,56 @@ foreach dict : executables
                 endif
         endif
 
+        if not is_test and not is_fuzz
+                kwargs_static = kwargs
+
+                if 'export' in dict
+                        obj = exported_by_name[name]
+                        kwargs_static += { 'objects' : kwargs_static.get('objects', []) + obj['exported'] }
+                        include_directories += obj['include_directories']
+                endif
+
+                link_with_static = []
+                foreach obj : kwargs_static.get('link_with', [])
+                        if obj.full_path() == libshared.full_path()
+                                link_with_static += [
+                                        libshared_static,
+                                        libsystemd_static,
+                                ]
+                        elif obj.full_path() == libcore.full_path()
+                                link_with_static += libcore_static
+                        else
+                                link_with_static += obj
+                        endif
+                endforeach
+
+                kwargs_static += {
+                        'link_with' : link_with_static,
+                        'link_args' : dict.get('link_args_static', kwargs_static.get('link_args', [])),
+                }
+
+                exe = executable(
+                        name_static,
+                        sources : exe_sources_static,
+                        kwargs : kwargs_static,
+                        implicit_include_directories : false,
+                        include_directories : include_directories,
+                        build_by_default: build_by_default_static,
+                        install: install_static,
+                )
+
+                executables_by_name += { name_static : exe }
+
+                if build_by_default_static
+                        if dict.get('dbus', false) and not build_by_default_shared
+                                dbus_programs += exe
+                        endif
+                        if dict.get('public', false)
+                                public_programs += exe
+                        endif
+                endif
+        endif
+
         if is_test
                 type = dict.get('type', '')
                 suite = dict.get('suite', '')
index 2b8b260c47f84bed94bf33314da1406f808c24ad..af9f5d52cd873a58332f27f626673efb5768f834 100644 (file)
@@ -59,7 +59,7 @@ executables += [
                         libseccomp_cflags,
                         tpm2_cflags,
                 ],
-                'install' : conf.get('ENABLE_ANALYZE') == 1,
+                'install' : conf.get('ENABLE_ANALYZE') == 1 ? 'yes' : 'no',
         },
         core_test_template + {
                 'sources' : files('test-verify.c'),
index ae814f1b29d1ac32f7a33d777575d17da5860e04..737c652c27258a9b78dd7f8e0416ca6eeabbdce4 100644 (file)
@@ -1,14 +1,5 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
-if get_option('link-boot-shared')
-        boot_link_with = [libshared]
-else
-        boot_link_with = [
-                libshared_static,
-                libsystemd_static,
-        ]
-endif
-
 executables += [
         libexec_template + {
                 'name' : 'systemd-bless-boot',
@@ -18,7 +9,7 @@ executables += [
                         'ENABLE_BOOTLOADER',
                 ],
                 'sources' : files('bless-boot.c'),
-                'link_with' : boot_link_with,
+                'install' : get_option('link-boot-shared') ? 'yes' : 'static',
         },
         generator_template + {
                 'name' : 'systemd-bless-boot-generator',
@@ -27,7 +18,7 @@ executables += [
                         'ENABLE_BOOTLOADER',
                 ],
                 'sources' : files('bless-boot-generator.c'),
-                'link_with' : boot_link_with,
+                'install' : get_option('link-boot-shared') ? 'yes' : 'static',
         },
         libexec_template + {
                 'name' : 'systemd-boot-check-no-failures',
index 958a804b80598b22b2359b7f795521fd974892c5..d312b5e6177b9924c00c8a07119cfe8912cd71ac 100644 (file)
@@ -23,11 +23,11 @@ executables += [
                           'HAVE_BLKID',
                 ],
                 'sources' : bootctl_sources,
-                'link_with' : boot_link_with,
                 'dependencies' : [
                         libopenssl_cflags,
                         tpm2_cflags,
                 ],
+                'install' : get_option('link-boot-shared') ? 'yes' : 'static',
         },
         test_template + {
                 'sources' : files(
index e46698b4cf8ec5545dbe4300928a1d49e6a2c3d1..e8d6563803f8ff86d9bd8e8d58833d07013d0ecc 100644 (file)
@@ -200,18 +200,6 @@ libcore = shared_library(
         install : true,
         install_dir : pkglibdir)
 
-core_libs_static = [
-        libc_wrapper_static,
-        libcore_static,
-        libshared_static,
-        libbasic_static,
-        libsystemd_static,
-]
-core_libs_shared = [
-        libcore,
-        libshared,
-]
-
 systemd_deps = [
         libapparmor_cflags,
         libaudit_cflags,
@@ -221,11 +209,6 @@ systemd_deps = [
         libselinux_cflags,
 ]
 
-systemd_link_args = get_option('build-static') ? ['-static'] : []
-systemd_libs = get_option('build-static') ? core_libs_static : core_libs_shared
-
-executor_libs = get_option('link-executor-shared') ? core_libs_shared : core_libs_static
-
 if conf.get('SYSTEMD_MULTICALL_BINARY') == 1
         systemd_sources += systemd_executor_sources
         systemd_deps += [
@@ -242,16 +225,20 @@ executables += [
                 'dbus' : true,
                 'public' : true,
                 'sources' : systemd_sources,
-                'link_args' : systemd_link_args,
-                'link_with' : systemd_libs,
+                'link_args_static' : get_option('build-static') ? ['-static'] : [],
+                'link_with' : [
+                        libcore,
+                        libshared,
+                ],
                 'dependencies' : systemd_deps,
+                'install' : get_option('build-static') ? 'static' : 'yes',
         },
 
         fuzz_template + {
                 'sources' : files('fuzz-unit-file.c'),
                 'link_with' : [
                         libcore,
-                        libshared
+                        libshared,
                 ],
                 'dependencies' : libmount_cflags,
         },
@@ -259,14 +246,14 @@ executables += [
                 'sources' : files('fuzz-manager-serialize.c'),
                 'link_with' : [
                         libcore,
-                        libshared
+                        libshared,
                 ],
         },
         fuzz_template + {
                 'sources' : files('fuzz-execute-serialize.c'),
                 'link_with' : [
                         libcore,
-                        libshared
+                        libshared,
                 ],
         },
 ]
@@ -282,7 +269,10 @@ else
                         'name' : 'systemd-executor',
                         'public' : true,
                         'sources' : systemd_executor_sources,
-                        'link_with' : executor_libs,
+                        'link_with' : [
+                                libcore,
+                                libshared,
+                        ],
                         'dependencies' : [
                                 libapparmor_cflags,
                                 libbpf_cflags,
@@ -293,6 +283,7 @@ else
                                 libseccomp_cflags,
                                 libselinux_cflags,
                         ],
+                        'install' : get_option('link-executor-shared') ? 'yes' : 'static',
                 },
         ]
 endif
index 57ace3ad44d4d3b9c8f61ee70f3ccc8375e92b44..cb1d3562bd8d89610d313dc3c70140c4317fc8d1 100644 (file)
@@ -6,8 +6,7 @@ executables += [
                 'public' : true,
                 'conditions' : ['ENABLE_HWDB'],
                 'sources' : files('hwdb.c'),
-                'link_with' : udev_link_with,
-                'install_rpath' : udev_rpath,
+                'install' : get_option('link-udev-shared') ? 'yes' : 'static',
                 'install_tag' : 'hwdb',
         },
 ]
index 574263e6451cb91d9bb48bd676e744732148ba69..441a173eabbae1d6f82f61da362de4dca990be4d 100644 (file)
@@ -44,7 +44,7 @@ executables += [
                 # We always build systemd-journal-remote regardless of ENABLE_REMOTE because we have to build
                 # fuzz-journal-remote even when --auto-features=disabled (see tools/oss-fuzz.sh for why).
                 # Instead, we make sure we don't install it when the remote feature is disabled.
-                'install' : conf.get('ENABLE_REMOTE') == 1,
+                'install' : conf.get('ENABLE_REMOTE') == 1 ? 'yes' : 'no',
                 'sources' : systemd_journal_remote_sources,
                 'export' : systemd_journal_remote_export_sources,
                 'dependencies' : common_deps + [libmicrohttpd_cflags],
index 4ddc92484a0c08c3e294cbce2b00637aec9529ca..a27b359b6119e5b93921215fdaa321b2a0314345 100644 (file)
@@ -68,15 +68,6 @@ journalctl_sources = files(
         'journalctl-varlink-server.c',
 )
 
-if get_option('link-journalctl-shared')
-        journalctl_link_with = [libshared]
-else
-        journalctl_link_with = [
-                libshared_static,
-                libsystemd_static,
-        ]
-endif
-
 journal_test_template = test_template + {
         'import' : ['systemd-journald'],
 }
@@ -123,7 +114,6 @@ executables += [
                 'name' : 'journalctl',
                 'public' : true,
                 'sources' : journalctl_sources,
-                'link_with' : journalctl_link_with,
                 'dependencies' : [
                         liblz4_cflags,
                         libopenssl_cflags,
@@ -131,6 +121,7 @@ executables += [
                         libxz_cflags,
                         libzstd_cflags,
                 ],
+                'install' : get_option('link-journalctl-shared') ? 'yes' : 'static',
         },
         journal_test_template + {
                 'sources' : files('test-audit-type.c'),
index 8baa80556fdb77629b480a9eca6a84e5246252c7..2a4120f747016a8c05fb2028e968d58507499b1d 100644 (file)
@@ -163,19 +163,12 @@ netdev_gperf_c = custom_target(
 generated_sources += [networkd_gperf_c, networkd_network_gperf_c, netdev_gperf_c]
 systemd_networkd_export_sources += [networkd_gperf_c, networkd_network_gperf_c, netdev_gperf_c]
 
-if get_option('link-networkd-shared')
-        networkd_link_with = [libshared]
-else
-        networkd_link_with = [libsystemd_static,
-                              libshared_static]
-endif
-
 network_includes = [include_directories(['.', 'netdev', 'tc']), libsystemd_network_includes]
 
 network_test_template = test_template + {
         'conditions' : ['ENABLE_NETWORKD'],
         'link_with' : [
-                networkd_link_with,
+                libshared,
                 libsystemd_network,
         ],
         'import' : ['systemd-networkd'],
@@ -185,7 +178,7 @@ network_test_template = test_template + {
 network_fuzz_template = fuzz_template + {
         'conditions' : ['ENABLE_NETWORKD'],
         'link_with' : [
-                networkd_link_with,
+                libshared,
                 libsystemd_network,
         ],
         'import' : ['systemd-networkd'],
@@ -201,8 +194,8 @@ executables += [
                 'export' : systemd_networkd_export_sources,
                 'include_directories' : network_includes,
                 'link_with' : [
+                        libshared,
                         libsystemd_network,
-                        networkd_link_with,
                 ],
                 'dependencies' : [
                         libbpf_cflags,
@@ -210,13 +203,14 @@ executables += [
                 'bpf_programs': [
                         'sysctl-monitor',
                 ],
+                'install' : get_option('link-networkd-shared') ? 'yes' : 'static',
         },
         libexec_template + {
                 'name' : 'systemd-networkd-wait-online',
                 'public' : true,
                 'conditions' : ['ENABLE_NETWORKD'],
                 'sources' : systemd_networkd_wait_online_sources,
-                'link_with' : networkd_link_with,
+                'install' : get_option('link-networkd-shared') ? 'yes' : 'static',
         },
         executable_template + {
                 'name' : 'networkctl',
@@ -225,18 +219,19 @@ executables += [
                 'sources' : networkctl_sources,
                 'include_directories' : libsystemd_network_includes,
                 'link_with' : [
+                        libshared,
                         libsystemd_network,
-                        networkd_link_with,
                 ],
                 'dependencies' : [
                         libselinux_cflags,
                 ],
+                'install' : get_option('link-networkd-shared') ? 'yes' : 'static',
         },
         libexec_template + {
                 'name' : 'systemd-network-generator',
                 'sources' : files('generator/network-generator-main.c'),
                 'export' : files('generator/network-generator.c'),
-                'link_with' : networkd_link_with,
+                'install' : get_option('link-networkd-shared') ? 'yes' : 'static',
         },
         test_template + {
                 'sources' : files('generator/test-network-generator.c'),
@@ -263,7 +258,6 @@ executables += [
         test_template + {
                 'sources' : files('test-modem-manager-mock.c'),
                 'conditions' : ['ENABLE_NETWORKD'],
-                'link_with' : [libshared],
                 'type' : 'manual',
         },
         network_fuzz_template + {
index 0bd5d1c3ce2628b44bdeafb5a720e56d8fff7594..1a3897495e51a9d0ce468de82f23903c833c9828 100644 (file)
@@ -13,32 +13,23 @@ systemd_portabled_sources = files(
         'portabled.c',
 )
 
-if get_option('link-portabled-shared')
-        portabled_link_with = [libshared]
-else
-        portabled_link_with = [
-                libshared_static,
-                libsystemd_static,
-        ]
-endif
-
 executables += [
         libexec_template + {
                 'name' : 'systemd-portabled',
                 'dbus' : true,
                 'sources' : systemd_portabled_sources,
-                'link_with' : portabled_link_with,
                 'dependencies' : [
                         libcryptsetup_cflags,
                         libmount_cflags,
                         libselinux_cflags,
                 ],
+                'install' : get_option('link-portabled-shared') ? 'yes' : 'static',
         },
         executable_template + {
                 'name' : 'portablectl',
                 'public' : true,
                 'sources' : files('portablectl.c'),
-                'link_with' : portabled_link_with,
+                'install' : get_option('link-portabled-shared') ? 'yes' : 'static',
         },
 ]
 
index d7c2edf0d532f2bc97d72ecad35e0b14c7740dde..1cff471087c5caf8c02487b4cd0547a7316bd155 100644 (file)
@@ -21,25 +21,7 @@ executables += [
                         libopenssl_cflags,
                         tpm2_cflags,
                 ],
-        },
-        executable_template + {
-                'name' : 'systemd-repart.standalone',
-                'public' : true,
-                'import' : ['systemd-repart'],
-                'link_with' : [
-                        libc_wrapper_static,
-                        libbasic_static,
-                        libshared_static,
-                        libsystemd_static,
-                ],
-                'dependencies' : [
-                        libblkid_cflags,
-                        libcryptsetup_cflags,
-                        libfdisk_cflags,
-                        libmount_cflags,
-                        libopenssl_cflags,
-                        tpm2_cflags,
-                ],
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
 ]
 
index 2c49a97fbf64f5625e7c552222ff28a4cb33ea82..3eaf20a397b2f237ac75dbc94b218c2743a487ba 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
-report_executables = [
-        {
+executables += [
+        libexec_template + {
                 'name' : 'systemd-report',
                 'public' : true,
                 'export' : files(
@@ -13,64 +13,47 @@ report_executables = [
                 'dependencies' : [
                         libcurl_cflags,
                 ],
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
-        {
+        libexec_template + {
                 'name' : 'systemd-report-basic',
                 'public' : true,
                 'export' : files(
                         'report-basic.c',
                         'report-basic-server.c',
                 ),
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
-        {
+        libexec_template + {
                 'name' : 'systemd-report-cgroup',
                 'export' : files(
                         'report-cgroup.c',
                         'report-cgroup-server.c',
                 ),
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
-        {
+        libexec_template + {
                 'name' : 'systemd-report-files',
                 'export' : files(
                         'report-files.c',
                         'report-files-server.c',
                 ),
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
-        {
+        libexec_template + {
                 'name' : 'systemd-report-sign-plain',
                 'export' : files(
                         'report-sign-plain.c',
                 ),
                 'dependencies' : libopenssl_cflags,
                 'conditions' : ['HAVE_OPENSSL'],
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
-        {
+        libexec_template + {
                 'name' : 'systemd-report-sign-tsm',
                 'export' : files(
                         'report-sign-tsm.c',
                 ),
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
 ]
-
-foreach exe : report_executables
-        exe2 = {
-                'name' : exe['name'] + '.standalone',
-                'import' : [exe['name']],
-                'link_with' : [
-                        libc_wrapper_static,
-                        libbasic_static,
-                        libshared_static,
-                        libsystemd_static,
-                ]
-        }
-        foreach optional : ['public', 'dependencies', 'conditions']
-                if optional in exe
-                        exe2 += { optional : exe[optional] }
-                endif
-        endforeach
-
-        executables += [
-                libexec_template + exe,
-                libexec_template + exe2,
-        ]
-endforeach
index 98669bfdf3fbe2fbf15a5d0b3430ba8b909e030e..e9f4abeaa9be7b15ce7a5183d4605fb085d4a3ef 100644 (file)
@@ -19,17 +19,7 @@ executables += [
                         'shutdown.c',
                 ) + shutdown_detach_sources,
                 'dependencies' : libmount_cflags,
-        },
-        libexec_template + {
-                'name' : 'systemd-shutdown.standalone',
-                'import' : ['systemd-shutdown'],
-                'link_with' : [
-                        libc_wrapper_static,
-                        libbasic_static,
-                        libshared_static,
-                        libsystemd_static,
-                ],
-                'dependencies' : libmount_cflags,
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
         test_template + {
                 'sources' : files('test-umount.c') +
index 7b75eef43c1e3dc2db9325e3d6a0426ebfd65ae4..b23af93221dd2993cec04f43f34d57657f4effc6 100644 (file)
@@ -40,31 +40,23 @@ systemctl_export_sources = files(
         'systemctl.c',
 )
 
-if get_option('link-systemctl-shared')
-        systemctl_link_with = [libshared]
-else
-        systemctl_link_with = [libsystemd_static,
-                               libshared_static]
-endif
-
 executables += [
         executable_template + {
                 'name' : 'systemctl',
                 'public' : true,
                 'sources' : systemctl_sources,
                 'export' : systemctl_export_sources,
-                'link_with' : systemctl_link_with,
                 'dependencies' : [
                         liblz4_cflags,
                         libxz_cflags,
                         libzstd_cflags,
                 ],
+                'install' : get_option('link-systemctl-shared') ? 'yes' : 'static',
                 'install_tag' : 'systemctl',
         },
         fuzz_template + {
                 'sources' : files('fuzz-systemctl-parse-argv.c'),
                 'import' : ['systemctl'],
-                'link_with' : systemctl_link_with,
                 'dependencies' : [
                         libselinux_cflags,
                 ],
index 9ff149d72d2d0290740389a196ab7dc0589b0d51..4fc99bfb24ff4c819d0a9cc538f4f9aed70d5d14 100644 (file)
@@ -10,17 +10,6 @@ executables += [
                 'public' : true,
                 'export' : files('sysusers.c'),
                 'dependencies' : libaudit_cflags,
-        },
-        executable_template + {
-                'name' : 'systemd-sysusers.standalone',
-                'public' : true,
-                'import' : ['systemd-sysusers'],
-                'link_with' : [
-                        libc_wrapper_static,
-                        libbasic_static,
-                        libshared_static,
-                        libsystemd_static,
-                ],
-                'dependencies' : libaudit_cflags,
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
 ]
index 2cb18a798a88867620cb755c26b421ed84ffb2c9..ccd4a327ce31f6230c00fe0144cb88e5ec2d0ae3 100644 (file)
@@ -17,6 +17,7 @@ test_env = {
         'SYSTEMD_SLOW_TESTS' : want_slow_tests ? '1' : '0',
         'PYTHONDONTWRITEBYTECODE' : '1',
         'SYSTEMD_LIBC' : get_option('libc'),
+        'SYSTEMD_BUILD_MODE' : get_option('mode'),
 }
 if conf.get('ENABLE_LOCALED') == 1
         test_env += {'SYSTEMD_LANGUAGE_FALLBACK_MAP' : language_fallback_map}
@@ -349,7 +350,7 @@ executables += [
                         libc_wrapper_static,
                         libbasic_static,
                 ],
-                'install' : false,
+                'install' : 'no',
                 'type' : 'manual',
         },
         test_template + {
@@ -721,7 +722,7 @@ if static_libsystemd != 'false'
                         'sources' : [test_libsystemd_sym_c],
                         'link_with' : install_libsystemd_static,
                         'build_by_default' : want_tests != 'false',
-                        'install' : install_tests,
+                        'install' : install_tests ? 'yes' : 'no',
                         'suite' : 'libsystemd',
                 },
         ]
@@ -736,7 +737,7 @@ if static_libudev != 'false'
                         'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
                         'link_with' : install_libudev_static,
                         'build_by_default' : want_tests != 'false',
-                        'install' : install_tests,
+                        'install' : install_tests ? 'yes' : 'no',
                         'suite' : 'libudev',
                 },
         ]
index 896a51c191a12eb324fee3be1923a944f51e7241..9a9fc27df1427f45ccdb340d2ad02ff4a11fe892 100644 (file)
@@ -22,20 +22,13 @@ timesyncd_gperf_c = custom_target(
 generated_sources += timesyncd_gperf_c
 timesyncd_export_sources += timesyncd_gperf_c
 
-if get_option('link-timesyncd-shared')
-        timesyncd_link_with = [libshared]
-else
-        timesyncd_link_with = [libsystemd_static,
-                               libshared_static]
-endif
-
 executables += [
         libexec_template + {
                 'name' : 'systemd-timesyncd',
                 'sources' : timesyncd_sources,
                 'export' : timesyncd_export_sources,
-                'link_with' : timesyncd_link_with,
                 'dependencies' : libm,
+                'install' : get_option('link-timesyncd-shared') ? 'yes' : 'static',
         },
         libexec_template + {
                 'name' : 'systemd-time-wait-sync',
index 5f661c19259de87c97815deef45e6bd697e9ca9b..8c18190e12e4092d90479dfe8ebd0e816495c344 100644 (file)
@@ -16,21 +16,7 @@ executables += [
                         libacl_cflags,
                         libselinux_cflags,
                 ],
-        },
-        executable_template + {
-                'name' : 'systemd-tmpfiles.standalone',
-                'public' : true,
-                'import' : ['systemd-tmpfiles'],
-                'link_with' : [
-                        libc_wrapper_static,
-                        libbasic_static,
-                        libshared_static,
-                        libsystemd_static,
-                ],
-                'dependencies' : [
-                        libacl_cflags,
-                        libselinux_cflags,
-                ],
+                'install' : have_standalone_binaries ? 'both' : 'yes',
         },
         test_template + {
                 'sources' : files('test-offline-passwd.c') +
index cfbf958ed38210d713671bfd4095d2f3f6600234..50060646ba9f82ea78bf8a1d2fa2daf41e65d74c 100644 (file)
@@ -106,17 +106,6 @@ generated_sources += link_config_gperf_c
 
 ############################################################
 
-if get_option('link-udev-shared')
-        udev_link_with = [libshared]
-        udev_rpath = pkglibdir
-else
-        udev_link_with = [libshared_static,
-                          libsystemd_static]
-        udev_rpath = ''
-endif
-
-############################################################
-
 udev_dependencies = [
         libacl_cflags,
         libblkid_cflags,
@@ -128,8 +117,7 @@ udev_dependencies = [
 
 udev_plugin_template = executable_template + {
         'public' : true,
-        'link_with' : udev_link_with,
-        'install_rpath' : udev_rpath,
+        'install' : get_option('link-udev-shared') ? 'yes' : 'static',
         'install_dir' : udevlibexecdir,
         'install_tag' : 'udev',
 }
@@ -156,8 +144,7 @@ udev_binaries_dict = [
                         libexec_template['include_directories'],
                 ],
                 'dependencies' : udev_dependencies,
-                'link_with' : udev_link_with,
-                'install_rpath' : udev_rpath,
+                'install' : get_option('link-udev-shared') ? 'yes' : 'static',
                 'install_tag' : 'udev',
         },
         udev_plugin_template + {