anchor.diff:    '';
   
     outputs = ["out" "drivers"];
  -  preferLocalBuild = true; # see https://github.com/NixOS/nix/issues/118
   
     preConfigure = "./autogen.sh";
   
  
positive.code:   ]
      ++ optional enableR600LlvmCompiler "--enable-r600-llvm-compiler" # complains about R600 missing in LLVM
      ++ optional enableTextureFloats "--enable-texture-float"
      ++ optionals extraFeatures [
        "--enable-gles1" "--enable-gles2"
        "--enable-xa"
        "--enable-osmesa"
        "--enable-openvg" "--enable-gallium-egl" # not needed for EGL in Gallium, but OpenVG might be useful
        #"--enable-xvmc" # tests segfault with 9.1.{1,2}
        "--enable-vdpau"
        #"--enable-opencl" # ToDo: opencl seems to need libclc for clover
      ];
  
negative.code:     autoconf automake libtool intltool expat libxml2Python udev llvm
      libdrm libXxf86vm libXfixes libXdamage glproto dri2proto libX11 libXext libxcb libXt
      libffi wayland
    ] ++ stdenv.lib.optionals enableExtraFeatures [ /*libXvMC*/ libvdpau ];
  
    enableParallelBuilding = true;
    doCheck = true;
  
    # move gallium-related stuff to $drivers, so $out doesn't depend on LLVM
    # ToDo: probably not all .la files are completely fixed, but it shouldn't matter
    postInstall = with stdenv.lib; ''
      mv -t "$drivers/lib/" \
    '' + optionalString enableExtraFeatures ''
        `#$out/lib/libXvMC*` \
        $out/lib/vdpau \
        $out/lib/libOSMesa* \
        $out/lib/gbm $out/lib/libgbm* \
        $out/lib/gallium-pipe \
    '' + ''
        $out/lib/libdricore* \
        $out/lib/libgallium* \
        $out/lib/libxatracker*
  
    '' + /* now fix references in .la files */ ''
      sed "/^libdir=/s,$out,$drivers," -i \
    '' + optionalString enableExtraFeatures ''
        `#$drivers/lib/libXvMC*.la` \
        $drivers/lib/vdpau/*.la \
        $drivers/lib/libOSMesa*.la \
        $drivers/lib/gallium-pipe/*.la \
    '' + ''
        $drivers/lib/libgallium.la \
        $drivers/lib/libdricore*.la
  
      sed "s,$out\(/lib/\(libdricore[0-9\.]*\|libgallium\).la\),$drivers\1,g" \
        -i $drivers/lib/*.la $drivers/lib/*/*.la
  
    '' + /* work around bug #529, but maybe $drivers should also be patchelf-ed */ ''
      find $drivers/ -type f -executable -print0 | xargs -0 strip -S || true
  
    '' + /* add RPATH so the drivers can find the moved libgallium and libdricore9 */ ''
      for lib in $drivers/lib/*.so* $drivers/lib/*/*.so*; do
        if [[ ! -L "$lib" ]]; then
  