@ -1,13 +1,12 @@
{ stdenv , fetchurl , fetchpatch , pkgconfig , intltool , autoreconfHook , substituteAll
, file , expat , libdrm , xorg , wayland , libudev , llvmPackages , libffi , libomxil-bellagio
, libvdpau , libelf , libva
, grsecEnabled
{ stdenv , fetchurl , fetchpatch
, pkgconfig , intltool , autoreconfHook , substituteAll
, file , expat , libdrm , xorg , wayland , libudev
, llvmPackages , libffi , libomxil-bellagio , libva
, libelf , libvdpau , python
, grsecEnabled ? false
, enableTextureFloats ? false # Texture floats are patented, see docs/patents.txt
} :
if ! stdenv . lib . lists . elem stdenv . system stdenv . lib . platforms . mesaPlatforms then
throw " u n s u p p o r t e d p l a t f o r m f o r M e s a "
else
/* * P a c k a g i n g d e s i g n :
- The basic mesa ( $ out ) contains headers and libraries ( GLU is in mesa_glu now ) .
@ -20,11 +19,15 @@ else
- libOSMesa is in $ osmesa ( ~ 4 MB )
* /
with { inherit ( stdenv . lib ) optional optionalString ; } ;
with stdenv . lib ;
if ! lists . elem stdenv . system platforms . mesaPlatforms then
throw " u n s u p p o r t e d p l a t f o r m f o r M e s a "
else
let
version = " 1 1 . 2 . 2 " ;
# this is the default search path for DRI drivers
version = " 1 2 . 0 . 1 " ;
branch = head ( splitString " . " version ) ;
driverLink = " / r u n / o p e n g l - d r i v e r " + optionalString stdenv . isi686 " - 3 2 " ;
in
@ -34,20 +37,20 @@ stdenv.mkDerivation {
src = fetchurl {
urls = [
" f t p : / / f t p . f r e e d e s k t o p . o r g / p u b / m e s a / ${ version } / m e s a - ${ version } . t a r . x z "
( with stdenv . lib ; '' f t p : / / f t p . f r e e d e s k t o p . o r g / p u b / m e s a / o l d e r - v e r s i o n s / ''
+ head ( splitString " . " version ) + '' . x / ${ version } / m e s a - ${ version } . t a r . x z '' )
" f t p : / / f t p . f r e e d e s k t o p . o r g / p u b / m e s a / o l d e r - v e r s i o n s / ${ branch } . x / ${ version } / m e s a - ${ version } . t a r . x z "
" h t t p s : / / l a u n c h p a d . n e t / m e s a / t r u n k / ${ version } / + d o w n l o a d / m e s a - ${ version } . t a r . x z "
] ;
sha256 = " 4 0 e 1 4 8 8 1 2 3 8 8 e c 7 c 6 d 7 b 6 6 5 7 d 5 a 1 6 e 2 e 8 d a b b a 8 b 9 7 d d f c e e a 5 1 9 7 9 4 7 6 4 7 b d f b 4 " ;
sha256 = " 1 2 b 3 i 5 9 x d n 2 i n 2 h c h r k g h 4 f w i j 8 z h z n i b x 9 7 6 l 3 p d j 3 q k y v l z c m s " ;
} ;
prePatch = " p a t c h S h e b a n g s . " ;
# TODO:
# revive ./dricore-gallium.patch when it gets ported (from Ubuntu), as it saved
# ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
patches = [
./glx_ro_text_segm.patch # fix for grsecurity/PaX
./symlink-drivers.patch
# TODO: revive ./dricore-gallium.patch when it gets ported (from Ubuntu),
# as it saved ~35 MB in $drivers; watch https://launchpad.net/ubuntu/+source/mesa/+changelog
] ++ optional stdenv . isLinux
( substituteAll {
src = ./dlopen-absolute-paths.diff ;
@ -61,61 +64,59 @@ stdenv.mkDerivation {
outputs = [ " d e v " " o u t " " d r i v e r s " " o s m e s a " ] ;
# TODO: Figure out how to enable opencl without having a runtime dependency on clang
configureFlags = [
" - - s y s c o n f d i r = / e t c "
" - - l o c a l s t a t e d i r = / v a r "
" - - w i t h - d r i - d r i v e r d i r = $ ( d r i v e r s ) / l i b / d r i "
" - - w i t h - d r i - s e a r c h p a t h = ${ driverLink } / l i b / d r i "
" - - w i t h - e g l - p l a t f o r m s = x 1 1 , w a y l a n d , d r m "
( optionalString ( stdenv . system != " a r m v 7 l - l i n u x " )
" - - w i t h - g a l l i u m - d r i v e r s = s v g a , i 9 1 5 , i l o , r 3 0 0 , r 6 0 0 , r a d e o n s i , n o u v e a u , f r e e d r e n o , s w r a s t " )
( optionalString ( stdenv . system != " a r m v 7 l - l i n u x " )
" - - w i t h - d r i - d r i v e r s = i 9 1 5 , i 9 6 5 , n o u v e a u , r a d e o n , r 2 0 0 , s w r a s t " )
( enableFeature enableTextureFloats " t e x t u r e - f l o a t " )
( enableFeature grsecEnabled " g l x - r t s " )
( enableFeature stdenv . isLinux " d r i 3 " )
( enableFeature stdenv . isLinux " n i n e " ) # Direct3D in Wine
" - - e n a b l e - d r i "
" - - e n a b l e - d r i g l x - d i r e c t "
" - - e n a b l e - g l e s 1 "
" - - e n a b l e - g l e s 2 "
" - - e n a b l e - d r i "
] ++ optional stdenv . isLinux " - - e n a b l e - d r i 3 "
++ [
" - - e n a b l e - g l x "
" - - e n a b l e - g l x - t l s "
" - - e n a b l e - g a l l i u m - o s m e s a " # used by wine
" - - e n a b l e - g a l l i u m - l l v m "
" - - e n a b l e - e g l "
" - - e n a b l e - x a " # used in vmware driver
" - - e n a b l e - g b m "
] ++ optional stdenv . isLinux " - - e n a b l e - n i n e " # Direct3D in Wine
++ [
" - - e n a b l e - x v m c "
" - - e n a b l e - v d p a u "
#"--enable-omx"
#"--enable-va"
# TODO: Figure out how to enable opencl without having a runtime dependency on clang
" - - d i s a b l e - o p e n c l "
( if " a r m v 7 l - l i n u x " == stdenv . system
then null
else " - - w i t h - g a l l i u m - d r i v e r s = s v g a , i 9 1 5 , i l o , r 3 0 0 , r 6 0 0 , r a d e o n s i , n o u v e a u , f r e e d r e n o , s w r a s t " )
" - - e n a b l e - s h a r e d - g l a p i "
" - - e n a b l e - s y s f s "
" - - e n a b l e - d r i g l x - d i r e c t " # seems enabled anyway
" - - e n a b l e - g l x - t l s "
( if " a r m v 7 l - l i n u x " == stdenv . system
then " - - w i t h - d r i - d r i v e r s = "
else " - - w i t h - d r i - d r i v e r s = i 9 1 5 , i 9 6 5 , n o u v e a u , r a d e o n , r 2 0 0 , s w r a s t " )
" - - w i t h - e g l - p l a t f o r m s = x 1 1 , w a y l a n d , d r m "
" - - e n a b l e - g a l l i u m - l l v m "
" - - e n a b l e - l l v m - s h a r e d - l i b s "
] ++ optional enableTextureFloats " - - e n a b l e - t e x t u r e - f l o a t "
++ optional grsecEnabled " - - e n a b l e - g l x - r t s " ; # slight performance degradation, enable only for grsec
" - - e n a b l e - o m x "
" - - e n a b l e - v a "
" - - d i s a b l e - o p e n c l "
] ;
nativeBuildInputs = [ pkgconfig file ] ;
propagatedBuildInputs = with xorg ; [ libXdamage libXxf86vm ]
propagatedBuildInputs = with xorg ;
[ libXdamage libXxf86vm ]
++ optional stdenv . isLinux libdrm ;
buildInputs = with xorg ; [
autoreconfHook intltool expat llvmPackages . llvm
glproto dri2proto dri3proto presentproto
libX11 libXext libxcb libXt libXfixes libxshmfence
libffi wayland libvdpau libelf libXvMC /* l i b o m x i l - b e l l a g i o l i b v a */
libffi wayland libvdpau libelf libXvMC
libomxil-bellagio libva libpthreadstubs
( python . withPackages ( ps : [ ps . Mako ] ) )
] ++ optional stdenv . isLinux libudev ;
enableParallelBuilding = true ;
doCheck = false ;
@ -124,42 +125,42 @@ stdenv.mkDerivation {
" l o c a l s t a t e d i r = \$ { T M P D I R } "
] ;
# move gallium-related stuff to $drivers, so $out doesn't depend on LLVM;
# also move libOSMesa to $osmesa, as it's relatively big
# ToDo: probably not all .la files are completely fixed, but it shouldn't matter
postInstall = with stdenv . lib ; ''
mv - t " $ d r i v e r s / l i b / " \
$ out/lib/libXvMC * \
$ out/lib/d3d \
$ out/lib/vdpau \
$ out/lib/libxatracker *
# TODO: probably not all .la files are completely fixed, but it shouldn't matter;
postInstall = ''
# move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
mv - t " $ d r i v e r s / l i b / " \
$ out/lib/libXvMC * \
$ out/lib/d3d \
$ out/lib/vdpau \
$ out/lib/bellagio \
$ out/lib/libxatracker * \
mv $ out/lib/dri /* $ d r i v e r s / l i b / d r i
# move libOSMesa to $osmesa, as it's relatively big
mkdir - p { $ osmesa , $ drivers } /lib /
mv - t $ osmesa/lib / \
$ out/lib/libOSMesa *
mv - t $ osmesa/lib / $ out/lib/libOSMesa *
'' + / * n o w f i x r e f e r e n c e s i n . l a f i l e s * / ''
sed " / ^ l i b d i r = / s , $ o u t , $ o s m e s a , " - i \
$ osmesa/lib/libOSMesa * . la
# now fix references in .la files
sed " / ^ l i b d i r = / s , $ o u t , $ o s m e s a , " - i $ osmesa/lib/libOSMesa * . la
'' + / * s e t t h e d e fa ul t s ea rc h p a t h f o r D R I d r i v e rs ; us e d e . g . b y X s e r v e r * / ''
# s et the defa ul t s ea rc h pa th for DRI drivers ; us ed e.g. by X s erver
substituteInPlace " $ d e v / l i b / p k g c o n f i g / d r i . p c " - - replace ' $ ( drivers ) ' " ${ driverLink } "
'' ;
#ToDo: @vcunat isn't sure if drirc will be found when in $out/etc/, but it doesn't seem important ATM */
postFixup =
# TODO:
# @vcunat isn't sure if drirc will be found when in $out/etc/;
# check $out doesn't depend on llvm: builder failures are ignored
# for some reason grep -qv '${llvmPackages.llvm}' -R "$out";
postFixup = ''
# add RPATH so the drivers can find the moved libgallium and libdricore9
# moved here to avoid problems with stripping patchelfed files
''
for lib in $ drivers/lib /* . s o * $ d r i v e r s / l i b / */ * . so * ; do
if [ [ ! - L " $ l i b " ] ] ; then
patchelf - - set-rpath " $ ( p a t c h e l f - - p r i n t - r p a t h $ l i b ) : $ d r i v e r s / l i b " " $ l i b "
fi
done
'' ;
# ToDo + /* check $out doesn't depend on llvm */ ''
# builder failures are ignored for some reason
# grep -qv '${llvmPackages.llvm}' -R "$out"
passthru = { inherit libdrm version driverLink ; } ;