From 63ce9d6693445ffc44b2685b8e66df4704c9d24c Mon Sep 17 00:00:00 2001 From: Zurab Kvachadze Date: Tue, 4 Nov 2025 04:26:12 +0100 Subject: [PATCH] nginx-module.eclass: Add ngx_mod_link_lib helper The helpers make it easier to link to external libraries from ebuilds to accommodate to NGINX build system deficiencies. Signed-off-by: Zurab Kvachadze Part-of: https://github.com/gentoo/gentoo/pull/44576 Signed-off-by: Sam James --- eclass/nginx-module.eclass | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/eclass/nginx-module.eclass b/eclass/nginx-module.eclass index f17b7d4445be5..714467248de2e 100644 --- a/eclass/nginx-module.eclass +++ b/eclass/nginx-module.eclass @@ -24,7 +24,7 @@ # libraries/APIs. In the example HMAC case, the module actually requires # libcrypto, not the http_ssl module, so the ebuild code reflects this by # patching the module's 'config' file and depending on dev-libs/openssl directly -# using the ngx_mod_append_libs() function. +# using the ngx_mod_link_lib() function. # # If the module makes use of the ngx_devel_kit (NDK) or any other NGINX # module, there are two approaches. @@ -349,6 +349,25 @@ ngx_mod_link_module() { ngx_mod_append_libs "${sonames[@]/#/-l:}" } +# @FUNCTION: ngx_mod_link_lib +# @USAGE: +# @DESCRIPTION: +# Adds the necessary CFLAGS and LDFLAGS to link the NGINX module with the +# library specified by its . The {C,LD}FLAGS are +# obtained using pkgconfig. The caller must ensure that pkgconfig has been +# added to BDEPEND. +ngx_mod_link_lib() { + debug-print-function "${FUNCNAME[0]}" "$@" + [[ $# -ne 1 ]] && die "${FUNCNAME[0]} must receive exactly one argument" + local pkgconf + pkgconf="$(tc-getPKG_CONFIG)" + + "${pkgconf}" --exists "$1" || die "The pkgconfig library $1 does not exist" + + append-cflags "$("${pkgconf}" --cflags "$1")" + ngx_mod_append_libs "$("${pkgconf}" --libs "$1")" +} + #-----> ebuild-defined variables <----- # @ECLASS_VARIABLE: NGINX_MOD_S