summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/qrcodegen-cpp-make-install.patch
blob: 4da619d3c8312c0c7e3ae8aafbf60caec8f82c26 (about) (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
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?= <tchvatal@suse.com>
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?= <tchvatal@suse.com>
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?= <tchvatal@suse.com>
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?= <tchvatal@suse.com>
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?= <tchvatal@suse.com>
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?= <tchvatal@suse.com>
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?= <tchvatal@suse.com>
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