1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 autoreconfHook,
6 gmp,
7 libffi,
8 fetchpatch,
9}:
10
11stdenv.mkDerivation rec {
12 pname = "polyml";
13 version = "5.7.1";
14
15 postPatch =
16 ''
17 substituteInPlace configure.ac \
18 --replace-fail 'AC_FUNC_ALLOCA' "AC_FUNC_ALLOCA
19 AH_TEMPLATE([_Static_assert])
20 AC_DEFINE([_Static_assert], [static_assert])
21 "
22 ''
23 + lib.optionalString stdenv.hostPlatform.isDarwin ''
24 substituteInPlace configure.ac --replace-fail stdc++ c++
25 '';
26
27 patches = [
28 ./5.7-new-libffi-FFI_SYSV.patch
29
30 # glibc 2.34 compat
31 (fetchpatch {
32 url = "https://src.fedoraproject.org/rpms/polyml/raw/4d8868ca5a1ce3268f212599a321f8011c950496/f/polyml-pthread-stack-min.patch";
33 sha256 = "1h5ihg2sxld9ymrl3f2mpnbn2242ka1fsa0h4gl9h90kndvg6kby";
34 })
35 ];
36
37 buildInputs = [
38 libffi
39 gmp
40 ];
41
42 nativeBuildInputs = [ autoreconfHook ];
43
44 configureFlags = [
45 "--enable-shared"
46 "--with-system-libffi"
47 "--with-gmp"
48 ];
49
50 src = fetchFromGitHub {
51 owner = "polyml";
52 repo = "polyml";
53 rev = "v${version}";
54 sha256 = "0j0wv3ijfrjkfngy7dswm4k1dchk3jak9chl5735dl8yrl8mq755";
55 };
56
57 meta = with lib; {
58 description = "Standard ML compiler and interpreter";
59 longDescription = ''
60 Poly/ML is a full implementation of Standard ML.
61 '';
62 homepage = "https://www.polyml.org/";
63 license = licenses.lgpl21;
64 platforms = with platforms; (linux ++ darwin);
65 maintainers = with maintainers; [ maggesi ];
66 # never built on aarch64-darwin since first introduction in nixpkgs
67 broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;
68 };
69}