aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 365c0e9a0ce060a5cfa19a0d62dc326a04cad39d (about) (plain) (blame)
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
# cqrlogo - CGI QR-Code logo for web services

CC	:= gcc
INSTALL	:= install
CP	:= cp
RM	:= rm
ZBARIMG	:= zbarimg
SED	:= sed
GREP	:= grep
FILE	:= file
CFLAGS	+= -O2 -Wall -Werror
CFLAGS	+= $(shell pkg-config --cflags --libs libpng) \
	   $(shell pkg-config --cflags --libs zlib) \
	   $(shell pkg-config --cflags --libs libqrencode)
VERSION	= $(shell git describe --tags --long)

all: cqrlogo.c config.h
	$(CC) $(CFLAGS) -o cqrlogo cqrlogo.c \
		-DVERSION="\"$(VERSION)\""

config.h:
	$(CP) config.def.h config.h

install:
	$(INSTALL) -D -m0755 cqrlogo $(DESTDIR)/usr/share/webapps/cqrlogo/cqrlogo

check:
	$(eval SERVER := www.eworm.de)
	$(RM) -f check.png

	SERVER_NAME=$(SERVER) HTTP_REFERER=http://$(SERVER)/ \
		    ./cqrlogo | $(SED) '1,2d' > 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=0' \
		./cqrlogo | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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=10' \
		./cqrlogo | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		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 | $(SED) '1,2d' > \
		check.png
	$(FILE) check.png | $(GREP) 'PNG image data'
	$(ZBARIMG) --raw -q check.png | \
		$(GREP) -e '^This QR Code has been stolen from eworm.net!$$'

clean:
	$(RM) -f *.o *~ cqrlogo