aboutsummaryrefslogtreecommitdiff
path: root/libraries/QR-Code-generator/qr-code-generator-build-fixes.patch
blob: 4acdfe49999832090b65f5eff2ea2942a753a4e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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: