- Add patches to make the stuff actually installable:

* 0001-Do-not-append-to-C-XX-FLAGS-but-just-set-them-if-not.patch
  * 0002-Make-use-of-fPIC-parameter-when-building.patch
  * 0003-Generate-both-shared-and-static-libraries.patch
  * 0004-Create-install-targets-for-C-and-CPP.patch
  * 0005-Rename-cpp-library-to-qrcodegencpp-to-avoid-conflict.patch
  * cflags.patch

- Initial commit, needed by libreoffice 6.4

OBS-URL: https://build.opensuse.org/package/show/LibreOffice:Factory/QR-Code-generator?expand=0&rev=1
This commit is contained in:
Tomáš Chvátal 2019-12-03 12:06:07 +00:00 committed by Git OBS Bridge
commit c3894e1578
11 changed files with 497 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,40 @@
From f0823adc2f7224aad3a1060a4eede4adad5858f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 11:57:24 +0100
Subject: [PATCH 1/5] 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 1d32943..62e03c5 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
--
2.24.0

View File

@ -0,0 +1,39 @@
From 8b4866c98775680abc49e8c1c0c50daa25dea052 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 11:59:59 +0100
Subject: [PATCH 2/5] 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 62e03c5..deb8924 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:
--
2.24.0

View File

@ -0,0 +1,95 @@
From 16351a7ebaf318d21632bbaabf0675a70bb67dc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:07:19 +0100
Subject: [PATCH 3/5] 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 deb8924..2f5b2af 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 = BitBuffer.o QrCode.o QrSegment.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 $<
--
2.24.0

View File

@ -0,0 +1,122 @@
From 498d2a0cf6d6f01a3ffb87e358f63c3a64afeb9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:45:34 +0100
Subject: [PATCH 4/5] 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 2f5b2af..d131f30 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 = BitBuffer.hpp QrCode.hpp QrSegment.hpp
LIBOBJ = BitBuffer.o QrCode.o QrSegment.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)
--
2.24.0

View File

@ -0,0 +1,25 @@
From ac482f00f1ad08ba692a24ef5abffe31b659c1d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tchvatal@suse.com>
Date: Tue, 3 Dec 2019 12:50:39 +0100
Subject: [PATCH 5/5] 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 d131f30..2e7ed1f 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
--
2.24.0

15
QR-Code-generator.changes Normal file
View File

@ -0,0 +1,15 @@
-------------------------------------------------------------------
Tue Dec 3 12:01:27 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Add patches to make the stuff actually installable:
* 0001-Do-not-append-to-C-XX-FLAGS-but-just-set-them-if-not.patch
* 0002-Make-use-of-fPIC-parameter-when-building.patch
* 0003-Generate-both-shared-and-static-libraries.patch
* 0004-Create-install-targets-for-C-and-CPP.patch
* 0005-Rename-cpp-library-to-qrcodegencpp-to-avoid-conflict.patch
* cflags.patch
-------------------------------------------------------------------
Tue Dec 3 09:05:13 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Initial commit, needed by libreoffice 6.4

78
QR-Code-generator.spec Normal file
View File

@ -0,0 +1,78 @@
#
# spec file for package QR-Code-generator
#
# Copyright (c) 2019 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define libcname libqrcodegen1
%define libcppname libqrcodegencpp1
Name: QR-Code-generator
Version: 1.5.0
Release: 0
Summary: QR Code generator library
License: MIT
URL: https://github.com/nayuki/QR-Code-generator
Source: https://github.com/nayuki/QR-Code-generator/archive/v%{version}.tar.gz
Patch0: cflags.patch
Patch1: 0001-Do-not-append-to-C-XX-FLAGS-but-just-set-them-if-not.patch
Patch2: 0002-Make-use-of-fPIC-parameter-when-building.patch
Patch3: 0003-Generate-both-shared-and-static-libraries.patch
Patch4: 0004-Create-install-targets-for-C-and-CPP.patch
Patch5: 0005-Rename-cpp-library-to-qrcodegencpp-to-avoid-conflict.patch
BuildRequires: %{python_module setuptools}
BuildRequires: gcc-c++
BuildRequires: python-rpm-macros
%python_subpackages
%description
This project aims to be the best, clearest QR Code generator library in multiple languages.
The primary goals are flexible options and absolute correctness.
Secondary goals are compact implementation size and good documentation comments.
%prep
%setup -q
%autopatch -p1
%build
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
pushd c
make -j1
popd
pushd cpp
make -j1
popd
pushd python
%python_build
popd
%install
pushd c
%make_install LIBDIR=%{buildroot}%{_libdir}
popd
pushd cpp
%make_install LIBDIR=%{buildroot}%{_libdir}
popd
pushd python
%python_install
popd
rm -rf %{buildroot}%{_libdir}/*.a
%files %{python_files}
%license Readme.markdown
%{python_sitelib}/*
%changelog

56
cflags.patch Normal file
View File

@ -0,0 +1,56 @@
From 7eac8beffeb935de5a2fdd65656d8cb500b0abda Mon Sep 17 00:00:00 2001
From: Project Nayuki <me@nayuki.io>
Date: Fri, 9 Aug 2019 23:00:13 +0000
Subject: [PATCH] Updated C and C++ makefiles to exclude warnings and
sanitizers by default, instead recommending extra flags for manually doing a
diagnostic/debug build.
---
c/Makefile | 11 +++++------
cpp/Makefile | 11 +++++------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/c/Makefile b/c/Makefile
index 99f926b..fd0c367 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -28,12 +28,11 @@
# - CC: The C compiler, such as gcc or clang.
# - CFLAGS: Any extra user-specified compiler flags (can be blank).
-# Mandatory compiler flags
-CFLAGS += -std=c99
-# Diagnostics. Adding '-fsanitize=address' is helpful for most versions of Clang and newer versions of GCC.
-CFLAGS += -Wall -fsanitize=undefined
-# Optimization level
-CFLAGS += -O1
+# Recommended compiler flags:
+CFLAGS += -std=c99 -O
+
+# Extra flags for diagnostics:
+# CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
# ---- Controlling make ----
diff --git a/cpp/Makefile b/cpp/Makefile
index 858a1bf..1d32943 100644
--- a/cpp/Makefile
+++ b/cpp/Makefile
@@ -28,12 +28,11 @@
# - CXX: The C++ compiler, such as g++ or clang++.
# - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
-# Mandatory compiler flags
-CXXFLAGS += -std=c++11
-# Diagnostics. Adding '-fsanitize=address' is helpful for most versions of Clang and newer versions of GCC.
-CXXFLAGS += -Wall -fsanitize=undefined
-# Optimization level
-CXXFLAGS += -O1
+# Recommended compiler flags:
+CXXFLAGS += -std=c++11 -O
+
+# Extra flags for diagnostics:
+# CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
# ---- Controlling make ----

3
v1.5.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6cf993c10fbf96b5e8f8e4eaad8ea1ca3bbc58fb4d00a4728b4f818c27fb4d5e
size 147230