util-linux: fix FreeBSD build

- disable some feature flags
- a needed header is included guarded by __APPLE__. Change it for the
  FreeBSD build.
- the explicit definition of _POSIX_C_SOURCE and _XOPEN_SOURCE to
  rather old versions in-source masks some needed declarations. Remove
  them.
This commit is contained in:
Audrey Dutcher 2024-11-19 13:56:54 -07:00
parent 5a27cc051d
commit 2a2670af0a

View File

@ -53,6 +53,9 @@ stdenv.mkDerivation rec {
'' + lib.optionalString shadowSupport '' '' + lib.optionalString shadowSupport ''
substituteInPlace include/pathnames.h \ substituteInPlace include/pathnames.h \
--replace "/bin/login" "${shadow}/bin/login" --replace "/bin/login" "${shadow}/bin/login"
'' + lib.optionalString stdenv.hostPlatform.isFreeBSD ''
substituteInPlace lib/c_strtod.c --replace-fail __APPLE__ __FreeBSD__
sed -E -i -e '/_POSIX_C_SOURCE/d' -e '/_XOPEN_SOURCE/d' misc-utils/hardlink.c
''; '';
# !!! It would be better to obtain the path to the mount helpers # !!! It would be better to obtain the path to the mount helpers
@ -75,6 +78,12 @@ stdenv.mkDerivation rec {
"SYSCONFSTATICDIR=${placeholder "lib"}/lib" "SYSCONFSTATICDIR=${placeholder "lib"}/lib"
] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
"scanf_cv_type_modifier=ms" "scanf_cv_type_modifier=ms"
++ lib.optionals stdenv.hostPlatform.isFreeBSD [
# These features are all disabled in the freebsd-ports distribution
"--disable-nls"
"--disable-ipcrm"
"--disable-ipcs"
]
; ;
makeFlags = [ makeFlags = [