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@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/44576
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Zurab Kvachadze
2025-11-04 04:26:12 +01:00
committed by Sam James
parent c9e91f7b6e
commit 63ce9d6693

View File

@@ -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