{ stdenv, fetchurl, cmake, patchelf, imagemagick }:

stdenv.mkDerivation rec {
  name = "cuneiform-${version}";
  version = "1.1.0";

  src = fetchurl {
    url = "https://launchpad.net/cuneiform-linux/1.1/1.1/+download/cuneiform-linux-1.1.0.tar.bz2";
    sha256 = "1bdvppyfx2184zmzcylskd87cxv56d8f32jf7g1qc8779l2hszjp";
  };

  patches = [
  (fetchurl {
    url = "https://git.archlinux.org/svntogit/community.git/plain/cuneiform/trunk/build-fix.patch?id=a2ec92f05de006b56d16ac6a6c370d54a554861a";
    sha256 = "19cmrlx4khn30qqrpyayn7bicg8yi0wpz1x1bvqqrbvr3kwldxyj";
  })
  ];

  buildInputs = [ imagemagick ];

  nativeBuildInputs = [ cmake ];

  meta = {
    description = "Multi-language OCR system";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
  };
}

{ stdenv, fetchurl, cmake, patchelf, imagemagick }:

stdenv.mkDerivation rec {
  name = "cuneiform-${version}";
  version = "1.1.0";

  src = fetchurl {
    url = "https://launchpad.net/cuneiform-linux/1.1/1.1/+download/cuneiform-linux-1.1.0.tar.bz2";
    sha256 = "1bdvppyfx2184zmzcylskd87cxv56d8f32jf7g1qc8779l2hszjp";
  };

  patches = [
  (fetchurl {
    url = "https://git.archlinux.org/svntogit/community.git/plain/cuneiform/trunk/build-fix.patch?id=a2ec92f05de006b56d16ac6a6c370d54a554861a";
    sha256 = "19cmrlx4khn30qqrpyayn7bicg8yi0wpz1x1bvqqrbvr3kwldxyj";
  })
  ];

  postPatch = ''
    rm cuneiform_src/Kern/hhh/tigerh/h/strings.h
  '';

  buildInputs = [ imagemagick ];

  nativeBuildInputs = [ cmake ];

  meta = {
    description = "Multi-language OCR system";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
  };
}

Fix build against glibc 2.26
cuneiform: Fix build against glibc 2.26

Since glibc 2.26 the string.h file includes <strings.h>, which in case
of cuneiform will include the strings.h found in Kern/hhh/tigerh/h,
because of the search path order.

Fortunately for us the strings.h in cuneiform are completely unused and
no files reference or include it. I even checked various references to
types within strings.h and the only occurences are in cf_strings.h,
which is also included by other files.

Signed-off-by: aszlig <ee1aa092358634f9c53f01b5a783726c9e21b35a@nix.build>
Cc: da39a3ee5e6b4b0d3255bfef95601890afd80709@7c6f434c
