Home | History | Annotate | Line # | Download | only in vndcompress
Makefile revision 1.2.8.2
      1      1.1  hubertf PROG=	vndcompress
      2  1.2.8.1   martin SRCS=	main.c offtab.c utils.c vndcompress.c vnduncompress.c
      3  1.2.8.1   martin 
      4  1.2.8.1   martin LINKS=	${BINDIR}/vndcompress ${BINDIR}/vnduncompress
      5  1.2.8.1   martin MLINKS=	vndcompress.1 vnduncompress.1
      6  1.2.8.1   martin 
      7  1.2.8.1   martin DPADD+=	${LIBZ}
      8      1.1  hubertf LDADD+=	-lz
      9      1.1  hubertf 
     10  1.2.8.1   martin WARNS=	5
     11  1.2.8.1   martin 
     12      1.1  hubertf .include <bsd.prog.mk>
     13  1.2.8.1   martin 
     14  1.2.8.1   martin TESTFILES+=	oneblock
     15  1.2.8.1   martin XFAIL+=		oneblock.in-outx
     16  1.2.8.1   martin XFAIL+=		oneblock.cl2-cl2x
     17  1.2.8.1   martin oneblock.in:
     18  1.2.8.1   martin 	head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \
     19  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     20  1.2.8.1   martin 
     21  1.2.8.1   martin TESTFILES+=	tenblock
     22  1.2.8.1   martin XFAIL+=		tenblock.in-outx
     23  1.2.8.1   martin XFAIL+=		tenblock.cl2-cl2x
     24  1.2.8.1   martin tenblock.in:
     25  1.2.8.1   martin 	head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \
     26  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     27  1.2.8.1   martin 
     28  1.2.8.1   martin TESTFILES+=	smallfile
     29  1.2.8.1   martin XFAIL+=		smallfile.in-outx
     30  1.2.8.1   martin XFAIL+=		smallfile.cl2-cl2x
     31  1.2.8.1   martin smallfile.in:
     32  1.2.8.1   martin 	head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \
     33  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     34  1.2.8.1   martin 
     35  1.2.8.1   martin CHECKS+=	check-pipe
     36  1.2.8.1   martin CLEANFILES+=	smallfile.cl2pipe
     37  1.2.8.1   martin check-pipe: .PHONY smallfile.cl2 smallfile.cl2pipe
     38  1.2.8.1   martin 	cmp ${.ALLSRC}
     39  1.2.8.1   martin smallfile.cl2pipe: smallfile.in vndcompress
     40  1.2.8.1   martin 	head -c 54321 < /usr/share/dict/words \
     41  1.2.8.1   martin 	| ./vndcompress -l 12345 /dev/stdin ${.TARGET}.tmp \
     42  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     43  1.2.8.1   martin 
     44  1.2.8.1   martin TESTFILES+=	onechunk
     45  1.2.8.1   martin onechunk.in:
     46  1.2.8.1   martin 	head -c 65536 < /usr/share/dict/words > ${.TARGET}.tmp \
     47  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     48  1.2.8.1   martin 
     49  1.2.8.1   martin TESTFILES+=	tenchunk
     50  1.2.8.1   martin tenchunk.in:
     51  1.2.8.1   martin 	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
     52  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     53  1.2.8.1   martin 
     54  1.2.8.1   martin TESTFILES+=	extrablock
     55  1.2.8.1   martin XFAIL+=		extrablock.in-outx
     56  1.2.8.1   martin XFAIL+=		extrablock.cl2-cl2x
     57  1.2.8.1   martin extrablock.in:
     58  1.2.8.1   martin 	head -c $$((65536 + 512)) < /usr/share/dict/words > ${.TARGET}.tmp \
     59  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     60  1.2.8.1   martin 
     61  1.2.8.1   martin TESTFILES+=	medfile
     62  1.2.8.1   martin XFAIL+=		medfile.in-outx
     63  1.2.8.1   martin XFAIL+=		medfile.cl2-cl2x
     64  1.2.8.1   martin medfile.in:
     65  1.2.8.1   martin 	head -c 123456 < /usr/share/dict/words > ${.TARGET}.tmp \
     66  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     67  1.2.8.1   martin 
     68  1.2.8.1   martin TESTFILES+=		onetinyblock
     69  1.2.8.1   martin BLOCKSIZE.onetinyblock=	512
     70  1.2.8.1   martin onetinyblock.in:
     71  1.2.8.1   martin 	head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \
     72  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     73  1.2.8.1   martin 
     74  1.2.8.1   martin TESTFILES+=		tentinyblock
     75  1.2.8.1   martin BLOCKSIZE.tentinyblock=	512
     76  1.2.8.1   martin tentinyblock.in:
     77  1.2.8.1   martin 	head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \
     78  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     79  1.2.8.1   martin 
     80  1.2.8.2      snj # Make sure we can restart from a pipe.
     81  1.2.8.1   martin CHECKS+=	check-pipe-restart
     82  1.2.8.1   martin CLEANFILES+=	piperestart.in piperestart.in.tmp
     83  1.2.8.1   martin CLEANFILES+=	piperestart.cl2 piperestart.cl2.tmp
     84  1.2.8.1   martin CLEANFILES+=	piperestart.cl2restart piperestart.cl2restart.tmp
     85  1.2.8.1   martin CLEANFILES+=	piperestart.cl2part piperestart.cl2part.tmp
     86  1.2.8.1   martin check-pipe-restart: .PHONY piperestart.cl2 piperestart.cl2restart
     87  1.2.8.1   martin 	cmp ${.ALLSRC}
     88  1.2.8.1   martin piperestart.cl2restart: piperestart.cl2part vndcompress
     89  1.2.8.1   martin 	cp piperestart.cl2part ${.TARGET}.tmp \
     90  1.2.8.1   martin 	&& head -c 700000 < /usr/share/dict/words \
     91  1.2.8.2      snj 	| ./vndcompress -l 655360 -k 1 -r -R /dev/stdin ${.TARGET}.tmp \
     92  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
     93  1.2.8.1   martin # The following rule uses ; and not && on purpose: vndcompress is
     94  1.2.8.1   martin # supposed to fail (and it is even OK to interrupt!) so we can restart
     95  1.2.8.1   martin # and fill in the rest.
     96  1.2.8.1   martin piperestart.cl2part: vndcompress
     97  1.2.8.1   martin 	head -c 600000 < /usr/share/dict/words \
     98  1.2.8.1   martin 	| ./vndcompress -l 655360 -k 1 /dev/stdin ${.TARGET}.tmp; \
     99  1.2.8.1   martin 	mv -f ${.TARGET}.tmp ${.TARGET}
    100  1.2.8.1   martin piperestart.in:
    101  1.2.8.1   martin 	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
    102  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    103  1.2.8.1   martin 
    104  1.2.8.2      snj # Make sure we can restart from a pipe even if the original start was
    105  1.2.8.2      snj # corrupted, as long as we don't pass -R.
    106  1.2.8.2      snj CHECKS+=	check-pipe-badstart
    107  1.2.8.2      snj CLEANFILES+=	pipebadstart.in pipebadstart.in.tmp
    108  1.2.8.2      snj CLEANFILES+=	pipebadstart.cl2 pipebadstart.cl2.tmp
    109  1.2.8.2      snj CLEANFILES+=	pipebadstart.cl2restart pipebadstart.cl2restart.tmp
    110  1.2.8.2      snj CLEANFILES+=	pipebadstart.cl2part pipebadstart.cl2part.tmp
    111  1.2.8.2      snj check-pipe-badstart: .PHONY pipebadstart.cl2 pipebadstart.cl2restart
    112  1.2.8.2      snj 	cmp ${.ALLSRC}
    113  1.2.8.2      snj pipebadstart.cl2restart: pipebadstart.cl2part vndcompress
    114  1.2.8.2      snj 	cp pipebadstart.cl2part ${.TARGET}.tmp \
    115  1.2.8.2      snj 	&& head -c 700000 < /usr/share/dict/words \
    116  1.2.8.2      snj 	| ./vndcompress -l 655360 -k 1 -r /dev/stdin ${.TARGET}.tmp \
    117  1.2.8.2      snj 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    118  1.2.8.2      snj pipebadstart.cl2part:
    119  1.2.8.2      snj 	touch ${.TARGET}
    120  1.2.8.2      snj pipebadstart.in:
    121  1.2.8.2      snj 	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
    122  1.2.8.2      snj 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    123  1.2.8.2      snj 
    124  1.2.8.2      snj # Make sure we can `restart' even if there's nothing there.
    125  1.2.8.2      snj CHECKS+=	check-pipe-falsestart
    126  1.2.8.2      snj CLEANFILES+=	pipefalsestart.in pipefalsestart.in.tmp
    127  1.2.8.2      snj CLEANFILES+=	pipefalsestart.cl2 pipefalsestart.cl2.tmp
    128  1.2.8.2      snj CLEANFILES+=	pipefalsestart.cl2restart pipefalsestart.cl2restart.tmp
    129  1.2.8.2      snj check-pipe-falsestart: .PHONY pipefalsestart.cl2 pipefalsestart.cl2restart
    130  1.2.8.2      snj 	cmp ${.ALLSRC}
    131  1.2.8.2      snj pipefalsestart.cl2restart: vndcompress
    132  1.2.8.2      snj 	rm -f ${.TARGET}.tmp \
    133  1.2.8.2      snj 	&& head -c 700000 < /usr/share/dict/words \
    134  1.2.8.2      snj 	| ./vndcompress -l 655360 -k 1 -r /dev/stdin ${.TARGET}.tmp \
    135  1.2.8.2      snj 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    136  1.2.8.2      snj pipefalsestart.in:
    137  1.2.8.2      snj 	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
    138  1.2.8.2      snj 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    139  1.2.8.2      snj 
    140  1.2.8.2      snj # Make sure we can restart from a file, simulated with `-p'.
    141  1.2.8.1   martin CHECKS+=	check-part
    142  1.2.8.2      snj CLEANFILES+=	part.orig part.orig.tmp
    143  1.2.8.2      snj CLEANFILES+=	part.cl2part part.cl2part.tmp
    144  1.2.8.2      snj CLEANFILES+=	part.cl2 part.cl2.tmp
    145  1.2.8.2      snj CLEANFILES+=	part.out part.out.tmp
    146  1.2.8.1   martin check-part: .PHONY part.orig part.out
    147  1.2.8.1   martin 	cmp part.orig part.out
    148  1.2.8.1   martin part.cl2: part.orig part.cl2part vndcompress
    149  1.2.8.1   martin 	cp part.cl2part ${.TARGET}.tmp \
    150  1.2.8.2      snj 	&& ./vndcompress -b 512 -r -R part.orig ${.TARGET}.tmp \
    151  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    152  1.2.8.1   martin part.cl2part: part.orig vndcompress
    153  1.2.8.1   martin 	./vndcompress -b 512 -p 10 part.orig ${.TARGET}.tmp \
    154  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    155  1.2.8.1   martin part.orig:
    156  1.2.8.1   martin 	head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \
    157  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    158  1.2.8.1   martin 
    159  1.2.8.2      snj # Make sure we can `restart' even if there's nothing there.
    160  1.2.8.2      snj CHECKS+=	check-falsestart
    161  1.2.8.2      snj CLEANFILES+=	falsestart.in falsestart.in.tmp
    162  1.2.8.2      snj CLEANFILES+=	falsestart.cl2 falsestart.cl2.tmp
    163  1.2.8.2      snj CLEANFILES+=	falsestart.cl2restart falsestart.cl2restart.tmp
    164  1.2.8.2      snj check-falsestart: .PHONY falsestart.cl2 falsestart.cl2restart
    165  1.2.8.2      snj 	cmp ${.ALLSRC}
    166  1.2.8.2      snj falsestart.cl2restart: vndcompress falsestart.in
    167  1.2.8.2      snj 	rm -f ${.TARGET}.tmp \
    168  1.2.8.2      snj 	&& ./vndcompress -r falsestart.in ${.TARGET}.tmp \
    169  1.2.8.2      snj 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    170  1.2.8.2      snj falsestart.in:
    171  1.2.8.2      snj 	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
    172  1.2.8.2      snj 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    173  1.2.8.2      snj 
    174  1.2.8.1   martin TESTFILES+=	smallwindow
    175  1.2.8.1   martin smallwindow.in:
    176  1.2.8.1   martin 	head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \
    177  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    178  1.2.8.1   martin smallwindow.cl2: smallwindow.in
    179  1.2.8.1   martin 	./vndcompress -w 1 ${.IMPSRC} ${.TARGET}.tmp \
    180  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    181  1.2.8.1   martin smallwindow.out: smallwindow.cl2
    182  1.2.8.1   martin 	./vndcompress -w 1 -d ${.IMPSRC} ${.TARGET}.tmp \
    183  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    184  1.2.8.1   martin 
    185  1.2.8.1   martin CHECKS+=	check-pipewindow
    186  1.2.8.1   martin check-pipewindow: smallwindow.cl2
    187  1.2.8.1   martin 	@echo '# expecting failure...'
    188  1.2.8.1   martin 	if cat smallwindow.cl2 | ./vndcompress -w 1 -d /dev/stdin /dev/null; \
    189  1.2.8.1   martin 	then \
    190  1.2.8.1   martin 	  echo 'unexpected pass!' && exit 1; \
    191  1.2.8.1   martin 	fi
    192  1.2.8.1   martin 
    193  1.2.8.1   martin # The following two tests try to ensure a limited window size means
    194  1.2.8.1   martin # limited memory allocation.  They don't work very well.  The virtual
    195  1.2.8.1   martin # address space rlimit (ulimit -v, RLIMIT_AS) must cover the stack size
    196  1.2.8.1   martin # that is allocated automatically for the process, which varies from
    197  1.2.8.1   martin # machine architecture to machine architecture (the kernel's MAXSSIZ
    198  1.2.8.1   martin # parameter), as well as any shared libraries that get loaded in and
    199  1.2.8.1   martin # other auxiliary crud the loader or libc might allocate.
    200  1.2.8.1   martin #
    201  1.2.8.1   martin # In principle, the overhead from that and the program image should be
    202  1.2.8.1   martin # constant, and the only substantial memory allocation performed by
    203  1.2.8.1   martin # vndcompress should be w*8 bytes or (n/b)*8, where w is the window
    204  1.2.8.1   martin # size if specified, n is the size of the input, and b is the block
    205  1.2.8.1   martin # size.
    206  1.2.8.1   martin #
    207  1.2.8.1   martin # We could perhaps do an exponential growth and then binary search on
    208  1.2.8.1   martin # the virtual address space limit to determine the overhead, but that's
    209  1.2.8.1   martin # more trouble than I care to do in a makefile right now.  Currently
    210  1.2.8.1   martin # this is calibrated for NetBSD/amd64 6, where 128 MB of virtual
    211  1.2.8.1   martin # address space is allocated for the stack.  (Note `ulimit -v' takes a
    212  1.2.8.1   martin # number of kilobytes, not a number of bytes.)  Since this is not
    213  1.2.8.1   martin # reliable, however, these are commented out.
    214  1.2.8.1   martin 
    215  1.2.8.1   martin #CHECKS+=	check-ulimit
    216  1.2.8.1   martin #check-ulimit:
    217  1.2.8.1   martin #	@echo '# expecting failure...'
    218  1.2.8.1   martin #	if head -c $$((64 * 1024 * 1024)) < /dev/zero \
    219  1.2.8.1   martin #	    | (ulimit -v $$((139 * 1024)) && \
    220  1.2.8.1   martin #	        ./vndcompress -w 0 -l 64m -b 512 /dev/stdin /dev/null); then \
    221  1.2.8.1   martin #	  echo 'unexpected pass!' && exit 1; \
    222  1.2.8.1   martin #	fi
    223  1.2.8.1   martin #
    224  1.2.8.1   martin #CHECKS+=	check-ulimit-window
    225  1.2.8.1   martin #check-ulimit-window:
    226  1.2.8.1   martin #	head -c $$((64 * 1024 * 1024)) < /dev/zero \
    227  1.2.8.1   martin #	| (ulimit -v $$((139 * 1024)) && \
    228  1.2.8.1   martin #	    ./vndcompress -w 8192 -l 64m -b 512 /dev/stdin /dev/null)
    229  1.2.8.1   martin 
    230  1.2.8.1   martin TESTSUFFIXES+=	in cl2 cl2x out outx
    231  1.2.8.1   martin 
    232  1.2.8.1   martin TESTFORMS+=	cl2 cl2x
    233  1.2.8.1   martin TESTFORMS+=	in out
    234  1.2.8.1   martin TESTFORMS+=	in outx
    235  1.2.8.1   martin 
    236  1.2.8.1   martin .for testfile in ${TESTFILES}
    237  1.2.8.1   martin .  for suffix in ${TESTSUFFIXES}
    238  1.2.8.1   martin CLEANFILES+=	${testfile}.${suffix}
    239  1.2.8.1   martin CLEANFILES+=	${testfile}.${suffix}.tmp
    240  1.2.8.1   martin .  endfor
    241  1.2.8.1   martin .  for left right in ${TESTFORMS}
    242  1.2.8.1   martin CHECKS.${testfile}+=	check-${testfile}.${left}-${right}
    243  1.2.8.1   martin check-${testfile}.${left}-${right}: .PHONY \
    244  1.2.8.1   martin   ${testfile}.${left} ${testfile}.${right}
    245  1.2.8.1   martin .    if empty(XFAIL:M${testfile}.${left}-${right})
    246  1.2.8.1   martin 	cmp ${testfile}.${left} ${testfile}.${right}
    247  1.2.8.1   martin .    else
    248  1.2.8.1   martin 	@echo '# expecting failure...' \
    249  1.2.8.1   martin 	&& echo 'cmp ${testfile}.${left} ${testfile}.${right}' \
    250  1.2.8.1   martin 	&& if cmp ${testfile}.${left} ${testfile}.${right}; then \
    251  1.2.8.1   martin 	  echo 'unexpected pass!' \
    252  1.2.8.1   martin 	  && exit 1; \
    253  1.2.8.1   martin 	fi
    254  1.2.8.1   martin .    endif
    255  1.2.8.1   martin .  endfor
    256  1.2.8.1   martin check-${testfile}: ${CHECKS.${testfile}}
    257  1.2.8.1   martin CHECKS+=	check-${testfile}
    258  1.2.8.1   martin .endfor
    259  1.2.8.1   martin 
    260  1.2.8.1   martin check: .PHONY ${CHECKS}
    261  1.2.8.1   martin 
    262  1.2.8.1   martin .SUFFIXES: .cl2 .cl2x .in .out .outx
    263  1.2.8.1   martin 
    264  1.2.8.1   martin # XXX These tests should automatically try different window sizes, but
    265  1.2.8.1   martin # that is tricky to express in make.
    266  1.2.8.1   martin 
    267  1.2.8.1   martin .in.cl2: vndcompress
    268  1.2.8.1   martin 	./vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \
    269  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    270  1.2.8.1   martin 
    271  1.2.8.1   martin .in.cl2x:
    272  1.2.8.1   martin 	vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \
    273  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    274  1.2.8.1   martin 
    275  1.2.8.1   martin .cl2.out: vndcompress
    276  1.2.8.1   martin 	./vndcompress -d ${.IMPSRC} ${.TARGET}.tmp \
    277  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    278  1.2.8.1   martin 
    279  1.2.8.1   martin .cl2.outx:
    280  1.2.8.1   martin 	vnduncompress ${.IMPSRC} ${.TARGET}.tmp \
    281  1.2.8.1   martin 	&& mv -f ${.TARGET}.tmp ${.TARGET}
    282