2021-02-05 17:12:51 +00:00
|
|
|
|
{ lib, stdenv, fetchurl, makeWrapper, darwin, bootstrap-chicken ? null }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
version = "4.13.0";
|
|
|
|
|
platform = with stdenv;
|
|
|
|
|
if isDarwin then "macosx"
|
|
|
|
|
else if isCygwin then "cygwin"
|
|
|
|
|
else if (isFreeBSD || isOpenBSD) then "bsd"
|
|
|
|
|
else if isSunOS then "solaris"
|
|
|
|
|
else "linux"; # Should be a sane default
|
|
|
|
|
in
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
|
pname = "chicken";
|
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
|
|
binaryVersion = 8;
|
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
|
url = "https://code.call-cc.org/releases/${version}/chicken-${version}.tar.gz";
|
|
|
|
|
sha256 = "0hvckhi5gfny3mlva6d7y9pmx7cbwvq0r7mk11k3sdiik9hlkmdd";
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
|
|
|
|
# There is not enough space in the load command to accomodate a full path to the store,
|
|
|
|
|
# so use `@executable_path` to specify a relative path to chicken’s lib folder.
|
|
|
|
|
sed -e '/POSTINSTALL_PROGRAM_FLAGS = /{s|$(LIBDIR)|@executable_path/../lib|}' \
|
|
|
|
|
-i Makefile.macosx
|
|
|
|
|
'';
|
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
|
setupHook = lib.optional (bootstrap-chicken != null) ./setup-hook.sh;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
|
# -fno-strict-overflow is not a supported argument in clang on darwin
|
|
|
|
|
hardeningDisable = lib.optionals stdenv.isDarwin ["strictoverflow"];
|
|
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
|
"PLATFORM=${platform}" "PREFIX=$(out)"
|
|
|
|
|
"VARDIR=$(out)/var/lib"
|
|
|
|
|
] ++ (lib.optionals stdenv.isDarwin [
|
|
|
|
|
"XCODE_TOOL_PATH=${darwin.binutils.bintools}/bin"
|
|
|
|
|
"C_COMPILER=$(CC)"
|
2023-11-16 04:20:00 +00:00
|
|
|
|
"POSTINSTALL_PROGRAM=${stdenv.cc.targetPrefix}install_name_tool"
|
2020-11-19 00:13:47 +00:00
|
|
|
|
]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
# We need a bootstrap-chicken to regenerate the c-files after
|
|
|
|
|
# applying a patch to add support for CHICKEN_REPOSITORY_EXTRA
|
2020-11-19 00:13:47 +00:00
|
|
|
|
patches = lib.optionals (bootstrap-chicken != null) [
|
2020-04-24 23:36:52 +00:00
|
|
|
|
./0001-Introduce-CHICKEN_REPOSITORY_EXTRA.patch
|
|
|
|
|
];
|
|
|
|
|
|
2022-08-21 13:32:41 +00:00
|
|
|
|
nativeBuildInputs = [
|
2020-04-24 23:36:52 +00:00
|
|
|
|
makeWrapper
|
2022-10-30 15:09:59 +00:00
|
|
|
|
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
|
|
|
darwin.autoSignDarwinBinariesHook
|
2022-08-21 13:32:41 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
buildInputs = lib.optionals (bootstrap-chicken != null) [
|
2020-04-24 23:36:52 +00:00
|
|
|
|
bootstrap-chicken
|
2022-08-21 13:32:41 +00:00
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2020-11-19 00:13:47 +00:00
|
|
|
|
preBuild = lib.optionalString (bootstrap-chicken != null) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# Backup the build* files - those are generated from hostname,
|
|
|
|
|
# git-tag, etc. and we don't need/want that
|
|
|
|
|
mkdir -p build-backup
|
|
|
|
|
mv buildid buildbranch buildtag.h build-backup
|
|
|
|
|
|
|
|
|
|
# Regenerate eval.c after the patch
|
2020-11-19 00:13:47 +00:00
|
|
|
|
make spotless $makeFlags
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
mv build-backup/* .
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
|
for f in $out/bin/*
|
|
|
|
|
do
|
|
|
|
|
wrapProgram $f \
|
|
|
|
|
--prefix PATH : ${stdenv.cc}/bin
|
|
|
|
|
done
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# TODO: Assert csi -R files -p '(pathname-file (repository-path))' == binaryVersion
|
|
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
|
homepage = "http://www.call-cc.org/";
|
2021-02-05 17:12:51 +00:00
|
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
|
maintainers = with lib.maintainers; [ corngood ];
|
|
|
|
|
platforms = lib.platforms.linux ++ lib.platforms.darwin; # Maybe other Unix
|
2020-04-24 23:36:52 +00:00
|
|
|
|
description = "A portable compiler for the Scheme programming language";
|
|
|
|
|
longDescription = ''
|
|
|
|
|
CHICKEN is a compiler for the Scheme programming language.
|
|
|
|
|
CHICKEN produces portable and efficient C, supports almost all
|
|
|
|
|
of the R5RS Scheme language standard, and includes many
|
|
|
|
|
enhancements and extensions. CHICKEN runs on Linux, macOS,
|
|
|
|
|
Windows, and many Unix flavours.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
}
|