1{lib, stdenv, fetchurl, libGLU, libGL, libglut, glew, libXmu, libXext, libX11
2, qmake, GLUT, fixDarwinDylibNames }:
3
4stdenv.mkDerivation rec {
5 version = "1.6.0";
6 pname = "opencsg";
7 src = fetchurl {
8 url = "http://www.opencsg.org/OpenCSG-${version}.tar.gz";
9 hash = "sha256-v4+4Dj4M4R2H3XjdFaDehy27iXLYf1+Jz/xGHvrUe+g=";
10 };
11
12 nativeBuildInputs = [ qmake ]
13 ++ lib.optional stdenv.isDarwin fixDarwinDylibNames;
14
15 buildInputs = [ glew ]
16 ++ lib.optionals stdenv.isLinux [ libGLU libGL libglut libXmu libXext libX11 ]
17 ++ lib.optional stdenv.isDarwin GLUT;
18
19 doCheck = false;
20
21 preConfigure = ''
22 rm example/Makefile src/Makefile
23 qmakeFlags=("''${qmakeFlags[@]}" "INSTALLDIR=$out")
24 '';
25
26 postInstall = ''
27 install -D copying.txt "$out/share/doc/opencsg/copying.txt"
28 '' + lib.optionalString stdenv.isDarwin ''
29 mkdir -p $out/Applications
30 mv $out/bin/*.app $out/Applications
31 rmdir $out/bin || true
32 '';
33
34 dontWrapQtApps = true;
35
36 postFixup = lib.optionalString stdenv.isDarwin ''
37 app=$out/Applications/opencsgexample.app/Contents/MacOS/opencsgexample
38 install_name_tool -change \
39 $(otool -L $app | awk '/opencsg.+dylib/ { print $1 }') \
40 $(otool -D $out/lib/libopencsg.dylib | tail -n 1) \
41 $app
42 '';
43
44 meta = with lib; {
45 description = "Constructive Solid Geometry library";
46 mainProgram = "opencsgexample";
47 homepage = "http://www.opencsg.org/";
48 platforms = platforms.unix;
49 maintainers = [ maintainers.raskin ];
50 license = licenses.gpl2Plus;
51 };
52}
53