xref: /netbsd-src/usr.bin/vndcompress/Makefile (revision 75219f3a016dfaad1cb304eb017f9787b1de8292)
1PROG=	vndcompress
2SRCS=	main.c vndcompress.c vnduncompress.c
3
4LINKS=	${BINDIR}/vndcompress ${BINDIR}/vnduncompress
5MLINKS=	vndcompress.1 vnduncompress.1
6
7DPADD+=	${LIBZ}
8LDADD+=	-lz
9
10.include <bsd.prog.mk>
11
12TESTFILES+=	oneblock
13XFAIL+=		oneblock.in-outx
14XFAIL+=		oneblock.cl2-cl2x
15oneblock.in:
16	head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \
17	&& mv -f ${.TARGET}.tmp ${.TARGET}
18
19TESTFILES+=	tenblock
20XFAIL+=		tenblock.in-outx
21XFAIL+=		tenblock.cl2-cl2x
22tenblock.in:
23	head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \
24	&& mv -f ${.TARGET}.tmp ${.TARGET}
25
26TESTFILES+=	smallfile
27XFAIL+=		smallfile.in-outx
28XFAIL+=		smallfile.cl2-cl2x
29smallfile.in:
30	head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \
31	&& mv -f ${.TARGET}.tmp ${.TARGET}
32
33CHECKS+=	check-pipe
34CLEANFILES+=	smallfile.cl2pipe
35check-pipe: .PHONY smallfile.cl2 smallfile.cl2pipe
36	cmp ${.ALLSRC}
37smallfile.cl2pipe: smallfile.in vndcompress
38	head -c 54321 < /usr/share/dict/words \
39	| ./vndcompress -l 12345 /dev/stdin ${.TARGET}.tmp \
40	&& mv -f ${.TARGET}.tmp ${.TARGET}
41
42TESTFILES+=	onechunk
43onechunk.in:
44	head -c 65536 < /usr/share/dict/words > ${.TARGET}.tmp \
45	&& mv -f ${.TARGET}.tmp ${.TARGET}
46
47TESTFILES+=	tenchunk
48tenchunk.in:
49	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
50	&& mv -f ${.TARGET}.tmp ${.TARGET}
51
52TESTFILES+=	extrablock
53XFAIL+=		extrablock.in-outx
54XFAIL+=		extrablock.cl2-cl2x
55extrablock.in:
56	head -c $$((65536 + 512)) < /usr/share/dict/words > ${.TARGET}.tmp \
57	&& mv -f ${.TARGET}.tmp ${.TARGET}
58
59TESTFILES+=	medfile
60XFAIL+=		medfile.in-outx
61XFAIL+=		medfile.cl2-cl2x
62medfile.in:
63	head -c 123456 < /usr/share/dict/words > ${.TARGET}.tmp \
64	&& mv -f ${.TARGET}.tmp ${.TARGET}
65
66TESTFILES+=		onetinyblock
67BLOCKSIZE.onetinyblock=	512
68onetinyblock.in:
69	head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \
70	&& mv -f ${.TARGET}.tmp ${.TARGET}
71
72TESTFILES+=		tentinyblock
73BLOCKSIZE.tentinyblock=	512
74tentinyblock.in:
75	head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \
76	&& mv -f ${.TARGET}.tmp ${.TARGET}
77
78CHECKS+=	check-pipe-restart
79CLEANFILES+=	piperestart.in piperestart.in.tmp
80CLEANFILES+=	piperestart.cl2 piperestart.cl2.tmp
81CLEANFILES+=	piperestart.cl2restart piperestart.cl2restart.tmp
82CLEANFILES+=	piperestart.cl2part piperestart.cl2part.tmp
83check-pipe-restart: .PHONY piperestart.cl2 piperestart.cl2restart
84	cmp ${.ALLSRC}
85piperestart.cl2restart: piperestart.cl2part vndcompress
86	cp piperestart.cl2part ${.TARGET}.tmp \
87	&& head -c 700000 < /usr/share/dict/words \
88	| ./vndcompress -l 655360 -k 1 -rR /dev/stdin ${.TARGET}.tmp \
89	&& mv -f ${.TARGET}.tmp ${.TARGET}
90piperestart.cl2part: vndcompress
91	head -c 600000 < /usr/share/dict/words \
92	| ./vndcompress -l 655360 -k 1 /dev/stdin ${.TARGET}.tmp; \
93	mv -f ${.TARGET}.tmp ${.TARGET}
94piperestart.in:
95	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
96	&& mv -f ${.TARGET}.tmp ${.TARGET}
97
98CHECKS+=	check-part
99CLEANFILES+=	part.orig part.cl2part part.cl2 part.out
100check-part: .PHONY part.orig part.out
101	cmp part.orig part.out
102part.cl2: part.orig part.cl2part vndcompress
103	cp part.cl2part ${.TARGET}.tmp \
104	&& ./vndcompress -s 512 -rR part.orig ${.TARGET}.tmp \
105	&& mv -f ${.TARGET}.tmp ${.TARGET}
106part.cl2part: part.orig vndcompress
107	./vndcompress -s 512 -p 10 part.orig ${.TARGET}.tmp \
108	&& mv -f ${.TARGET}.tmp ${.TARGET}
109part.orig:
110	head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \
111	&& mv -f ${.TARGET}.tmp ${.TARGET}
112
113TESTSUFFIXES+=	in cl2 cl2x out outx
114
115TESTFORMS+=	cl2 cl2x
116TESTFORMS+=	in out
117TESTFORMS+=	in outx
118
119.for testfile in ${TESTFILES}
120.  for suffix in ${TESTSUFFIXES}
121CLEANFILES+=	${testfile}.${suffix}
122CLEANFILES+=	${testfile}.${suffix}.tmp
123.  endfor
124.  for left right in ${TESTFORMS}
125CHECKS.${testfile}+=	check-${testfile}.${left}-${right}
126check-${testfile}.${left}-${right}: .PHONY \
127  ${testfile}.${left} ${testfile}.${right}
128.    if empty(XFAIL:M${testfile}.${left}-${right})
129	cmp ${testfile}.${left} ${testfile}.${right}
130.    else
131	@echo '# expecting failure...' \
132	&& echo 'cmp ${testfile}.${left} ${testfile}.${right}' \
133	&& if cmp ${testfile}.${left} ${testfile}.${right}; then \
134	  echo 'unexpected pass!' \
135	  && exit 1; \
136	fi
137.    endif
138.  endfor
139check-${testfile}: ${CHECKS.${testfile}}
140CHECKS+=	check-${testfile}
141.endfor
142
143check: .PHONY ${CHECKS}
144
145.SUFFIXES: .cl2 .cl2x .in .out .outx
146
147.in.cl2: vndcompress
148	./vndcompress ${.IMPSRC} ${.TARGET} ${BLOCKSIZE.${.PREFIX}}
149
150.in.cl2x:
151	vndcompress ${.IMPSRC} ${.TARGET} ${BLOCKSIZE.${.PREFIX}}
152
153.cl2.out: vndcompress
154	./vndcompress -d ${.IMPSRC} ${.TARGET}
155
156.cl2.outx:
157	vnduncompress ${.IMPSRC} ${.TARGET}
158