1{ fetchurl, stdenv, makeWrapper, gnum4, texinfo, texLive, automake,
2 enableX11 ? false, xlibsWrapper ? null }:
3
4let
5 version = "9.2";
6 bootstrapFromC = ! (stdenv.isi686 || stdenv.isx86_64);
7
8 arch = if stdenv.isi686 then "-i386"
9 else if stdenv.isx86_64 then "-x86-64"
10 else "";
11in
12stdenv.mkDerivation {
13 name = if enableX11 then "mit-scheme-x11-${version}" else "mit-scheme-${version}";
14
15 # MIT/GNU Scheme is not bootstrappable, so it's recommended to compile from
16 # the platform-specific tarballs, which contain pre-built binaries. It
17 # leads to more efficient code than when building the tarball that contains
18 # generated C code instead of those binaries.
19 src =
20 if stdenv.isi686
21 then fetchurl {
22 url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-${version}-i386.tar.gz";
23 sha256 = "1fmlpnhf5a75db93phajh4ysbdgrgl72v45lk3kznriprl0a7jc6";
24 } else if stdenv.isx86_64
25 then fetchurl {
26 url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-${version}-x86-64.tar.gz";
27 sha256 = "1skzxxhr0iq96bf0j5m7mvf3i4sppfyfa6gpqn34mwgkw1fx8274";
28 } else fetchurl {
29 url = "mirror://gnu/mit-scheme/stable.pkg/${version}/mit-scheme-c-${version}.tar.gz";
30 sha256 = "0w5ib5vsidihb4hb6fma3sp596ykr8izagm57axvgd6lqzwicsjg";
31 };
32
33 buildInputs = if enableX11 then [xlibsWrapper] else [];
34
35 configurePhase =
36 '' (cd src && ./configure)
37 (cd doc && ./configure)
38 '';
39
40 buildPhase =
41 '' cd src
42 ${if bootstrapFromC
43 then "./etc/make-liarc.sh --prefix=$out"
44 else "make compile-microcode"}
45
46 cd ../doc
47
48 # Provide a `texinfo.tex'.
49 export TEXINPUTS="$(echo ${automake}/share/automake-*)"
50 echo "\$TEXINPUTS is \`$TEXINPUTS'"
51 make
52
53 cd ..
54 '';
55
56 installPhase =
57 '' make prefix=$out install -C src
58 make prefix=$out install -C doc
59 '';
60
61 fixupPhase =
62 '' wrapProgram $out/bin/mit-scheme${arch} --set MITSCHEME_LIBRARY_PATH \
63 $out/lib/mit-scheme${arch}
64 '';
65
66 nativeBuildInputs = [ makeWrapper gnum4 texinfo texLive automake ];
67
68 # XXX: The `check' target doesn't exist.
69 doCheck = false;
70
71 meta = with stdenv.lib; {
72 description = "MIT/GNU Scheme, a native code Scheme compiler";
73
74 longDescription =
75 '' MIT/GNU Scheme is an implementation of the Scheme programming
76 language, providing an interpreter, compiler, source-code debugger,
77 integrated Emacs-like editor, and a large runtime library. MIT/GNU
78 Scheme is best suited to programming large applications with a rapid
79 development cycle.
80 '';
81
82 homepage = http://www.gnu.org/software/mit-scheme/;
83
84 license = licenses.gpl2Plus;
85
86 maintainers = [ ];
87
88 # Build fails on Cygwin and Darwin:
89 # <http://article.gmane.org/gmane.lisp.scheme.mit-scheme.devel/489>.
90 platforms = platforms.gnu ++ platforms.freebsd;
91 };
92}