summary refs log tree commit diff
path: root/pkgs/development/java-modules/jogl/default.nix
blob: 574629d8efd3bb033c993843282e96486d114632 (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
59
60
61
62
63
64
{ stdenv, fetchgit, ant, jdk, git, xorg, udev, libGL, libGLU }:

{
  jogl_2_3_2 =
    let
      version = "2.3.2";

      gluegen-src = fetchgit {
        url = "git://jogamp.org/srv/scm/gluegen.git";
        rev = "v${version}";
        sha256 = "00hybisjwqs88p24dds652bzrwbbmhn2dpx56kp4j6xpadkp33d0";
        fetchSubmodules = true;
      };
    in stdenv.mkDerivation {
      pname = "jogl";
      inherit version;

      src = fetchgit {
        url = "git://jogamp.org/srv/scm/jogl.git";
        rev = "v${version}";
        sha256 = "0msi2gxiqm2yqwkmxqbh521xdrimw1fly20g890r357rcgj8fsn3";
        fetchSubmodules = true;
      };

      postPatch = ''
        find  .  -type f  -name '*.java' \
          -exec sed -i 's@"libGL.so"@"${libGL}/lib/libGL.so"@'    {} \; \
          -exec sed -i 's@"libGLU.so"@"${libGLU}/lib/libGLU.so"@' {} \;
      '';

      nativeBuildInputs = [ jdk ant git ];
      buildInputs = [ udev xorg.libX11 xorg.libXrandr xorg.libXcursor xorg.libXt xorg.libXxf86vm xorg.libXrender ];

      buildPhase = ''
        cp -r ${gluegen-src} $NIX_BUILD_TOP/gluegen
        chmod -R +w $NIX_BUILD_TOP/gluegen
        ( cd ../gluegen/make
          ant )

        ( cd make

          # force way to do disfunctional "ant -Dsetup.addNativeBroadcom=false" and disable dependency on raspberrypi drivers
          # if arm/aarch64 support will be added, this block might be commented out on those platforms
          # on x86 compiling with default "setup.addNativeBroadcom=true" leads to unsatisfied import "vc_dispmanx_resource_delete" in libnewt.so
          cp build-newt.xml build-newt.xml.old
          fgrep -v 'if="setup.addNativeBroadcom"' build-newt.xml.old > build-newt.xml

          ant )
      '';

      installPhase = ''
        mkdir -p $out/share/java
        cp $NIX_BUILD_TOP/gluegen/build/gluegen-rt{,-natives-linux-amd64}.jar $out/share/java/
        cp $NIX_BUILD_TOP/jogl/build/jar/jogl-all{,-natives-linux-amd64}.jar  $out/share/java/
      '';

      meta = with stdenv.lib; {
        description = "Java libraries for 3D Graphics, Multimedia and Processing";
        homepage = "https://jogamp.org/";
        license = licenses.bsd3;
        platforms = [ "x86_64-linux" ];
      };
    };
}