summary refs log tree commit diff
path: root/pkgs/applications/graphics/sane
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2022-08-31 18:59:23 +0300
committerArtturin <Artturin@artturin.com>2022-09-01 00:21:13 +0300
commitcf360a109584d56f5acb974ccc4771f2975ec4d0 (patch)
treeaadc60f085fb4a80b8b5b573b6edc88715564526 /pkgs/applications/graphics/sane
parent77c92662415d541f36b317bcb97f5c8d9932bffb (diff)
downloadnixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.tar
nixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.tar.gz
nixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.tar.bz2
nixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.tar.lz
nixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.tar.xz
nixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.tar.zst
nixpkgs-cf360a109584d56f5acb974ccc4771f2975ec4d0.zip
sane-backends: fix cross
pulled patch from void-linux

MMAP is only on linux i think
Diffstat (limited to 'pkgs/applications/graphics/sane')
-rw-r--r--pkgs/applications/graphics/sane/backends/default.nix24
1 files changed, 23 insertions, 1 deletions
diff --git a/pkgs/applications/graphics/sane/backends/default.nix b/pkgs/applications/graphics/sane/backends/default.nix
index 02f5025a563..2364b450835 100644
--- a/pkgs/applications/graphics/sane/backends/default.nix
+++ b/pkgs/applications/graphics/sane/backends/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchurl, runtimeShell
+{ stdenv, lib, fetchurl, fetchpatch, runtimeShell, buildPackages
 , gettext, pkg-config, python3
 , avahi, libgphoto2, libieee1284, libjpeg, libpng, libtiff, libusb1, libv4l, net-snmp
 , curl, systemd, libxml2, poppler, gawk
@@ -29,8 +29,26 @@ stdenv.mkDerivation {
     sha256 = "055iicihxa6b28iv5fnz13n67frdr5nrydq2c846f9x7q0vw4a1s";
   };
 
+  patches = [
+    # sane-desc will be used in postInstall so compile it for build
+    # https://github.com/void-linux/void-packages/blob/master/srcpkgs/sane/patches/sane-desc-cross.patch
+    (fetchpatch {
+      name = "compile-sane-desc-for-build.patch";
+      url = "https://raw.githubusercontent.com/void-linux/void-packages/4b97cd2fb4ec38712544438c2491b6d7d5ab334a/srcpkgs/sane/patches/sane-desc-cross.patch";
+      sha256 = "sha256-y6BOXnOJBSTqvRp6LwAucqaqv+OLLyhCS/tXfLpnAPI=";
+    })
+  ];
+
+  postPatch = ''
+    # related to the compile-sane-desc-for-build
+    substituteInPlace tools/Makefile.in \
+      --replace 'cc -I' '$(CC_FOR_BUILD) -I'
+  '';
+
   outputs = [ "out" "doc" "man" ];
 
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+
   nativeBuildInputs = [
     gettext
     pkg-config
@@ -62,6 +80,10 @@ stdenv.mkDerivation {
     ++ lib.optional (libusb1 != null) "--with-usb"
   ;
 
+  # autoconf check for HAVE_MMAP is never set on cross compilation.
+  # The pieusb backend fails compilation if HAVE_MMAP is not set.
+  buildFlags = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "CFLAGS=-DHAVE_MMAP=${if stdenv.hostPlatform.isLinux then "1" else "0"}" ];
+
   postInstall = let
 
     compatFirmware = extraFirmware