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
|
# cqrlogo - CGI QR-Code logo for web services
# pathes
PREFIX := /usr
APACHECONF := /etc/httpd/conf/extra/
LIGHTTPDCONF := /etc/lighttpd/conf.d/
# commands
CC := gcc
CP := cp
FILE := file
GREP := grep
INSTALL := install
LN := ln
MD := markdown
RM := rm
SED := sed
ZBARIMG := zbarimg
# flags
CFLAGS += -O2 -Wall -Werror
# calls to compiled binary files
CQRLOGO_CGI += LD_LIBRARY_PATH=lib/ ./cqrlogo.cgi
CQRLOGO_FCGI += LD_LIBRARY_PATH=lib/ ./cqrlogo.fcgi
# this is just a fallback in case you do not use git but downloaded
# a release tarball...
VERSION := 0.5.0
# library abi version
SOVERSION := 0
all: lib/libcqrlogo.so cqrlogo.cgi cqrlogo.fcgi README.html cqrlogo.png
lib/libcqrlogo.so: lib/libcqrlogo.c lib/libcqrlogo.h config.h version.h
SOVERSION=$(SOVERSION) $(MAKE) -C lib
cqrlogo.cgi: lib/libcqrlogo.so cqrlogo.c cqrlogo.h config.h version.h
$(CC) $(CFLAGS) -lcqrlogo -Llib/ -Ilib/ $(LDFLAGS) -DHAVE_FCGI=0 -o cqrlogo.cgi cqrlogo.c
cqrlogo.fcgi: lib/libcqrlogo.so cqrlogo.c cqrlogo.h config.h version.h
$(CC) $(CFLAGS) -lcqrlogo -Llib/ -Ilib/ -lfcgi $(LDFLAGS) -DHAVE_FCGI=1 -o cqrlogo.fcgi cqrlogo.c
version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
echo "#ifndef VERSION" > $@
echo "#define VERSION \"$(shell git describe --tags --long 2>/dev/null || echo ${VERSION})\"" >> $@
echo "#endif" >> $@
config.h: config.def.h
$(CP) config.def.h config.h
README.html: README.md
$(MD) README.md > README.html
cqrlogo.png: cqrlogo.cgi
SERVER_NAME="github.com" HTTP_REFERER="https://github.com/eworm-de/cqrlogo" \
QUERY_STRING='scale=4' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > cqrlogo.png
install: install-bin install-config install-doc
install-bin: lib/libcqrlogo.so lib/libcqrlogo.h cqrlogo.cgi cqrlogo.fcgi cqrlogo.conf
$(INSTALL) -D -m0755 lib/libcqrlogo.so.$(SOVERSION) $(DESTDIR)$(PREFIX)/lib/libcqrlogo.so.$(SOVERSION)
$(INSTALL) -D -m0755 lib/libcqrlogo.h $(DESTDIR)$(PREFIX)/include/libcqrlogo.h
$(LN) -sf libcqrlogo.so.$(SOVERSION) $(DESTDIR)$(PREFIX)/lib/libcqrlogo.so
$(INSTALL) -D -m0755 cqrlogo.cgi $(DESTDIR)$(PREFIX)/lib/cqrlogo/cqrlogo.cgi
$(INSTALL) -D -m0755 cqrlogo.fcgi $(DESTDIR)$(PREFIX)/lib/cqrlogo/cqrlogo.fcgi
$(INSTALL) -D -m0644 cqrlogo.conf $(DESTDIR)/etc/cqrlogo.conf
install-config: config/apache.conf config/lighttpd.conf
$(INSTALL) -D -m0644 config/apache.conf $(DESTDIR)$(APACHECONF)/cqrlogo.conf
$(INSTALL) -D -m0644 config/lighttpd.conf $(DESTDIR)$(LIGHTTPDCONF)/cqrlogo.conf
install-doc: README.md README.html cqrlogo.png
$(INSTALL) -D -m0644 README.md $(DESTDIR)$(PREFIX)/share/doc/cqrlogo/README.md
$(INSTALL) -D -m0644 README.html $(DESTDIR)$(PREFIX)/share/doc/cqrlogo/README.html
$(INSTALL) -D -m0644 cqrlogo.png $(DESTDIR)$(PREFIX)/share/doc/cqrlogo/cqrlogo.png
check:
$(eval SERVER := www.eworm.de)
$(RM) -f check.png
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=https://$(SERVER)/ HTTPS=on \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^https://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=0' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=4' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=20' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=0' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=2' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10&level=0' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10&level=2' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10&level=4' \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=eworm.net HTTP_REFERER=http://$(SERVER)/ \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | \
$(GREP) -e '^This QR Code has been stolen from http://eworm.net/!$$'
SERVER_NAME=eworm.net HTTP_REFERER=https://$(SERVER)/ HTTPS=on \
$(CQRLOGO_CGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | \
$(GREP) -e '^This QR Code has been stolen from https://eworm.net/!$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=https://$(SERVER)/ HTTPS=on \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^https://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=0' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=4' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=20' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=0' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=2' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10&level=0' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10&level=2' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
QUERY_STRING='scale=2&border=10&level=4' \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | $(GREP) -e '^http://$(SERVER)/$$'
SERVER_NAME=eworm.net HTTP_REFERER=http://$(SERVER)/ \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | \
$(GREP) -e '^This QR Code has been stolen from http://eworm.net/!$$'
SERVER_NAME=eworm.net HTTP_REFERER=https://$(SERVER)/ HTTPS=on \
$(CQRLOGO_FCGI) | $(SED) '1,/^$$/d' > \
check.png
$(FILE) check.png | $(GREP) 'PNG image data'
$(ZBARIMG) --raw -q check.png | \
$(GREP) -e '^This QR Code has been stolen from https://eworm.net/!$$'
clean:
$(RM) -f *.o *~ *.png README.html lib/libcqrlogo.so lib/libcqrlogo.so.* cqrlogo.cgi cqrlogo.fcgi version.h
distclean:
$(RM) -f *.o *~ *.png README.html lib/libcqrlogo.so lib/libcqrlogo.so.* cqrlogo.cgi cqrlogo.fcgi version.h config.h
release:
git archive --format=tar.xz --prefix=cqrlogo-$(VERSION)/ $(VERSION) > cqrlogo-$(VERSION).tar.xz
gpg -ab cqrlogo-$(VERSION).tar.xz
|