about summary refs log tree commit diff
diff options
context:
space:
mode:
author4825764518 <100122841+4825764518@users.noreply.github.com>2022-04-13 00:15:29 -0400
committer4825764518 <100122841+4825764518@users.noreply.github.com>2022-04-13 00:56:27 -0400
commit313e2a51240d632bb4fc1f1c891bcbbd564f9503 (patch)
tree9b8d4d78fd8f7bd6e3d1a5dfcda0c0e9d95f0885
parente51d4a13bc9345554991cb4f97a8962e27af98d8 (diff)
quirc: fix darwin build
Some linux-only samples prevented this package from building on x86_64 and aarch64 darwin systems.
-rw-r--r--pkgs/tools/graphics/quirc/0001-dont-build-demos.patch29
-rw-r--r--pkgs/tools/graphics/quirc/default.nix20
2 files changed, 44 insertions, 5 deletions
diff --git a/pkgs/tools/graphics/quirc/0001-dont-build-demos.patch b/pkgs/tools/graphics/quirc/0001-dont-build-demos.patch
new file mode 100644
index 0000000000000..9ecb6dda4e19e
--- /dev/null
+++ b/pkgs/tools/graphics/quirc/0001-dont-build-demos.patch
@@ -0,0 +1,29 @@
+diff --git a/Makefile b/Makefile
+index 2d5b745..ecef988 100644
+--- a/Makefile
++++ b/Makefile
+@@ -37,7 +37,7 @@ DEMO_UTIL_OBJ = \
+ 
+ OPENCV_CFLAGS != pkg-config --cflags opencv4
+ OPENCV_LIBS != pkg-config --libs opencv4
+-QUIRC_CXXFLAGS = $(QUIRC_CFLAGS) $(OPENCV_CFLAGS) --std=c++17
++QUIRC_CXXFLAGS = $(QUIRC_CFLAGS) --std=c++17
+ 
+ .PHONY: all v4l sdl opencv install uninstall clean
+ 
+@@ -85,14 +85,11 @@ libquirc.so.$(LIB_VERSION): $(LIB_OBJ)
+ .cxx.o:
+ 	$(CXX) $(QUIRC_CXXFLAGS) -o $@ -c $<
+ 
+-install: libquirc.a libquirc.so.$(LIB_VERSION) quirc-demo quirc-scanner
++install: libquirc.a libquirc.so.$(LIB_VERSION)
+ 	install -o root -g root -m 0644 lib/quirc.h $(DESTDIR)$(PREFIX)/include
+ 	install -o root -g root -m 0644 libquirc.a $(DESTDIR)$(PREFIX)/lib
+ 	install -o root -g root -m 0755 libquirc.so.$(LIB_VERSION) \
+ 		$(DESTDIR)$(PREFIX)/lib
+-	install -o root -g root -m 0755 quirc-demo $(DESTDIR)$(PREFIX)/bin
+-	# install -o root -g root -m 0755 quirc-demo-opencv $(DESTDIR)$(PREFIX)/bin
+-	install -o root -g root -m 0755 quirc-scanner $(DESTDIR)$(PREFIX)/bin
+ 
+ uninstall:
+ 	rm -f $(DESTDIR)$(PREFIX)/include/quirc.h
\ No newline at end of file
diff --git a/pkgs/tools/graphics/quirc/default.nix b/pkgs/tools/graphics/quirc/default.nix
index 1376b34a697ce..6ad0262da3a13 100644
--- a/pkgs/tools/graphics/quirc/default.nix
+++ b/pkgs/tools/graphics/quirc/default.nix
@@ -1,6 +1,5 @@
-{ lib, stdenv, fetchFromGitHub
-, SDL_gfx, SDL, libjpeg, libpng, opencv, pkg-config
-}:
+{ lib, stdenv, fetchFromGitHub, SDL_gfx, SDL, libjpeg, libpng, opencv
+, pkg-config }:
 
 stdenv.mkDerivation {
   pname = "quirc";
@@ -19,6 +18,16 @@ stdenv.mkDerivation {
   makeFlags = [ "PREFIX=$(out)" ];
   NIX_CFLAGS_COMPILE = "-I${SDL.dev}/include/SDL -I${SDL_gfx}/include/SDL";
 
+  # Disable building of linux-only demos on darwin systems
+  patches = lib.optionals stdenv.isDarwin [ ./0001-dont-build-demos.patch ];
+
+  buildPhase = lib.optionalString stdenv.isDarwin ''
+    runHook preBuild
+    make libquirc.so
+    make qrtest
+    runHook postBuild
+  '';
+
   configurePhase = ''
     runHook preConfigure
 
@@ -27,6 +36,7 @@ stdenv.mkDerivation {
 
     runHook postConfigure
   '';
+
   preInstall = ''
     mkdir -p "$out"/{bin,lib,include}
 
@@ -37,7 +47,7 @@ stdenv.mkDerivation {
   meta = {
     description = "A small QR code decoding library";
     license = lib.licenses.isc;
-    maintainers = [lib.maintainers.raskin];
-    platforms = lib.platforms.linux;
+    maintainers = [ lib.maintainers.raskin ];
+    platforms = lib.platforms.linux ++ [ "x86_64-darwin" "aarch64-darwin" ];
   };
 }