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