From: Zbigniew Jędrzejewski-Szmek Date: Tue, 31 Mar 2026 11:08:03 +0000 (+0200) Subject: meson: use a convenience lib for curl-util.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b63373a65657ef610622590a00dd5a9452873e9a;p=thirdparty%2Fsystemd.git meson: use a convenience lib for curl-util.c 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.) --- diff --git a/src/imds/meson.build b/src/imds/meson.build index cb919fec615..29fa878eaba 100644 --- a/src/imds/meson.build +++ b/src/imds/meson.build @@ -11,7 +11,8 @@ executables += [ 'sources' : files( 'imdsd.c', 'imds-util.c' - ) + curl_util_c, + ), + 'link_with' : [libcurlutil_static, libshared], 'dependencies' : [libcurl], }, libexec_template + { diff --git a/src/import/meson.build b/src/import/meson.build index 1fab9afd0b0..13c90d7937f 100644 --- a/src/import/meson.build +++ b/src/import/meson.build @@ -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, ], diff --git a/src/shared/meson.build b/src/shared/meson.build index efa0dc05adf..8fb14f9fef6 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -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