commit: 63ce9d6693445ffc44b2685b8e66df4704c9d24c Author: Zurab Kvachadze <zurabid2016 <AT> gmail <DOT> com> AuthorDate: Tue Nov 4 03:26:12 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Thu Nov 13 12:33:10 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=63ce9d66
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 <zurabid2016 <AT> gmail.com> Part-of: https://github.com/gentoo/gentoo/pull/44576 Signed-off-by: Sam James <sam <AT> gentoo.org> 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 f17b7d4445be..714467248de2 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: <pkgconfig module name> +# @DESCRIPTION: +# Adds the necessary CFLAGS and LDFLAGS to link the NGINX module with the +# library specified by its <pkgconfig module name>. 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
