From d41e25c05825d062a8237c9e1186194d6bab3484 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Thu, 30 Jan 2020 14:52:29 -0500 Subject: gnu: Add qrcodegen-cpp. * gnu/packages/aidc.scm (qrcodegen-cpp): New variable. * gnu/packages/patches/qrcodegen-cpp-make-install.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 1 + gnu/packages/aidc.scm | 39 ++ .../patches/qrcodegen-cpp-make-install.patch | 448 +++++++++++++++++++++ 3 files changed, 488 insertions(+) create mode 100644 gnu/packages/patches/qrcodegen-cpp-make-install.patch diff --git a/gnu/local.mk b/gnu/local.mk index 3f8fa2ed7b..2bbb41da92 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1351,6 +1351,7 @@ dist_patch_DATA = \ %D%/packages/patches/qemu-CVE-2020-7039.patch \ %D%/packages/patches/qemu-CVE-2020-7211.patch \ %D%/packages/patches/qemu-fix-documentation-build-failure.patch \ + %D%/packages/patches/qrcodegen-cpp-make-install.patch \ %D%/packages/patches/qt4-ldflags.patch \ %D%/packages/patches/qtbase-use-TZDIR.patch \ %D%/packages/patches/qtscript-disable-tests.patch \ diff --git a/gnu/packages/aidc.scm b/gnu/packages/aidc.scm index 77db0ac9fc..b68f2137be 100644 --- a/gnu/packages/aidc.scm +++ b/gnu/packages/aidc.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2017 Hartmut Goebel ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice ;;; Copyright © 2019 Guillaume Le Vaillant +;;; Copyright © 2020 Leo Famulari ;;; ;;; This file is part of GNU Guix. ;;; @@ -154,3 +155,41 @@ For application developers, language bindings are included for C, C++ and Python as well as GUI widgets for GTK and Qt.") (home-page "https://github.com/mchehab/zbar") (license license:lgpl2.1+))) + +(define-public qrcodegen-cpp + ;; Currently this project's installation mechanism only exists as a GitHub + ;; pull request, so we build from a recent commit that the proposed patch + ;; applies to. + (let ((commit "6ea933f1596d818bd21e9a6b8d2e851fb8b4bcf1") + (revision "0")) + (package + (name "qrcodegen-cpp") + (version (git-version "1.5.0" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/nayuki/QR-Code-generator.git") + (commit commit))) + (file-name (git-file-name name version)) + (patches (search-patches "qrcodegen-cpp-make-install.patch")) + (sha256 + (base32 + "19fcwqmfk2n9p2n01dv2j4x2y2mqip0j1wbmfbxjp34rqkjwcwxm")))) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; no test suite + #:make-flags + (list (string-append "PREFIX=" (assoc-ref %outputs "out"))) + #:phases + (modify-phases %standard-phases + (delete 'configure) ; No ./configure script + ;; Only build the C++ variant. + (add-after 'unpack 'chdir + (lambda _ + (chdir "cpp") + #t))))) + (synopsis "QR Code generator library") + (description "qrcodegen-cpp is a QR code generator library in C++. The +project also offers Java, Javascript, Python, C, and Rust implementations.") + (home-page "https://www.nayuki.io/page/qr-code-generator-library") + (license license:expat)))) diff --git a/gnu/packages/patches/qrcodegen-cpp-make-install.patch b/gnu/packages/patches/qrcodegen-cpp-make-install.patch new file mode 100644 index 0000000000..4da619d3c8 --- /dev/null +++ b/gnu/packages/patches/qrcodegen-cpp-make-install.patch @@ -0,0 +1,448 @@ +Make the library installable. Patch copied from pull request: + +https://github.com/nayuki/QR-Code-generator/pull/72 + +From 1625fc1665e1f83eb73c0f5670dcfda96dc0b3e4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 3 Dec 2019 11:57:24 +0100 +Subject: [PATCH 1/7] Do not append to C/XX/FLAGS but just set them if not + defined already + +--- + c/Makefile | 2 +- + cpp/Makefile | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/c/Makefile b/c/Makefile +index fd0c367..b27449c 100644 +--- a/c/Makefile ++++ b/c/Makefile +@@ -29,7 +29,7 @@ + # - CFLAGS: Any extra user-specified compiler flags (can be blank). + + # Recommended compiler flags: +-CFLAGS += -std=c99 -O ++CFLAGS ?= -std=c99 -O + + # Extra flags for diagnostics: + # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address +diff --git a/cpp/Makefile b/cpp/Makefile +index f83c512..666f976 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -29,7 +29,7 @@ + # - CXXFLAGS: Any extra user-specified compiler flags (can be blank). + + # Recommended compiler flags: +-CXXFLAGS += -std=c++11 -O ++CXXFLAGS ?= -std=c++11 -O + + # Extra flags for diagnostics: + # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address + +From 2e496a0f59d5c6782c1e3e2a3ca36d0272b384f3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 3 Dec 2019 11:59:59 +0100 +Subject: [PATCH 2/7] Make use of -fPIC parameter when building' + +--- + c/Makefile | 2 +- + cpp/Makefile | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/c/Makefile b/c/Makefile +index b27449c..bf79462 100644 +--- a/c/Makefile ++++ b/c/Makefile +@@ -77,7 +77,7 @@ $(LIBFILE): $(LIBOBJ) + + # Object files + %.o: %.c .deps/timestamp +- $(CC) $(CFLAGS) -c -o $@ -MMD -MF .deps/$*.d $< ++ $(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $< + + # Have a place to store header dependencies automatically generated by compiler + .deps/timestamp: +diff --git a/cpp/Makefile b/cpp/Makefile +index 666f976..f37cf66 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -73,7 +73,7 @@ $(LIBFILE): $(LIBOBJ) + + # Object files + %.o: %.cpp .deps/timestamp +- $(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $< ++ $(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $< + + # Have a place to store header dependencies automatically generated by compiler + .deps/timestamp: + +From 29489faaa5a3b014c5c2d95ca34033df470de73c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 3 Dec 2019 12:07:19 +0100 +Subject: [PATCH 3/7] Generate both shared and static libraries + +--- + c/Makefile | 14 ++++++++++---- + cpp/Makefile | 14 ++++++++++---- + 2 files changed, 20 insertions(+), 8 deletions(-) + +diff --git a/c/Makefile b/c/Makefile +index bf79462..38eda2d 100644 +--- a/c/Makefile ++++ b/c/Makefile +@@ -51,16 +51,19 @@ CFLAGS ?= -std=c99 -O + # ---- Targets to build ---- + + LIB = qrcodegen +-LIBFILE = lib$(LIB).a ++ARFILE = lib$(LIB).a ++LIBFILE = lib$(LIB).so ++# Bump the soname number when the ABI changes and gets incompatible ++SO_NAME = $(LIBFILE).1 + LIBOBJ = qrcodegen.o + MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker + + # Build all binaries +-all: $(LIBFILE) $(MAINS) ++all: $(LIBFILE) $(ARFILE) $(MAINS) + + # Delete build output + clean: +- rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS) ++ rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS) + rm -rf .deps + + # Executable files +@@ -72,9 +75,12 @@ qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c) + $(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $^ + + # The library +-$(LIBFILE): $(LIBOBJ) ++$(ARFILE): $(LIBOBJ) + $(AR) -crs $@ -- $^ + ++$(LIBFILE): $(LIBOBJ) ++ $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ ++ + # Object files + %.o: %.c .deps/timestamp + $(CC) $(CFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $< +diff --git a/cpp/Makefile b/cpp/Makefile +index f37cf66..606cdad 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -51,16 +51,19 @@ CXXFLAGS ?= -std=c++11 -O + # ---- Targets to build ---- + + LIB = qrcodegen +-LIBFILE = lib$(LIB).a ++ARFILE = lib$(LIB).a ++LIBFILE = lib$(LIB).so ++# Bump the soname number when the ABI changes and gets incompatible ++SO_NAME = $(LIBFILE).1 + LIBOBJ = QrCode.o + MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker + + # Build all binaries +-all: $(LIBFILE) $(MAINS) ++all: $(LIBFILE) $(ARFILE) $(MAINS) + + # Delete build output + clean: +- rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS) ++ rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS) + rm -rf .deps + + # Executable files +@@ -68,9 +71,12 @@ clean: + $(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB) + + # The library +-$(LIBFILE): $(LIBOBJ) ++$(ARFILE): $(LIBOBJ) + $(AR) -crs $@ -- $^ + ++$(LIBFILE): $(LIBOBJ) ++ $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ ++ + # Object files + %.o: %.cpp .deps/timestamp + $(CXX) $(CXXFLAGS) -fPIC -c -o $@ -MMD -MF .deps/$*.d $< + +From 064f38d6a8dc0a457728a47ee4ca1e927e46d5ec Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 3 Dec 2019 12:45:34 +0100 +Subject: [PATCH 4/7] Create install targets for C and CPP + +--- + c/Makefile | 26 ++++++++++++++++++++++++++ + cpp/Makefile | 27 +++++++++++++++++++++++++++ + 2 files changed, 53 insertions(+) + +diff --git a/c/Makefile b/c/Makefile +index 38eda2d..7521944 100644 +--- a/c/Makefile ++++ b/c/Makefile +@@ -34,6 +34,8 @@ CFLAGS ?= -std=c99 -O + # Extra flags for diagnostics: + # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address + ++# Version information ++VERSION = 1.5.0 + + # ---- Controlling make ---- + +@@ -55,9 +57,15 @@ ARFILE = lib$(LIB).a + LIBFILE = lib$(LIB).so + # Bump the soname number when the ABI changes and gets incompatible + SO_NAME = $(LIBFILE).1 ++REAL_NAME = $(LIBFILE).$(VERSION) ++HEADERS = qrcodegen.h + LIBOBJ = qrcodegen.o + MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker + ++# define paths to install ++INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen ++LIBDIR ?= $(DESTDIR)/usr/lib ++ + # Build all binaries + all: $(LIBFILE) $(ARFILE) $(MAINS) + +@@ -66,6 +74,24 @@ clean: + rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS) + rm -rf .deps + ++install-shared: $(LIBFILE) ++ install -d $(LIBDIR) || true ++ install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME) ++ rm -f $(LIBDIR)/$(SO_NAME) ++ ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME) ++ rm -f $(LIBDIR)/$(LIBFILE) ++ ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE) ++ ++install-static: $(ARFILE) ++ install -d $(LIBDIR) || true ++ install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE) ++ ++install-header: $(HEADERS) ++ install -d $(INCLUDEDIR) || true ++ install -m 0644 $(HEADERS) $(INCLUDEDIR)/ ++ ++install: install-shared install-static install-header ++ + # Executable files + %: %.o $(LIBFILE) + $(CC) $(CFLAGS) -o $@ $< -L . -l $(LIB) +diff --git a/cpp/Makefile b/cpp/Makefile +index 606cdad..3271bd8 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -34,6 +34,8 @@ CXXFLAGS ?= -std=c++11 -O + # Extra flags for diagnostics: + # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address + ++# Version information ++VERSION = 1.5.0 + + # ---- Controlling make ---- + +@@ -55,9 +57,16 @@ ARFILE = lib$(LIB).a + LIBFILE = lib$(LIB).so + # Bump the soname number when the ABI changes and gets incompatible + SO_NAME = $(LIBFILE).1 ++REAL_NAME = $(LIBFILE).$(VERSION) ++HEADERS = QrCode.hpp + LIBOBJ = QrCode.o + MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker + ++# define paths to install ++INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen ++LIBDIR ?= $(DESTDIR)/usr/lib ++ ++ + # Build all binaries + all: $(LIBFILE) $(ARFILE) $(MAINS) + +@@ -66,6 +75,24 @@ clean: + rm -f -- $(LIBOBJ) $(LIBFILE) $(ARFILE) $(MAINS:=.o) $(MAINS) + rm -rf .deps + ++install-shared: $(LIBFILE) ++ install -d $(LIBDIR) || true ++ install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME) ++ rm -f $(LIBDIR)/$(SO_NAME) ++ ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME) ++ rm -f $(LIBDIR)/$(LIBFILE) ++ ln -s $(SO_NAME) $(LIBDIR)/$(LIBFILE) ++ ++install-static: $(ARFILE) ++ install -d $(LIBDIR) || true ++ install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE) ++ ++install-header: $(HEADERS) ++ install -d $(INCLUDEDIR) || true ++ install -m 0644 $(HEADERS) $(INCLUDEDIR)/ ++ ++install: install-shared install-static install-header ++ + # Executable files + %: %.o $(LIBFILE) + $(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB) + +From a635ff4654f94ab26b458c46a8841543e5bc8c67 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 3 Dec 2019 12:50:39 +0100 +Subject: [PATCH 5/7] Rename cpp library to qrcodegencpp to avoid conflict + +--- + cpp/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cpp/Makefile b/cpp/Makefile +index 3271bd8..42fa4ff 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -52,7 +52,7 @@ VERSION = 1.5.0 + + # ---- Targets to build ---- + +-LIB = qrcodegen ++LIB = qrcodegencpp + ARFILE = lib$(LIB).a + LIBFILE = lib$(LIB).so + # Bump the soname number when the ABI changes and gets incompatible + +From c073e7dfad6454dfd725a69c347f8272d29ea41c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 7 Jan 2020 09:18:59 +0100 +Subject: [PATCH 6/7] Add PREFIX variable and few minor fixes from code review + +--- + c/Makefile | 9 +++++---- + cpp/Makefile | 9 +++++---- + 2 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/c/Makefile b/c/Makefile +index 7521944..874933e 100644 +--- a/c/Makefile ++++ b/c/Makefile +@@ -29,7 +29,7 @@ + # - CFLAGS: Any extra user-specified compiler flags (can be blank). + + # Recommended compiler flags: +-CFLAGS ?= -std=c99 -O ++CFLAGS += -std=c99 + + # Extra flags for diagnostics: + # CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address +@@ -63,8 +63,9 @@ LIBOBJ = qrcodegen.o + MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker + + # define paths to install +-INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen +-LIBDIR ?= $(DESTDIR)/usr/lib ++PREFIX ?= /usr/local ++INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen ++LIBDIR ?= $(DESTDIR)$(PREFIX)/lib + + # Build all binaries + all: $(LIBFILE) $(ARFILE) $(MAINS) +@@ -105,7 +106,7 @@ $(ARFILE): $(LIBOBJ) + $(AR) -crs $@ -- $^ + + $(LIBFILE): $(LIBOBJ) +- $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ ++ $(CC) $(CFLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ + + # Object files + %.o: %.c .deps/timestamp +diff --git a/cpp/Makefile b/cpp/Makefile +index 42fa4ff..f8d9b7f 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -29,7 +29,7 @@ + # - CXXFLAGS: Any extra user-specified compiler flags (can be blank). + + # Recommended compiler flags: +-CXXFLAGS ?= -std=c++11 -O ++CXXFLAGS += -std=c++11 + + # Extra flags for diagnostics: + # CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address +@@ -63,8 +63,9 @@ LIBOBJ = QrCode.o + MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker + + # define paths to install +-INCLUDEDIR ?= $(DESTDIR)/usr/include/qrcodegen +-LIBDIR ?= $(DESTDIR)/usr/lib ++PREFIX ?= /usr/local ++INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include/qrcodegen ++LIBDIR ?= $(DESTDIR)$(PREFIX)/lib + + + # Build all binaries +@@ -102,7 +103,7 @@ $(ARFILE): $(LIBOBJ) + $(AR) -crs $@ -- $^ + + $(LIBFILE): $(LIBOBJ) +- $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ ++ $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^ + + # Object files + %.o: %.cpp .deps/timestamp + +From b43c1de5cc874535a7f549cef437f6849528e455 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= +Date: Tue, 7 Jan 2020 13:12:32 +0100 +Subject: [PATCH 7/7] Install static and shared library as an executable + +--- + c/Makefile | 4 ++-- + cpp/Makefile | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/c/Makefile b/c/Makefile +index 874933e..631cc71 100644 +--- a/c/Makefile ++++ b/c/Makefile +@@ -77,7 +77,7 @@ clean: + + install-shared: $(LIBFILE) + install -d $(LIBDIR) || true +- install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME) ++ install -m 0755 $(LIBFILE) $(LIBDIR)/$(REAL_NAME) + rm -f $(LIBDIR)/$(SO_NAME) + ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME) + rm -f $(LIBDIR)/$(LIBFILE) +@@ -85,7 +85,7 @@ install-shared: $(LIBFILE) + + install-static: $(ARFILE) + install -d $(LIBDIR) || true +- install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE) ++ install -m 0755 $(ARFILE) $(LIBDIR)/$(ARFILE) + + install-header: $(HEADERS) + install -d $(INCLUDEDIR) || true +diff --git a/cpp/Makefile b/cpp/Makefile +index f8d9b7f..bbd861e 100644 +--- a/cpp/Makefile ++++ b/cpp/Makefile +@@ -78,7 +78,7 @@ clean: + + install-shared: $(LIBFILE) + install -d $(LIBDIR) || true +- install -m 0644 $(LIBFILE) $(LIBDIR)/$(REAL_NAME) ++ install -m 0755 $(LIBFILE) $(LIBDIR)/$(REAL_NAME) + rm -f $(LIBDIR)/$(SO_NAME) + ln -s $(REAL_NAME) $(LIBDIR)/$(SO_NAME) + rm -f $(LIBDIR)/$(LIBFILE) +@@ -86,7 +86,7 @@ install-shared: $(LIBFILE) + + install-static: $(ARFILE) + install -d $(LIBDIR) || true +- install -m 0644 $(ARFILE) $(LIBDIR)/$(ARFILE) ++ install -m 0755 $(ARFILE) $(LIBDIR)/$(ARFILE) + + install-header: $(HEADERS) + install -d $(INCLUDEDIR) || true -- cgit v1.2.3