Merge pull request #182017 from rrbutani/tinyscheme-darwin
tinyscheme: fix build on macOS
This commit is contained in:
commit
1228cdddc6
@ -0,0 +1,24 @@
|
||||
diff --git a/scheme.c b/scheme.c
|
||||
index 6186ef0..5a43592 100644
|
||||
--- a/scheme.c
|
||||
+++ b/scheme.c
|
||||
@@ -4949,19 +4949,7 @@ pointer scheme_eval(scheme *sc, pointer obj)
|
||||
|
||||
#if STANDALONE
|
||||
|
||||
-#if defined(__APPLE__) && !defined (OSX)
|
||||
-int main()
|
||||
-{
|
||||
- extern MacTS_main(int argc, char **argv);
|
||||
- char** argv;
|
||||
- int argc = ccommand(&argv);
|
||||
- MacTS_main(argc,argv);
|
||||
- return 0;
|
||||
-}
|
||||
-int MacTS_main(int argc, char **argv) {
|
||||
-#else
|
||||
int main(int argc, char **argv) {
|
||||
-#endif
|
||||
scheme sc;
|
||||
FILE *fin;
|
||||
char *file_name=InitFile;
|
@ -0,0 +1,26 @@
|
||||
diff --git a/makefile b/makefile
|
||||
index aeb2fcd..4c111a1 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -18,7 +18,7 @@
|
||||
#AR= echo
|
||||
|
||||
# Unix, generally
|
||||
-CC = gcc -fpic -pedantic
|
||||
+CC := $(CC) -fpic -pedantic
|
||||
DEBUG=-g -Wall -Wno-char-subscripts -O
|
||||
Osuf=o
|
||||
SOsuf=so
|
||||
@@ -27,10 +27,10 @@ EXE_EXT=
|
||||
LIBPREFIX=lib
|
||||
OUT = -o $@
|
||||
RM= -rm -f
|
||||
-AR= ar crs
|
||||
+AR := $(AR) crs
|
||||
|
||||
# Linux
|
||||
-LD = gcc
|
||||
+LD := $(CC)
|
||||
LDFLAGS = -shared
|
||||
DEBUG=-g -Wno-char-subscripts -O
|
||||
SYS_LIBS= -ldl -lm
|
@ -0,0 +1,13 @@
|
||||
diff --git a/makefile b/makefile
|
||||
index 4c111a1..8d9e02e 100644
|
||||
--- a/makefile
|
||||
+++ b/makefile
|
||||
@@ -21,7 +21,7 @@
|
||||
CC := $(CC) -fpic -pedantic
|
||||
DEBUG=-g -Wall -Wno-char-subscripts -O
|
||||
Osuf=o
|
||||
-SOsuf=so
|
||||
+SOsuf=dylib
|
||||
LIBsuf=a
|
||||
EXE_EXT=
|
||||
LIBPREFIX=lib
|
@ -1,4 +1,10 @@
|
||||
{ lib, stdenv, fetchurl }:
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchurl
|
||||
, dos2unix
|
||||
, runCommand
|
||||
, tinyscheme
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "tinyscheme";
|
||||
@ -9,27 +15,68 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "sha256-F7Cxv/0i89SdWDPiKhILM5A50s/aC0bW/FHdLwG0B60=";
|
||||
};
|
||||
|
||||
patchPhase = ''
|
||||
nativeBuildInputs = [ dos2unix ];
|
||||
|
||||
prePatch = "dos2unix makefile";
|
||||
patches = [
|
||||
# The alternate macOS main makes use of `ccommand` which seems to be
|
||||
# `MetroWerks CodeWarrier` specific:
|
||||
# https://ptgmedia.pearsoncmg.com/imprint_downloads/informit/downloads/9780201703535/macfix.html
|
||||
#
|
||||
# In any case, this is not needed to build on macOS.
|
||||
./01-remove-macOS-main.patch
|
||||
|
||||
# We want to have the makefile pick up $CC, etc. so that we don't have
|
||||
# to unnecessarily tie this package to the GCC stdenv.
|
||||
./02-use-toolchain-env-vars.patch
|
||||
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||
# On macOS the library suffix is .dylib:
|
||||
./03-macOS-SOsuf.patch
|
||||
];
|
||||
postPatch = ''
|
||||
substituteInPlace scheme.c --replace "init.scm" "$out/lib/init.scm"
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/lib
|
||||
cp init.scm $out/lib
|
||||
cp libtinyscheme* $out/lib
|
||||
cp scheme $out/bin/tinyscheme
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
# Checks that the program can run and exit:
|
||||
simple = runCommand "${pname}-simple-test" {} ''
|
||||
${tinyscheme}/bin/tinyscheme <<<"(quit 0)"
|
||||
echo "success" > $out
|
||||
'';
|
||||
fileIo = runCommand "${pname}-file-io-test" {} ''
|
||||
${tinyscheme}/bin/tinyscheme <<EOF
|
||||
(call-with-output-file "$out"
|
||||
(lambda (p)
|
||||
(begin
|
||||
(write "success!" p)
|
||||
(newline p)
|
||||
)))
|
||||
EOF
|
||||
'';
|
||||
helpText = runCommand "${pname}-help-text-test" {} ''
|
||||
${tinyscheme}/bin/tinyscheme '-?' | tee > $out || :
|
||||
[[ "$(cat $out)" =~ ^Usage: ]]
|
||||
'';
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
broken = stdenv.isDarwin;
|
||||
description = "Lightweight Scheme implementation";
|
||||
longDescription = ''
|
||||
TinyScheme is a lightweight Scheme interpreter that implements as large a
|
||||
subset of R5RS as was possible without getting very large and complicated.
|
||||
'';
|
||||
homepage = "http://tinyscheme.sourceforge.net/";
|
||||
changelog = "http://tinyscheme.sourceforge.net/CHANGES";
|
||||
license = licenses.bsdOriginal;
|
||||
mainProgram = pname;
|
||||
maintainers = [ maintainers.ebzzry ];
|
||||
platforms = platforms.unix;
|
||||
badPlatforms = [ "aarch64-darwin" ];
|
||||
};
|
||||
}
|
||||
|
@ -14779,9 +14779,7 @@ with pkgs;
|
||||
wasi-libc = pkgsCross.wasi32.wasilibc;
|
||||
};
|
||||
|
||||
tinyscheme = callPackage ../development/interpreters/tinyscheme {
|
||||
stdenv = gccStdenv;
|
||||
};
|
||||
tinyscheme = callPackage ../development/interpreters/tinyscheme { };
|
||||
|
||||
bupc = callPackage ../development/compilers/bupc { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user