bcache: support external gettext when libintl is in glibc (#34114)

* bcache: support external gettext when `libintl` is in glibc

Many glibc-based Linux systems don't have gettext's libintl because
libintl is included in the standard system's glibc (libc) itself.

When using `spack external find gettext` on those, packages like
`bcache` which unconditionally to link using `-lintl` fail to link
with -lintl.

Description of the fix:

The libs property of spack's gettext recipe returns the list of libs,
so when gettext provides libintl, use it. When not, there is no
separate liblint library and the libintl API is provided by glibc.

Tested with `spack external find gettext` on glibc-based Linux and
in musl-based Alpine Linux to make sure that when -lintl is really
needed, it is really used and nothing breaks.
This commit is contained in:
Bernhard Kaindl 2022-12-07 17:39:02 +01:00 committed by GitHub
parent 7f4d71252b
commit d464185bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,9 @@ class Bcache(MakefilePackage):
depends_on("pkgconfig", type="build")
def setup_build_environment(self, env):
env.append_flags("LDFLAGS", "-lintl")
# Add -lintl if provided by gettext, otherwise libintl is provided by the system's glibc:
if any("libintl" in filename for filename in self.libs):
env.append_flags("LDFLAGS", "-lintl")
patch(
"func_crc64.patch",