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