slackbuilds_ponce/libraries/QR-Code-generator/qr-code-generator-build-fixes.patch
Hunter Sezen f3588e2b51
libraries/QR-Code-generator: Added (QR Code generator library)
Signed-off-by: Dave Woodfall <dave@slackbuilds.org>

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
2020-10-31 11:15:23 +07:00

156 lines
4.6 KiB
Diff

diff -urN QR-Code-generator-1.6.0.orig/c/Makefile QR-Code-generator-1.6.0/c/Makefile
--- QR-Code-generator-1.6.0.orig/c/Makefile 2020-10-28 13:44:11.561734024 -0700
+++ QR-Code-generator-1.6.0/c/Makefile 2020-10-28 13:47:38.512702152 -0700
@@ -29,11 +29,15 @@
# - CFLAGS: Any extra user-specified compiler flags (can be blank).
# Recommended compiler flags:
-CFLAGS += -std=c99 -O
+CFLAGS += -O2
+
+MAIN_FLAGS := -std=c99 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
# Extra flags for diagnostics:
-# CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
+# MAIN_FLAGS += -g -fsanitize=undefined,address
+# Version information
+VERSION = 1.6.0
# ---- Controlling make ----
@@ -51,10 +55,19 @@
# ---- Targets to build ----
LIB = qrcodegen
-LIBFILE = 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
+PREFIX ?= /usr/local
+INCLUDEDIR ?= $(PREFIX)/include/qrcodegen
+LIBDIR ?= $(PREFIX)/lib
+
# Build all binaries
all: $(LIBFILE) $(MAINS)
@@ -63,21 +76,33 @@
rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
rm -rf .deps
+install-shared: $(LIBFILE)
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ install -m 0755 $(LIBFILE) $(DESTDIR)$(LIBDIR)/$(REAL_NAME)
+ ln -s $(REAL_NAME) $(DESTDIR)$(LIBDIR)/$(SO_NAME)
+ ln -s $(SO_NAME) $(DESTDIR)$(LIBDIR)/$(LIBFILE)
+
+install-header: $(HEADERS)
+ mkdir -p $(DESTDIR)$(INCLUDEDIR)
+ install -m 0644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/
+
+install: install-shared install-header
+
# Executable files
%: %.o $(LIBFILE)
$(CC) $(CFLAGS) -o $@ $< -L . -l $(LIB)
# Special executable
qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
- $(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $^
+ $(CC) $(CFLAGS) $(MAIN_FLAGS) -DQRCODEGEN_TEST -o $@ $^
# The library
$(LIBFILE): $(LIBOBJ)
- $(AR) -crs $@ -- $^
+ $(CC) $(CFLAGS) $(MAIN_FLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
# Object files
%.o: %.c .deps/timestamp
- $(CC) $(CFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
+ $(CC) $(CFLAGS) $(MAIN_FLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
# Have a place to store header dependencies automatically generated by compiler
.deps/timestamp:
diff -urN QR-Code-generator-1.6.0.orig/cpp/Makefile QR-Code-generator-1.6.0/cpp/Makefile
--- QR-Code-generator-1.6.0.orig/cpp/Makefile 2020-10-28 13:44:11.561734024 -0700
+++ QR-Code-generator-1.6.0/cpp/Makefile 2020-10-28 13:48:27.218164945 -0700
@@ -29,11 +29,15 @@
# - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
# Recommended compiler flags:
-CXXFLAGS += -std=c++11 -O
+CXXFLAGS ?= -O2
+
+MAIN_FLAGS := -std=c++11 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
# Extra flags for diagnostics:
-# CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
+# MAIN_FLAGS += -g -fsanitize=undefined,address
+# Version information
+VERSION = 1.6.0
# ---- Controlling make ----
@@ -50,11 +54,20 @@
# ---- Targets to build ----
-LIB = qrcodegen
-LIBFILE = lib$(LIB).a
+LIB = qrcodegencpp
+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
+PREFIX ?= /usr/local
+INCLUDEDIR ?= $(PREFIX)/include/qrcodegen
+LIBDIR ?= $(PREFIX)/lib
+
# Build all binaries
all: $(LIBFILE) $(MAINS)
@@ -63,17 +76,29 @@
rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
rm -rf .deps
+install-shared: $(LIBFILE)
+ mkdir -p $(DESTDIR)$(LIBDIR)
+ install -m 0755 $(LIBFILE) $(DESTDIR)$(LIBDIR)/$(REAL_NAME)
+ ln -s $(REAL_NAME) $(DESTDIR)$(LIBDIR)/$(SO_NAME)
+ ln -s $(SO_NAME) $(DESTDIR)$(LIBDIR)/$(LIBFILE)
+
+install-header: $(HEADERS)
+ mkdir -p $(DESTDIR)$(INCLUDEDIR)
+ install -m 0644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/
+
+install: install-shared install-header
+
# Executable files
%: %.o $(LIBFILE)
- $(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)
+ $(CXX) $(CXXFLAGS) $(MAIN_FLAGS) -o $@ $< -L . -l $(LIB)
# The library
$(LIBFILE): $(LIBOBJ)
- $(AR) -crs $@ -- $^
+ $(CXX) $(CXXFLAGS) $(MAIN_FLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
# Object files
%.o: %.cpp .deps/timestamp
- $(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
+ $(CXX) $(CXXFLAGS) $(MAIN_FLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
# Have a place to store header dependencies automatically generated by compiler
.deps/timestamp: