1{ coreutils, lib, stdenv, fetchgit, ant, jdk8, jdk11, git, xorg, udev, libGL, libGLU, mesa, xmlstarlet }:
2
3{
4 jogl_2_4_0 =
5 let
6 version = "2.4.0";
7
8 gluegen-src = fetchgit {
9 url = "git://jogamp.org/srv/scm/gluegen.git";
10 rev = "v${version}";
11 hash = "sha256-qQzq7v2vMFeia6gXaNHS3AbOp9HhDRgISp7P++CKErA=";
12 fetchSubmodules = true;
13 };
14 jogl-src = fetchgit {
15 url = "git://jogamp.org/srv/scm/jogl.git";
16 rev = "v${version}";
17 hash = "sha256-PHDq7uFEQfJ2P0eXPUi0DGFR1ob/n5a68otgzpFnfzQ=";
18 fetchSubmodules = true;
19 };
20 in
21 stdenv.mkDerivation {
22 pname = "jogl";
23 inherit version;
24
25 srcs = [ gluegen-src jogl-src ];
26 sourceRoot = ".";
27
28 unpackCmd = "cp -r $curSrc \${curSrc##*-}";
29
30 nativeBuildInputs = [ ant jdk11 git xmlstarlet ];
31 buildInputs = [ udev xorg.libX11 xorg.libXrandr xorg.libXcursor xorg.libXi xorg.libXt xorg.libXxf86vm xorg.libXrender mesa ];
32
33 # Workaround build failure on -fno-common toolchains:
34 # ld: ../obj/Bindingtest1p1Impl_JNI.o:(.bss+0x8): multiple definition of
35 # `unsigned_size_t_1'; ../obj/TK_Surface_JNI.o:(.bss+0x8): first defined here
36 NIX_CFLAGS_COMPILE = "-fcommon"; # copied from 2.3.2, is this still needed?
37
38 buildPhase = ''
39 ( cd gluegen/make
40 substituteInPlace ../src/java/com/jogamp/common/util/IOUtil.java --replace '#!/bin/true' '#!${coreutils}/bin/true'
41
42 # set timestamp of files in jar to a fixed point in time
43 xmlstarlet ed --inplace \
44 --append //jar --type attr -n modificationtime --value 1980-01-01T00:00Z \
45 build.xml gluegen-cpptasks-base.xml
46
47 ant -Dtarget.sourcelevel=8 -Dtarget.targetlevel=8 -Dtarget.rt.jar='null.jar' )
48
49 ( cd jogl/make
50
51 # force way to do disfunctional "ant -Dsetup.addNativeBroadcom=false" and disable dependency on raspberrypi drivers
52 # if arm/aarch64 support will be added, this block might be commented out on those platforms
53 # on x86 compiling with default "setup.addNativeBroadcom=true" leads to unsatisfied import "vc_dispmanx_resource_delete" in libnewt.so
54 xmlstarlet ed --inplace --delete '//*[@if="setup.addNativeBroadcom"]' build-newt.xml
55
56 # set timestamp of files in jar to a fixed point in time
57 xmlstarlet ed --inplace \
58 --append //jar --type attr -n modificationtime --value 1980-01-01T00:00Z \
59 build.xml build-nativewindow.xml build-jogl.xml
60
61 ant -Dtarget.sourcelevel=8 -Dtarget.targetlevel=8 -Dtarget.rt.jar='null.jar' )
62 '';
63
64 installPhase = ''
65 mkdir -p $out/share/java
66 cp -v $NIX_BUILD_TOP/gluegen/build/gluegen-rt{,-natives-linux-amd64}.jar $out/share/java/
67 cp -v $NIX_BUILD_TOP/jogl/build/jar/jogl-all{,-natives-linux-amd64}.jar $out/share/java/
68 cp -v $NIX_BUILD_TOP/jogl/build/nativewindow/nativewindow{,-awt,-natives-linux-amd64,-os-drm,-os-x11}.jar $out/share/java/
69 '';
70
71 meta = with lib; {
72 description = "Java libraries for 3D Graphics, Multimedia and Processing";
73 homepage = "https://jogamp.org/";
74 license = licenses.bsd3;
75 platforms = [ "x86_64-linux" ];
76 };
77 };
78
79 jogl_2_3_2 =
80 let
81 version = "2.3.2";
82
83 gluegen-src = fetchgit {
84 url = "git://jogamp.org/srv/scm/gluegen.git";
85 rev = "v${version}";
86 sha256 = "00hybisjwqs88p24dds652bzrwbbmhn2dpx56kp4j6xpadkp33d0";
87 fetchSubmodules = true;
88 };
89 in stdenv.mkDerivation {
90 pname = "jogl";
91 inherit version;
92
93 src = fetchgit {
94 url = "git://jogamp.org/srv/scm/jogl.git";
95 rev = "v${version}";
96 sha256 = "0msi2gxiqm2yqwkmxqbh521xdrimw1fly20g890r357rcgj8fsn3";
97 fetchSubmodules = true;
98 };
99
100 postPatch = ''
101 find . -type f -name '*.java' \
102 -exec sed -i 's@"libGL.so"@"${libGL}/lib/libGL.so"@' {} \; \
103 -exec sed -i 's@"libGLU.so"@"${libGLU}/lib/libGLU.so"@' {} \;
104 '';
105
106 # TODO: upgrade to jdk https://github.com/NixOS/nixpkgs/pull/89731
107 nativeBuildInputs = [ jdk8 ant git ];
108 buildInputs = [ udev xorg.libX11 xorg.libXrandr xorg.libXcursor xorg.libXt xorg.libXxf86vm xorg.libXrender ];
109
110 # Workaround build failure on -fno-common toolchains:
111 # ld: ../obj/Bindingtest1p1Impl_JNI.o:(.bss+0x8): multiple definition of
112 # `unsigned_size_t_1'; ../obj/TK_Surface_JNI.o:(.bss+0x8): first defined here
113 env.NIX_CFLAGS_COMPILE = "-fcommon";
114
115 buildPhase = ''
116 cp -r ${gluegen-src} $NIX_BUILD_TOP/gluegen
117 chmod -R +w $NIX_BUILD_TOP/gluegen
118 ( cd ../gluegen/make
119 ant )
120
121 ( cd make
122
123 # force way to do disfunctional "ant -Dsetup.addNativeBroadcom=false" and disable dependency on raspberrypi drivers
124 # if arm/aarch64 support will be added, this block might be commented out on those platforms
125 # on x86 compiling with default "setup.addNativeBroadcom=true" leads to unsatisfied import "vc_dispmanx_resource_delete" in libnewt.so
126 cp build-newt.xml build-newt.xml.old
127 fgrep -v 'if="setup.addNativeBroadcom"' build-newt.xml.old > build-newt.xml
128
129 ant )
130 '';
131
132 installPhase = ''
133 mkdir -p $out/share/java
134 cp $NIX_BUILD_TOP/gluegen/build/gluegen-rt{,-natives-linux-amd64}.jar $out/share/java/
135 cp $NIX_BUILD_TOP/jogl/build/jar/jogl-all{,-natives-linux-amd64}.jar $out/share/java/
136 '';
137
138 meta = with lib; {
139 description = "Java libraries for 3D Graphics, Multimedia and Processing";
140 homepage = "https://jogamp.org/";
141 license = licenses.bsd3;
142 platforms = [ "x86_64-linux" ];
143 };
144 };
145}