Merge pull request #328420 from toonn/quirc-absolute-install-name

quirc: Use dylib with absolute install name on Darwin
This commit is contained in:
7c6f434c 2024-07-20 19:34:21 +00:00 committed by GitHub
commit 63911cd477
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 21 deletions

View File

@ -1,8 +1,17 @@
From 7435b2e12c2004cb0c497ff313288902f2a6f39a Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Fri, 19 Jul 2024 21:53:58 +0200
Subject: [PATCH] Don't build demos
---
Makefile | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 2d5b745..ecef988 100644
index 8327b4e..7901cc5 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ DEMO_UTIL_OBJ = \
@@ -45,7 +45,7 @@ DEMO_UTIL_OBJ = \
OPENCV_CFLAGS := $(shell pkg-config --cflags opencv4 2>&1)
OPENCV_LIBS = $(shell pkg-config --libs opencv4)
@ -11,19 +20,23 @@ index 2d5b745..ecef988 100644
.PHONY: all v4l sdl opencv install uninstall clean
@@ -85,14 +85,11 @@ libquirc.so.$(LIB_VERSION): $(LIB_OBJ)
@@ -93,15 +93,12 @@ libquirc.$(VERSIONED_LIB_SUFFIX): $(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: libquirc.a libquirc.$(LIB_SUFFIX) quirc-demo quirc-scanner
+install: libquirc.a libquirc.$(LIB_SUFFIX)
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) \
install -o root -g root -m 0755 libquirc.$(VERSIONED_LIB_SUFFIX) \
$(DESTDIR)$(PREFIX)/lib
cp -d libquirc.$(LIB_SUFFIX) $(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
rm -f $(DESTDIR)$(PREFIX)/include/quirc.h
--
2.42.2

View File

@ -1,5 +1,5 @@
{ lib, stdenv, fetchFromGitHub, SDL_gfx, SDL, libjpeg, libpng, opencv
, pkg-config }:
{ lib, stdenv, fetchFromGitHub, fetchpatch2, SDL_gfx, SDL, libjpeg, libpng
, opencv, pkg-config }:
stdenv.mkDerivation (finalAttrs: {
pname = "quirc";
@ -25,29 +25,38 @@ stdenv.mkDerivation (finalAttrs: {
makeFlags = [ "PREFIX=$(out)" ];
env.NIX_CFLAGS_COMPILE = "-I${lib.getDev SDL}/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
'';
patches = [
(fetchpatch2 {
url = "https://github.com/dlbeer/quirc/commit/2c350d8aaf37246e538a2c93b2cce8c78600d2fc.patch?full_index=1";
hash = "sha256-ZTcy/EoOBoyOjtXjmT+J/JcbX8lxGKmbWer23lymbWo=";
})
(fetchpatch2 {
url = "https://github.com/dlbeer/quirc/commit/257c6c94d99960819ecabf72199e5822f60a3bc5.patch?full_index=1";
hash = "sha256-WLQK7vy34VmgJzppTnRjAcZoSGWVaXQSaGq9An8W0rw=";
})
] ++ lib.optionals stdenv.isDarwin [
# Disable building of linux-only demos on darwin systems
./0001-Don-t-build-demos.patch
];
preInstall = ''
mkdir -p "$out"/{bin,lib,include}
# install all binaries
find -maxdepth 1 -type f -executable ! -name '*.so.*' | xargs cp -t "$out"/bin
find -maxdepth 1 -type f -executable ! -name '*.so.*' ! -name '*.dylib' \
| xargs cp -t "$out"/bin
'';
postInstall = ''
# don't install static library
rm $out/lib/libquirc.a
'' + (if stdenv.isDarwin then ''
# Set absolute install name to avoid the need for DYLD_LIBRARY_PATH
dylib=$out/lib/libquirc.${finalAttrs.version}.dylib
${stdenv.cc.targetPrefix}install_name_tool -id "$dylib" "$dylib"
'' else ''
ln -s $out/lib/libquirc.so.* $out/lib/libquirc.so
'';
'');
meta = {
description = "Small QR code decoding library";