Sfoglia il codice sorgente

libqrencode: import from old packages

Update to latest release
add qrencode package which contains the qrencode binary
Remove libpng dependancy
Signed-off-by: Jonathan Bennett <jbennett@incomsystems.biz>
Jonathan Bennett 10 anni fa
parent
commit
5c241d1498
2 ha cambiato i file con 383 aggiunte e 0 eliminazioni
  1. 90
    0
      libs/qrencode/Makefile
  2. 293
    0
      libs/qrencode/patches/001-disable-png.patch

+ 90
- 0
libs/qrencode/Makefile Vedi File

@@ -0,0 +1,90 @@
1
+#
2
+# Copyright (C) 2006-2012 OpenWrt.org
3
+#
4
+# This is free software, licensed under the GNU General Public License v2.
5
+# See /LICENSE for more information.
6
+#
7
+
8
+include $(TOPDIR)/rules.mk
9
+
10
+PKG_NAME:=qrencode
11
+PKG_VERSION:=3.4.4
12
+PKG_RELEASE:=1
13
+
14
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15
+PKG_SOURCE_URL:=http://fukuchi.org/works/qrencode/
16
+PKG_MD5SUM:=be545f3ce36ea8fbb58612d72c4222de
17
+PKG_MAINTAINER:=Jonathan Bennett <JBennett@incomsystems.biz>
18
+PKG_LICENSE:=LGPL-2.1+
19
+PKG_INSTALL:=1
20
+PKG:FIXUP:=autoreconf
21
+
22
+include $(INCLUDE_DIR)/package.mk
23
+
24
+define Package/libqrencode
25
+  SECTION:=libs
26
+  CATEGORY:=Libraries
27
+  TITLE:=Library for encoding data in a QR Code symbol
28
+  URL:=http://fukuchi.org/works/qrencode/
29
+endef
30
+
31
+define Package/libqrencode/description
32
+Libqrencode is a C library for encoding data in a QR Code symbol,
33
+a kind of 2D symbology that can be scanned by handy terminals such
34
+as a mobile phone with CCD. The capacity of QR Code is up to 7000
35
+digits or 4000 characters, and is highly robust.
36
+endef
37
+
38
+define Package/qrencode
39
+  SECTION:=utils
40
+  CATEGORY:=Utilities
41
+  TITLE:=qrencode binary for producing qr codes
42
+  URL:=http://fukuchi.org/works/qrencode/
43
+  DEPENDS:=+libqrencode
44
+endef
45
+
46
+define Package/qrencode/description
47
+Qrencode is a C program for encoding data in a QR Code symbol,
48
+a kind of 2D symbology that can be scanned by handy terminals such
49
+as a mobile phone with CCD. The capacity of QR Code is up to 7000
50
+digits or 4000 characters, and is highly robust.
51
+endef
52
+
53
+
54
+CONFIGURE_ARGS+= \
55
+	--enable-shared \
56
+	--enable-static \
57
+	--disable-rpath \
58
+	--disable-sdltest \
59
+	--without-tests 
60
+
61
+TARGET_LDFLAGS+= -s
62
+
63
+define Build/Compile
64
+	$(MAKE) -C $(PKG_BUILD_DIR) \
65
+		$(TARGET_CONFIGURE_OPTS) \
66
+		CFLAGS="$(TARGET_CFLAGS)" \
67
+		LDFLAGS="$(TARGET_LDFLAGS)" \
68
+		DESTDIR="$(PKG_INSTALL_DIR)" \
69
+		all install
70
+endef
71
+
72
+define Build/InstallDev
73
+	$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
74
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/qrencode.h $(1)/usr/include/
75
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libqrencode.{a,so*} $(1)/usr/lib/
76
+	$(CP) $(PKG_BUILD_DIR)/libqrencode.pc $(1)/usr/lib/pkgconfig/
77
+endef
78
+
79
+define Package/libqrencode/install
80
+	$(INSTALL_DIR) $(1)/usr/lib
81
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libqrencode.so* $(1)/usr/lib/
82
+endef
83
+
84
+define Package/qrencode/install
85
+	$(INSTALL_DIR) $(1)/usr/bin
86
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/qrencode $(1)/usr/bin/
87
+endef
88
+
89
+$(eval $(call BuildPackage,libqrencode))
90
+$(eval $(call BuildPackage,qrencode))

+ 293
- 0
libs/qrencode/patches/001-disable-png.patch Vedi File

