anchor.diff:    patches = optional tolerateCpuTimingInaccuracy ./disable-timing-accuracy-check.patch;
   
     # Configure outside of the source directory.
  -  preConfigure = '' mkdir build; cd build; configureScript=../configure; '';
  +  preConfigure = ''
  +    mkdir build
  +    cd build
  +    configureScript=../configure
  +  '';
   
     # * -fPIC is passed even in non-shared builds so that the ATLAS code can be
     #   used to inside of shared libraries, like Octave does.
     #
     # * -t 0 disables use of multi-threading. It's not quite clear what the
     #   consequences of that setting are and whether it's necessary or not.
  -  configureFlags = "-Fa alg -fPIC -t 0 ${cpuConfig}" + optionalString shared " --shared";
  +  configureFlags = [
  +    "-Fa alg"
  +    "-fPIC"
  +    "-t ${threads}"
  +    cpuConfig
  +  ] ++ optional shared "--shared";
  +
  +  postConfigure = ''
  +    if [[ -n "${cacheEdge}" ]]; then
  +      echo '#define CacheEdge ${cacheEdge}' >> include/atlas_cacheedge.h
  +      echo '#define CacheEdge ${cacheEdge}' >> include/atlas_tcacheedge.h
  +    fi
  +  '';
   
     doCheck = true;
  +
  +  postInstall = ''
  +    # Avoid name collision with the real lapack (ATLAS only builds a partial
  +    # lapack).
  +    mv $out/lib/liblapack.a $out/lib/liblapack_atlas.a
  +  '';
   
     meta = {
       homepage = "http://math-atlas.sourceforge.net/";
  
positive.code: # cannot execute.
  #
  # To avoid these issues, the build is configured using the 'cpuConfig'
  # parameter as follows:
  #
  #   | x86 CPU                                     | x86_64 CPU             |
  #   |---------------------------------------------+------------------------|
  #   | -b 32                                       | -b 64                  |
  #   | -A 18  (Pentium II)                         | -A 31 (Athlon K7)      |
  #   | -V 1 (No SIMD: Pentium II doesn't have SSE) | -V 384 (SSE1 and SSE2) |
  #
  # Users who want to compile a highly optimized version of ATLAS that's suitable
  # for their local machine can override these settings accordingly.
  #
  # The -V flags can change with each release as new instruction sets are added
  # because upstream thinks it's a good idea to add entries at the start of an
  # enum, rather than the end. If the build suddenly fails with messages about
  # missing instruction sets, you may need to poke around in the source a bit.
  
  let
    version = "3.10.2";
  
    optionalString = stdenv.lib.optionalString;
    optional = stdenv.lib.optional;
  in
  
  stdenv.mkDerivation {
  
negative.code: { stdenv, fetchurl, gfortran, tolerateCpuTimingInaccuracy ? true, shared ? false
  , cpuConfig ? if stdenv.isi686 then "-b 32 -A 12 -V 1" else "-b 64 -A 14 -V 384"
  , cacheEdge ? "262144"
  , threads ? "0"
  }:
  
  # Atlas detects the CPU and optimizes its build accordingly. This is great when
  