about summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/lablgl/default.nix
blob: 64ace7c44963738d0c2de287ef129ce8841632b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ lib, stdenv, fetchFromGitHub, ocaml, findlib, libGLU, libglut, camlp-streams } :

if lib.versionOlder ocaml.version "4.06"
then throw "lablgl is not available for OCaml ${ocaml.version}"
else

stdenv.mkDerivation rec {
  pname = "ocaml${ocaml.version}-lablgl";
  version = "1.07";

  src = fetchFromGitHub {
    owner = "garrigue";
    repo = "lablgl";
    rev = "v${version}";
    hash = "sha256-GiQKHMn5zHyvDrA2ve12X5YTm3/RZp8tukIqifgVaW4=";
  };

  strictDeps = true;

  nativeBuildInputs = [ ocaml findlib ];
  buildInputs = [ libglut camlp-streams ];
  propagatedBuildInputs = [
    libGLU
  ];

  patches = [ ./META.patch ];

  preConfigure = ''
    mkdir -p $out/bin
    mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs
    cp \
      Makefile.config.${if stdenv.hostPlatform.isDarwin then "osx" else "ex"} \
      Makefile.config
  '';

  makeFlags = [
    "BINDIR=${placeholder "out"}/bin/"
    "INSTALLDIR=${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib/lablgl/"
    "DLLDIR=${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib/stublibs/"
    "XINCLUDES="
    "TKINCLUDES="
    "TKLIBS="
  ];

  buildFlags = [ "lib" "libopt" "glut" "glutopt" ];

  postInstall = ''
    cp ./META $out/lib/ocaml/${ocaml.version}/site-lib/lablgl
  '';

  meta = with lib; {
    description = "OpenGL bindings for ocaml";
    homepage = "http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/lablgl.html";
    license = licenses.gpl2;
    maintainers = with maintainers; [ pSub vbgl ];
    mainProgram = "lablglut";
  };
}