@@ -0,0 +1,293 @@
1
+--- a/configure.ac
2
++++ b/configure.ac
3
+@@ -58,9 +58,6 @@
4
+  [build_tools=$withval], [build_tools=yes])
5
+ 
6
+ AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
7
+-if test x$build_tools = xyes ; then
8
+-	PKG_CHECK_MODULES(png, "libpng")
9
+-fi
10
+ 
11
+ dnl --with-tests
12
+ AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [build tests [default=no]])],
13
+--- a/qrenc.c
14
++++ b/qrenc.c
15
+@@ -25,7 +25,6 @@
16
+ #include <stdio.h>
17
+ #include <stdlib.h>
18
+ #include <string.h>
19
+-#include <png.h>
20
+ #include <getopt.h>
21
+ 
22
+ #include "qrencode.h"
23
+@@ -49,7 +48,6 @@
24
+ static int verbose = 0;
25
+ 
26
+ enum imageType {
27
+-	PNG_TYPE,
28
+ 	EPS_TYPE,
29
+ 	SVG_TYPE,
30
+ 	ANSI_TYPE,
31
+@@ -60,7 +58,7 @@
32
+ 	ANSIUTF8_TYPE
33
+ };
34
+ 
35
+-static enum imageType image_type = PNG_TYPE;
36
++static enum imageType image_type = SVG_TYPE;
37
+ 
38
+ static const struct option options[] = {
39
+ 	{"help"         , no_argument      , NULL, 'h'},
40
+@@ -96,13 +94,13 @@
41
+ 		if(longopt) {
42
+ 			fprintf(stderr,
43
+ "Usage: qrencode [OPTION]... [STRING]\n"
44
+-"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
45
++"Encode input data in a QR Code and save as a SVG or EPS image.\n\n"
46
+ "  -h, --help   display the help message. -h displays only the help of short\n"
47
+ "               options.\n\n"
48
+ "  -o FILENAME, --output=FILENAME\n"
49
+ "               write image to FILENAME. If '-' is specified, the result\n"
50
+ "               will be output to standard output. If -S is given, structured\n"
51
+-"               symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
52
++"               symbols are written to FILENAME-01.svg, FILENAME-02.svg, ...\n"
53
+ "               (suffix is removed from FILENAME, if specified)\n"
54
+ "  -s NUMBER, --size=NUMBER\n"
55
+ "               specify module size in dots (pixels). (default=3)\n\n"
56
+@@ -116,9 +114,9 @@
57
+ "               specify the width of the margins. (default=4 (2 for Micro QR)))\n\n"
58
+ "  -d NUMBER, --dpi=NUMBER\n"
59
+ "               specify the DPI of the generated PNG. (default=72)\n\n"
60
+-"  -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={PNG,EPS,\n"
61
++"  -t {EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={EPS,\n"
62
+ "               SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
63
+-"               specify the type of the generated image. (default=PNG)\n\n"
64
++"               specify the type of the generated image. (default=SVG)\n\n"
65
+ "  -S, --structured\n"
66
+ "               make structured symbols. Version must be specified.\n\n"
67
+ "  -k, --kanji  assume that the input text contains kanji (shift-jis).\n\n"
68
+@@ -133,7 +131,7 @@
69
+ "      --background=RRGGBB[AA]\n"
70
+ "               specify foreground/background color in hexadecimal notation.\n"
71
+ "               6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
72
+-"               Color output support available only in PNG and SVG.\n"
73
++"               Color output support available only in SVG.\n"
74
+ "  -V, --version\n"
75
+ "               display the version number and copyrights of the qrencode.\n\n"
76
+ "      --verbose\n"
77
+@@ -153,12 +151,12 @@
78
+ 		} else {
79
+ 			fprintf(stderr,
80
+ "Usage: qrencode [OPTION]... [STRING]\n"
81
+-"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
82
++"Encode input data in a QR Code and save as a SVG or EPS image.\n\n"
83
+ "  -h           display this message.\n"
84
+ "  --help       display the usage of long options.\n"
85
+ "  -o FILENAME  write image to FILENAME. If '-' is specified, the result\n"
86
+ "               will be output to standard output. If -S is given, structured\n"
87
+-"               symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
88
++"               symbols are written to FILENAME-01.svg, FILENAME-02.svg, ...\n"
89
+ "               (suffix is removed from FILENAME, if specified)\n"
90
+ "  -s NUMBER    specify module size in dots (pixels). (default=3)\n"
91
+ "  -l {LMQH}    specify error correction level from L (lowest) to H (highest).\n"
92
+@@ -166,8 +164,8 @@
93
+ "  -v NUMBER    specify the version of the symbol. (default=auto)\n"
94
+ "  -m NUMBER    specify the width of the margins. (default=4 (2 for Micro))\n"
95
+ "  -d NUMBER    specify the DPI of the generated PNG. (default=72)\n"
96
+-"  -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
97
+-"               specify the type of the generated image. (default=PNG)\n"
98
++"  -t {EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
99
++"               specify the type of the generated image. (default=SVG)\n"
100
+ "  -S           make structured symbols. Version must be specified.\n"
101
+ "  -k           assume that the input text contains kanji (shift-jis).\n"
102
+ "  -c           encode lower-case alphabet characters in 8-bit mode. (default)\n"
103
+@@ -178,7 +176,7 @@
104
+ "  --background=RRGGBB[AA]\n"
105
+ "               specify foreground/background color in hexadecimal notation.\n"
106
+ "               6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
107
+-"               Color output support available only in PNG and SVG.\n"
108
++"               Color output support available only in SVG.\n"
109
+ "  -V           display the version number and copyrights of the qrencode.\n"
110
+ "  [STRING]     input data. If it is not specified, data will be taken from\n"
111
+ "               standard input.\n"
112
+@@ -253,128 +251,6 @@
113
+ 	return fp;
114
+ }
115
+ 
116
+-static int writePNG(QRcode *qrcode, const char *outfile)
117
+-{
118
+-	static FILE *fp; // avoid clobbering by setjmp.
119
+-	png_structp png_ptr;
120
+-	png_infop info_ptr;
121
+-	png_colorp palette;
122
+-	png_byte alpha_values[2];
123
+-	unsigned char *row, *p, *q;
124
+-	int x, y, xx, yy, bit;
125
+-	int realwidth;
126
+-
127
+-	realwidth = (qrcode->width + margin * 2) * size;
128
+-	row = (unsigned char *)malloc((realwidth + 7) / 8);
129
+-	if(row == NULL) {
130
+-		fprintf(stderr, "Failed to allocate memory.\n");
131
+-		exit(EXIT_FAILURE);
132
+-	}
133
+-
134
+-	if(outfile[0] == '-' && outfile[1] == '\0') {
135
+-		fp = stdout;
136
+-	} else {
137
+-		fp = fopen(outfile, "wb");
138
+-		if(fp == NULL) {
139
+-			fprintf(stderr, "Failed to create file: %s\n", outfile);
140
+-			perror(NULL);
141
+-			exit(EXIT_FAILURE);
142
+-		}
143
+-	}
144
+-
145
+-	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
146
+-	if(png_ptr == NULL) {
147
+-		fprintf(stderr, "Failed to initialize PNG writer.\n");
148
+-		exit(EXIT_FAILURE);
149
+-	}
150
+-
151
+-	info_ptr = png_create_info_struct(png_ptr);
152
+-	if(info_ptr == NULL) {
153
+-		fprintf(stderr, "Failed to initialize PNG write.\n");
154
+-		exit(EXIT_FAILURE);
155
+-	}
156
+-
157
+-	if(setjmp(png_jmpbuf(png_ptr))) {
158
+-		png_destroy_write_struct(&png_ptr, &info_ptr);
159
+-		fprintf(stderr, "Failed to write PNG image.\n");
160
+-		exit(EXIT_FAILURE);
161
+-	}
162
+-
163
+-	palette = (png_colorp) malloc(sizeof(png_color) * 2);
164
+-	if(palette == NULL) {
165
+-		fprintf(stderr, "Failed to allocate memory.\n");
166
+-		exit(EXIT_FAILURE);
167
+-	}
168
+-	palette[0].red   = fg_color[0];
169
+-	palette[0].green = fg_color[1];
170
+-	palette[0].blue  = fg_color[2];
171
+-	palette[1].red   = bg_color[0];
172
+-	palette[1].green = bg_color[1];
173
+-	palette[1].blue  = bg_color[2];
174
+-	alpha_values[0] = fg_color[3];
175
+-	alpha_values[1] = bg_color[3];
176
+-	png_set_PLTE(png_ptr, info_ptr, palette, 2);
177
+-	png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
178
+-
179
+-	png_init_io(png_ptr, fp);
180
+-	png_set_IHDR(png_ptr, info_ptr,
181
+-			realwidth, realwidth,
182
+-			1,
183
+-			PNG_COLOR_TYPE_PALETTE,
184
+-			PNG_INTERLACE_NONE,
185
+-			PNG_COMPRESSION_TYPE_DEFAULT,
186
+-			PNG_FILTER_TYPE_DEFAULT);
187
+-	png_set_pHYs(png_ptr, info_ptr,
188
+-			dpi * INCHES_PER_METER,
189
+-			dpi * INCHES_PER_METER,
190
+-			PNG_RESOLUTION_METER);
191
+-	png_write_info(png_ptr, info_ptr);
192
+-
193
+-	/* top margin */
194
+-	memset(row, 0xff, (realwidth + 7) / 8);
195
+-	for(y=0; y<margin * size; y++) {
196
+-		png_write_row(png_ptr, row);
197
+-	}
198
+-
199
+-	/* data */
200
+-	p = qrcode->data;
201
+-	for(y=0; y<qrcode->width; y++) {
202
+-		bit = 7;
203
+-		memset(row, 0xff, (realwidth + 7) / 8);
204
+-		q = row;
205
+-		q += margin * size / 8;
206
+-		bit = 7 - (margin * size % 8);
207
+-		for(x=0; x<qrcode->width; x++) {
208
+-			for(xx=0; xx<size; xx++) {
209
+-				*q ^= (*p & 1) << bit;
210
+-				bit--;
211
+-				if(bit < 0) {
212
+-					q++;
213
+-					bit = 7;
214
+-				}
215
+-			}
216
+-			p++;
217
+-		}
218
+-		for(yy=0; yy<size; yy++) {
219
+-			png_write_row(png_ptr, row);
220
+-		}
221
+-	}
222
+-	/* bottom margin */
223
+-	memset(row, 0xff, (realwidth + 7) / 8);
224
+-	for(y=0; y<margin * size; y++) {
225
+-		png_write_row(png_ptr, row);
226
+-	}
227
+-
228
+-	png_write_end(png_ptr, info_ptr);
229
+-	png_destroy_write_struct(&png_ptr, &info_ptr);
230
+-
231
+-	fclose(fp);
232
+-	free(row);
233
+-	free(palette);
234
+-
235
+-	return 0;
236
+-}
237
+-
238
+ static int writeEPS(QRcode *qrcode, const char *outfile)
239
+ {
240
+ 	FILE *fp;
241
+@@ -831,9 +707,6 @@
242
+ 	}
243
+ 
244
+ 	switch(image_type) {
245
+-		case PNG_TYPE:
246
+-			writePNG(qrcode, outfile);
247
+-			break;
248
+ 		case EPS_TYPE:
249
+ 			writeEPS(qrcode, outfile);
250
+ 			break;
251
+@@ -887,9 +760,6 @@
252
+ 	size_t suffix_size;
253
+ 
254
+ 	switch(image_type) {
255
+-		case PNG_TYPE:
256
+-			type_suffix = ".png";
257
+-			break;
258
+ 		case EPS_TYPE:
259
+ 			type_suffix = ".eps";
260
+ 			break;
261
+@@ -948,9 +818,6 @@
262
+ 		}
263
+ 
264
+ 		switch(image_type) {
265
+-			case PNG_TYPE: 
266
+-				writePNG(p->code, filename);
267
+-				break;
268
+ 			case EPS_TYPE: 
269
+ 				writeEPS(p->code, filename);
270
+ 				break;
271
+@@ -1062,9 +929,7 @@
272
+ 				}
273
+ 				break;
274
+ 			case 't':
275
+-				if(strcasecmp(optarg, "png") == 0) {
276
+-					image_type = PNG_TYPE;
277
+-				} else if(strcasecmp(optarg, "eps") == 0) {
278
++				if(strcasecmp(optarg, "eps") == 0) {
279
+ 					image_type = EPS_TYPE;
280
+ 				} else if(strcasecmp(optarg, "svg") == 0) {
281
+ 					image_type = SVG_TYPE;
282
+@@ -1133,11 +998,6 @@
283
+ 		exit(EXIT_SUCCESS);
284
+ 	}
285
+ 
286
+-	if(outfile == NULL && image_type == PNG_TYPE) {
287
+-		fprintf(stderr, "No output filename is given.\n");
288
+-		exit(EXIT_FAILURE);
289
+-	}
290
+-
291
+ 	if(optind < argc) {
292
+ 		intext = (unsigned char *)argv[optind];
293
+ 		length = strlen((char *)intext);