qr-code-generator-build-fixes.patch 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. diff -urN QR-Code-generator-1.6.0.orig/c/Makefile QR-Code-generator-1.6.0/c/Makefile
  2. --- QR-Code-generator-1.6.0.orig/c/Makefile 2020-10-28 13:44:11.561734024 -0700
  3. +++ QR-Code-generator-1.6.0/c/Makefile 2020-10-28 13:47:38.512702152 -0700
  4. @@ -29,11 +29,15 @@
  5. # - CFLAGS: Any extra user-specified compiler flags (can be blank).
  6. # Recommended compiler flags:
  7. -CFLAGS += -std=c99 -O
  8. +CFLAGS += -O2
  9. +
  10. +MAIN_FLAGS := -std=c99 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
  11. # Extra flags for diagnostics:
  12. -# CFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
  13. +# MAIN_FLAGS += -g -fsanitize=undefined,address
  14. +# Version information
  15. +VERSION = 1.6.0
  16. # ---- Controlling make ----
  17. @@ -51,10 +55,19 @@
  18. # ---- Targets to build ----
  19. LIB = qrcodegen
  20. -LIBFILE = lib$(LIB).a
  21. +LIBFILE = lib$(LIB).so
  22. +# Bump the soname number when the ABI changes and gets incompatible
  23. +SO_NAME = $(LIBFILE).1
  24. +REAL_NAME = $(LIBFILE).$(VERSION)
  25. +HEADERS = qrcodegen.h
  26. LIBOBJ = qrcodegen.o
  27. MAINS = qrcodegen-demo qrcodegen-test qrcodegen-worker
  28. +# define paths to install
  29. +PREFIX ?= /usr/local
  30. +INCLUDEDIR ?= $(PREFIX)/include/qrcodegen
  31. +LIBDIR ?= $(PREFIX)/lib
  32. +
  33. # Build all binaries
  34. all: $(LIBFILE) $(MAINS)
  35. @@ -63,21 +76,33 @@
  36. rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
  37. rm -rf .deps
  38. +install-shared: $(LIBFILE)
  39. + mkdir -p $(DESTDIR)$(LIBDIR)
  40. + install -m 0755 $(LIBFILE) $(DESTDIR)$(LIBDIR)/$(REAL_NAME)
  41. + ln -s $(REAL_NAME) $(DESTDIR)$(LIBDIR)/$(SO_NAME)
  42. + ln -s $(SO_NAME) $(DESTDIR)$(LIBDIR)/$(LIBFILE)
  43. +
  44. +install-header: $(HEADERS)
  45. + mkdir -p $(DESTDIR)$(INCLUDEDIR)
  46. + install -m 0644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/
  47. +
  48. +install: install-shared install-header
  49. +
  50. # Executable files
  51. %: %.o $(LIBFILE)
  52. $(CC) $(CFLAGS) -o $@ $< -L . -l $(LIB)
  53. # Special executable
  54. qrcodegen-test: qrcodegen-test.c $(LIBOBJ:%.o=%.c)
  55. - $(CC) $(CFLAGS) -DQRCODEGEN_TEST -o $@ $^
  56. + $(CC) $(CFLAGS) $(MAIN_FLAGS) -DQRCODEGEN_TEST -o $@ $^
  57. # The library
  58. $(LIBFILE): $(LIBOBJ)
  59. - $(AR) -crs $@ -- $^
  60. + $(CC) $(CFLAGS) $(MAIN_FLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
  61. # Object files
  62. %.o: %.c .deps/timestamp
  63. - $(CC) $(CFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
  64. + $(CC) $(CFLAGS) $(MAIN_FLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
  65. # Have a place to store header dependencies automatically generated by compiler
  66. .deps/timestamp:
  67. diff -urN QR-Code-generator-1.6.0.orig/cpp/Makefile QR-Code-generator-1.6.0/cpp/Makefile
  68. --- QR-Code-generator-1.6.0.orig/cpp/Makefile 2020-10-28 13:44:11.561734024 -0700
  69. +++ QR-Code-generator-1.6.0/cpp/Makefile 2020-10-28 13:48:27.218164945 -0700
  70. @@ -29,11 +29,15 @@
  71. # - CXXFLAGS: Any extra user-specified compiler flags (can be blank).
  72. # Recommended compiler flags:
  73. -CXXFLAGS += -std=c++11 -O
  74. +CXXFLAGS ?= -O2
  75. +
  76. +MAIN_FLAGS := -std=c++11 -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion
  77. # Extra flags for diagnostics:
  78. -# CXXFLAGS += -g -Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -fsanitize=undefined,address
  79. +# MAIN_FLAGS += -g -fsanitize=undefined,address
  80. +# Version information
  81. +VERSION = 1.6.0
  82. # ---- Controlling make ----
  83. @@ -50,11 +54,20 @@
  84. # ---- Targets to build ----
  85. -LIB = qrcodegen
  86. -LIBFILE = lib$(LIB).a
  87. +LIB = qrcodegencpp
  88. +LIBFILE = lib$(LIB).so
  89. +# Bump the soname number when the ABI changes and gets incompatible
  90. +SO_NAME = $(LIBFILE).1
  91. +REAL_NAME = $(LIBFILE).$(VERSION)
  92. +HEADERS = QrCode.hpp
  93. LIBOBJ = QrCode.o
  94. MAINS = QrCodeGeneratorDemo QrCodeGeneratorWorker
  95. +# define paths to install
  96. +PREFIX ?= /usr/local
  97. +INCLUDEDIR ?= $(PREFIX)/include/qrcodegen
  98. +LIBDIR ?= $(PREFIX)/lib
  99. +
  100. # Build all binaries
  101. all: $(LIBFILE) $(MAINS)
  102. @@ -63,17 +76,29 @@
  103. rm -f -- $(LIBOBJ) $(LIBFILE) $(MAINS:=.o) $(MAINS)
  104. rm -rf .deps
  105. +install-shared: $(LIBFILE)
  106. + mkdir -p $(DESTDIR)$(LIBDIR)
  107. + install -m 0755 $(LIBFILE) $(DESTDIR)$(LIBDIR)/$(REAL_NAME)
  108. + ln -s $(REAL_NAME) $(DESTDIR)$(LIBDIR)/$(SO_NAME)
  109. + ln -s $(SO_NAME) $(DESTDIR)$(LIBDIR)/$(LIBFILE)
  110. +
  111. +install-header: $(HEADERS)
  112. + mkdir -p $(DESTDIR)$(INCLUDEDIR)
  113. + install -m 0644 $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/
  114. +
  115. +install: install-shared install-header
  116. +
  117. # Executable files
  118. %: %.o $(LIBFILE)
  119. - $(CXX) $(CXXFLAGS) -o $@ $< -L . -l $(LIB)
  120. + $(CXX) $(CXXFLAGS) $(MAIN_FLAGS) -o $@ $< -L . -l $(LIB)
  121. # The library
  122. $(LIBFILE): $(LIBOBJ)
  123. - $(AR) -crs $@ -- $^
  124. + $(CXX) $(CXXFLAGS) $(MAIN_FLAGS) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) -o $@ $^
  125. # Object files
  126. %.o: %.cpp .deps/timestamp
  127. - $(CXX) $(CXXFLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
  128. + $(CXX) $(CXXFLAGS) $(MAIN_FLAGS) -c -o $@ -MMD -MF .deps/$*.d $<
  129. # Have a place to store header dependencies automatically generated by compiler
  130. .deps/timestamp: