2019-06-12 22:18:19 +01:00
|
|
|
|
{ stdenv
|
|
|
|
|
, libglvnd, mesa
|
|
|
|
|
, OpenGL }:
|
|
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
|
inherit (libglvnd) version;
|
|
|
|
|
pname = "libGL";
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
|
|
# On macOS, libglvnd is not supported, so we just use what mesa
|
|
|
|
|
# build. We need to also include OpenGL.framework, and some
|
|
|
|
|
# extra tricks to go along with. We add mesa’s libGLX to support
|
|
|
|
|
# the X extensions to OpenGL.
|
|
|
|
|
buildCommand = if stdenv.hostPlatform.isDarwin then ''
|
|
|
|
|
mkdir -p $out/nix-support $dev
|
|
|
|
|
echo ${OpenGL} >> $out/nix-support/propagated-build-inputs
|
|
|
|
|
ln -s ${mesa.out}/lib $out/lib
|
|
|
|
|
|
|
|
|
|
mkdir -p $dev/lib/pkgconfig $dev/nix-support
|
|
|
|
|
echo "$out" > $dev/nix-support/propagated-build-inputs
|
|
|
|
|
ln -s ${mesa.dev}/include $dev/include
|
|
|
|
|
|
|
|
|
|
cat <<EOF >$dev/lib/pkgconfig/gl.pc
|
|
|
|
|
Name: gl
|
|
|
|
|
Description: gl library
|
|
|
|
|
Version: ${mesa.version}
|
|
|
|
|
Libs: -L${mesa.out}/lib -lGL
|
|
|
|
|
Cflags: -I${mesa.dev}/include
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat <<EOF >$dev/lib/pkgconfig/glesv1_cm.pc
|
|
|
|
|
Name: glesv1_cm
|
|
|
|
|
Description: glesv1_cm library
|
|
|
|
|
Version: ${mesa.version}
|
|
|
|
|
Libs: -L${mesa.out}/lib -lGLESv1_CM
|
|
|
|
|
Cflags: -I${mesa.dev}/include
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat <<EOF >$dev/lib/pkgconfig/glesv2.pc
|
|
|
|
|
Name: glesv2
|
|
|
|
|
Description: glesv2 library
|
|
|
|
|
Version: ${mesa.version}
|
|
|
|
|
Libs: -L${mesa.out}/lib -lGLESv2
|
|
|
|
|
Cflags: -I${mesa.dev}/include
|
|
|
|
|
EOF
|
|
|
|
|
''
|
|
|
|
|
|
|
|
|
|
# Otherwise, setup gl stubs to use libglvnd.
|
|
|
|
|
else ''
|
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
|
ln -s ${libglvnd.out}/lib $out/lib
|
|
|
|
|
|
|
|
|
|
mkdir -p $dev/{,lib/pkgconfig,nix-support}
|
2019-11-07 16:34:34 +00:00
|
|
|
|
echo "$out ${libglvnd} ${libglvnd.dev}" > $dev/nix-support/propagated-build-inputs
|
2021-04-04 15:50:17 +01:00
|
|
|
|
ln -s ${libglvnd.dev}/include $dev/include
|
2019-06-12 22:18:19 +01:00
|
|
|
|
|
|
|
|
|
genPkgConfig() {
|
|
|
|
|
local name="$1"
|
|
|
|
|
local lib="$2"
|
|
|
|
|
|
|
|
|
|
cat <<EOF >$dev/lib/pkgconfig/$name.pc
|
|
|
|
|
Name: $name
|
|
|
|
|
Description: $lib library
|
2021-04-04 15:50:17 +01:00
|
|
|
|
Version: ${libglvnd.version}
|
2019-06-12 22:18:19 +01:00
|
|
|
|
Libs: -L${libglvnd.out}/lib -l$lib
|
2021-04-04 15:50:17 +01:00
|
|
|
|
Cflags: -I${libglvnd.dev}/include
|
2019-06-12 22:18:19 +01:00
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
genPkgConfig gl GL
|
|
|
|
|
genPkgConfig egl EGL
|
|
|
|
|
genPkgConfig glesv1_cm GLESv1_CM
|
|
|
|
|
genPkgConfig glesv2 GLESv2
|
|
|
|
|
'';
|
|
|
|
|
}
|