2024-05-31 00:09:31 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
bc,
|
|
|
|
fetchurl,
|
|
|
|
getopt,
|
|
|
|
ksh,
|
|
|
|
pkgsMusl,
|
|
|
|
stdenv,
|
|
|
|
tzdata,
|
2019-06-16 03:51:00 +00:00
|
|
|
}:
|
|
|
|
|
2023-04-21 14:44:32 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "bmake";
|
2024-07-15 01:03:17 +00:00
|
|
|
version = "20240711";
|
2019-06-16 03:51:00 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-05-31 00:09:31 +00:00
|
|
|
url = "https://www.crufty.net/ftp/pub/sjg/bmake-${finalAttrs.version}.tar.gz";
|
2024-07-15 01:03:17 +00:00
|
|
|
hash = "sha256-z+2sCduQhqytVeejoNIkBo90tMARxbZK1x8dhoCHjOA=";
|
2019-06-16 03:51:00 +00:00
|
|
|
};
|
|
|
|
|
2019-06-16 19:24:15 +00:00
|
|
|
patches = [
|
2023-09-17 03:43:03 +00:00
|
|
|
# decouple tests from build phase
|
|
|
|
./002-dont-test-while-installing.diff
|
2021-05-29 10:50:32 +00:00
|
|
|
# preserve PATH from build env in unit tests
|
2023-09-17 03:43:03 +00:00
|
|
|
./003-fix-unexport-env-test.diff
|
2021-07-04 17:16:06 +00:00
|
|
|
# Always enable ksh test since it checks in a impure location /bin/ksh
|
2023-09-17 03:43:03 +00:00
|
|
|
./004-unconditional-ksh-test.diff
|
2019-06-16 19:24:15 +00:00
|
|
|
];
|
2019-06-16 03:51:00 +00:00
|
|
|
|
2024-05-31 00:09:31 +00:00
|
|
|
outputs = [ "out" "man" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ getopt ];
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
bc
|
|
|
|
tzdata
|
|
|
|
] ++ lib.optionals (stdenv.hostPlatform.libc != "musl") [
|
|
|
|
ksh
|
|
|
|
];
|
|
|
|
|
|
|
|
# The generated makefile is a small wrapper for calling ./boot-strap with a
|
|
|
|
# given op. On a case-insensitive filesystem this generated makefile clobbers
|
|
|
|
# a distinct, shipped Makefile and causes infinite recursion during tests
|
|
|
|
# which eventually fail with "fork: Resource temporarily unavailable"
|
|
|
|
configureFlags = [
|
|
|
|
"--without-makefile"
|
|
|
|
];
|
|
|
|
|
|
|
|
# Disabled tests:
|
|
|
|
# * directive-export{,-gmake}: another failure related to TZ variables
|
|
|
|
# * opt-keep-going-indirect: not yet known
|
|
|
|
# * varmod-localtime: musl doesn't support TZDIR and this test relies on
|
|
|
|
# impure, implicit paths
|
|
|
|
env.BROKEN_TESTS = builtins.concatStringsSep " " [
|
|
|
|
"directive-export"
|
|
|
|
"directive-export-gmake"
|
|
|
|
"opt-keep-going-indirect"
|
|
|
|
"varmod-localtime"
|
|
|
|
];
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
2023-07-23 21:18:58 +00:00
|
|
|
# Make tests work with musl
|
|
|
|
# * Disable deptgt-delete_on_error test (alpine does this too)
|
|
|
|
# * Disable shell-ksh test (ksh doesn't compile with musl)
|
|
|
|
# * Fix test failing due to different strerror(3) output for musl and glibc
|
|
|
|
postPatch = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
|
|
|
|
sed -i unit-tests/Makefile \
|
|
|
|
-e '/deptgt-delete_on_error/d' \
|
|
|
|
-e '/shell-ksh/d'
|
|
|
|
substituteInPlace unit-tests/opt-chdir.exp --replace "File name" "Filename"
|
|
|
|
'';
|
|
|
|
|
2021-05-26 13:39:23 +00:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
./boot-strap --prefix=$out -o . op=build
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
./boot-strap --prefix=$out -o . op=install
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-05-29 10:50:32 +00:00
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
./boot-strap -o . op=test
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
2021-04-13 00:10:06 +00:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2024-05-31 00:09:31 +00:00
|
|
|
passthru = {
|
|
|
|
tests = {
|
|
|
|
bmakeMusl = pkgsMusl.bmake;
|
|
|
|
};
|
|
|
|
};
|
2023-07-23 21:18:58 +00:00
|
|
|
|
|
|
|
meta = {
|
2024-05-31 00:09:31 +00:00
|
|
|
homepage = "https://www.crufty.net/help/sjg/bmake.html";
|
2019-06-16 03:51:00 +00:00
|
|
|
description = "Portable version of NetBSD 'make'";
|
2023-07-23 21:18:58 +00:00
|
|
|
license = lib.licenses.bsd3;
|
2023-09-17 03:43:03 +00:00
|
|
|
mainProgram = "bmake";
|
2023-07-23 21:18:58 +00:00
|
|
|
maintainers = with lib.maintainers; [ thoughtpolice AndersonTorres ];
|
|
|
|
platforms = lib.platforms.unix;
|
2024-05-31 00:09:31 +00:00
|
|
|
# requires strip
|
|
|
|
badPlatforms = [ lib.systems.inspect.platformPatterns.isStatic ];
|
2019-06-16 03:51:00 +00:00
|
|
|
};
|
2022-08-07 23:13:20 +00:00
|
|
|
})
|
2022-01-04 15:44:13 +00:00
|
|
|
# TODO: report the quirks and patches to bmake devteam (especially the Musl one)
|
2024-05-31 00:09:31 +00:00
|
|
|
# TODO: investigate static support
|