]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: use a convenience lib for curl-util.c
authorZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Tue, 31 Mar 2026 11:08:03 +0000 (13:08 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Thu, 16 Apr 2026 15:21:56 +0000 (17:21 +0200)
Previously we compiled curl-util.c at least two times, and then also
shared it using the extract+object. Let's build a static "convenience lib"
for it.

(Using extract+object everywhere is not possible because the different
places where it is used are conditionalized independently so we don't
have a single "source" that is always available.)

src/imds/meson.build
src/import/meson.build
src/shared/meson.build

index cb919fec615d84b3f6bb5ae68cc321ff64f7fe0f..29fa878eaba43dc7827636240236558fdc0e4a7d 100644 (file)
@@ -11,7 +11,8 @@ executables += [
                 'sources' : files(
                         'imdsd.c',
                         'imds-util.c'
-                ) + curl_util_c,
+                ),
+                'link_with' : [libcurlutil_static, libshared],
                 'dependencies' : [libcurl],
         },
         libexec_template + {
index 1fab9afd0b00596978e89b73b8b2b5780e20bf28..13c90d7937fed8fc9ad7355bbe1f4c021776580f 100644 (file)
@@ -33,8 +33,9 @@ executables += [
                         'pull-oci.c',
                         'pull-raw.c',
                         'pull-tar.c',
-                ) + curl_util_c,
+                ),
                 'objects' : ['systemd-importd'],
+                'link_with' : [libcurlutil_static, libshared],
                 'dependencies' : common_deps + [
                         libopenssl,
                 ],
index efa0dc05adf6aafd7534de6ea56a6a0763a45500..8fb14f9fef69c22d12f2978a634f08472660b3f1 100644 (file)
@@ -256,9 +256,6 @@ if get_option('tests') != 'false'
         shared_sources += files('tests.c')
 endif
 
-# A small shared file that is is linked into a few places
-curl_util_c = files('curl-util.c')
-
 syscall_list_inc = custom_target(
         input : syscall_list_txt,
         output : 'syscall-list.inc',
@@ -458,3 +455,18 @@ libshared_fdisk = static_library(
                         userspace],
         c_args : ['-fvisibility=default'],
         build_by_default : false)
+
+# A small shared file that is linked into a few places.
+# It is not part of libshared because this code needs libcurl and
+# we don't want to link libshared to libcurl.
+if conf.get('HAVE_LIBCURL') == 1
+        libcurlutil_static = static_library(
+                'curl-util',
+                'curl-util.c',
+                implicit_include_directories : false,
+                dependencies : [userspace, libcurl],
+                include_directories : includes,
+                build_by_default : false)
+else
+        libcurlutil_static = []
+endif