anchor.diff:      sed -i -e 's,LIB_SUFFIX="t,LIB_SUFFIX=",' configure
     '';
   
  +  NIX_LDFLAGS = if threaded then "-lpthread" else null;
  +
     selfNativeBuildInput = true;
   
     enableParallelBuilding = true;
  
positive.code:   buildInputs = [ optGpm ];
  
    configureFlags = [
      (mkWith   true        "abi-version"   abiVersion)
      (mkWith   true        "cxx"           null)
      (mkWith   true        "cxx-binding"   null)
      (mkWith   false       "ada"           null)
      (mkWith   true        "manpages"      null)
      (mkWith   true        "progs"         null)
      (mkWith   doCheck     "tests"         null)
      (mkWith   true        "curses-h"      null)
      (mkEnable true        "pc-files"      null)
      (mkEnable true        "mixed-case"    "auto")
      (mkWith   true        "libtool"       null)
      (mkWith   true        "shared"        null)
      (mkWith   true        "normal"        null)
      (mkWith   false       "debug"         null)
      (mkWith   false       "profile"       null)
      (mkWith   false       "termlib"       null)
      (mkWith   false       "ticlib"        null)
      (mkWith   optGpm      "gpm"           null)
      (mkWith   true        "dlsym"         null)
      (mkWith   true        "sysmouse"      "maybe")
      (mkEnable true        "relink"        null)
      (mkEnable true        "overwrite"     null)
      (mkEnable true        "database"      null)
      (mkWith   false       "hashed-db"     null)
      (mkWith   true        "fallbacks"     "")
      (mkWith   true        "xterm-new"     null)
      # With terminfo-dirs
      # With default-terminfo-dir
      # Enable big-core: Autodetected
      # Enable big-strings: Autodetected
      (mkEnable false       "termcap"       null)
      (mkWith   true        "termpath"      "\${out}/share/misc/termcap")
      (mkEnable true        "getcap"        null)
      (mkEnable false       "getcap-cache"  null)
      (mkEnable true        "home-terminfo" null)
      (mkEnable true        "root-environ"  null)
      (mkEnable true        "symlinks"      null)
      (mkEnable false       "broken-linker" null)
      (mkEnable false       "bsdpad"        null)
      (mkEnable unicode     "widec"         null)
      (mkEnable true        "lp64"          null)
      (mkEnable true        "tparm-varargs" null)
      (mkWith   true        "tic-depends"   null)
      (mkWith   true        "bool"          null)
      # With caps
      # With chtype
      # With ospeed
      # With mmask-t
      # With ccharw-max
      (mkWith   false       "rcs-ids"       null)
      (mkEnable true        "ext-funcs"     null)
      (mkEnable true        "sp-funcs"      null)
      (mkEnable true        "term-driver"   null)
      (mkEnable true        "const"         null)
      (mkEnable true        "ext-colors"    null)
      (mkEnable true        "ext-mouse"     null)
      (mkEnable true        "no-padding"    null)
      (mkEnable false       "signed-char"   null)
      (mkEnable true        "sigwinch"      null)
      (mkEnable true        "tcap-names"    null)
      (mkWith   true        "devlop"        null)
      (mkEnable true        "hard-tabs"     null)
      (mkEnable true        "xmc-glitch"    null)
      (mkWith   true        "assumed-color" null)
      (mkEnable true        "hashmap"       null)
      (mkEnable true        "colorfgbg"      null)
      (mkEnable true        "interop"        null)
      (mkWith   true        "pthread"        null)
      (mkEnable false       "pthreads-eintr" null)
      (mkEnable false       "weak-symbols"   null)
      (mkEnable true        "reentrant"      null)
      # With wrap-prefix
      (mkEnable true        "safe-sprintf"   null)
      (mkEnable true        "scroll-hints"   null)
  
negative.code: 
      suffix="$(awk -F': ' 'f{print $3; f=0} /default library suffix/{f=1}' config.log)"
      libs="$(ls $out/lib/pkgconfig | tr ' ' '\n' | sed "s,\(.*\)$suffix\.pc,\1,g")"
      suffixes="$(echo "$suffix" | awk '{for (i=1; i < length($0); i++) {x=substr($0, i+1, length($0)-i); print x}}')"
    '' + optionalString stdenv.isLinux ''
      for lib in $libs; do
        for newsuffix in $suffixes ""; do
          if [ -e "$out/lib/lib''${lib}$suffix.so" ]; then
            ln -svf lib''${lib}$suffix.so $out/lib/lib$lib$newsuffix.so
            ln -svf lib''${lib}$suffix.so.${abiVersion} $out/lib/lib$lib$newsuffix.so.${abiVersion}
          fi
          if [ -e "$out/lib/lib''${lib}$suffix.a" ]; then
            ln -svf lib''${lib}$suffix.a $out/lib/lib$lib$newsuffix.a
          fi
          ln -svf lib''${lib}$suffix.la $out/lib/lib$lib$newsuffix.la
          ln -svf ''${lib}$suffix.pc $out/lib/pkgconfig/$lib$newsuffix.pc
        done
      done
  
      # Create curses compatability
      ln -svf libncurses.so $out/lib/libcurses.so
  
      # Fix .la files to include pthreads
      find $out/lib -name \*.la -type f | xargs sed -i "s,\(dependency_libs='\),\1${optionalString threaded "-lpthread"},"
    '' + stdenv.lib.optionalString stdenv.isCygwin ''
      for lib in $libs; do
        if test -e $out/lib/lib''${lib}$suffix.dll.a; then
  