Makefile revision 1.13
11.3SriastradPROG= vndcompress 21.6SriastradSRCS= main.c offtab.c utils.c vndcompress.c vnduncompress.c 31.3Sriastrad 41.3SriastradLINKS= ${BINDIR}/vndcompress ${BINDIR}/vnduncompress 51.3SriastradMLINKS= vndcompress.1 vnduncompress.1 61.1Shubertf 71.3SriastradDPADD+= ${LIBZ} 81.1ShubertfLDADD+= -lz 91.1Shubertf 101.8SriastradWARNS= 5 111.8Sriastrad 121.1Shubertf.include <bsd.prog.mk> 131.3Sriastrad 141.3SriastradTESTFILES+= oneblock 151.3SriastradXFAIL+= oneblock.in-outx 161.3SriastradXFAIL+= oneblock.cl2-cl2x 171.3Sriastradoneblock.in: 181.3Sriastrad head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \ 191.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 201.3Sriastrad 211.3SriastradTESTFILES+= tenblock 221.3SriastradXFAIL+= tenblock.in-outx 231.3SriastradXFAIL+= tenblock.cl2-cl2x 241.3Sriastradtenblock.in: 251.3Sriastrad head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \ 261.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 271.3Sriastrad 281.3SriastradTESTFILES+= smallfile 291.3SriastradXFAIL+= smallfile.in-outx 301.3SriastradXFAIL+= smallfile.cl2-cl2x 311.3Sriastradsmallfile.in: 321.3Sriastrad head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \ 331.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 341.3Sriastrad 351.3SriastradCHECKS+= check-pipe 361.3SriastradCLEANFILES+= smallfile.cl2pipe 371.3Sriastradcheck-pipe: .PHONY smallfile.cl2 smallfile.cl2pipe 381.3Sriastrad cmp ${.ALLSRC} 391.3Sriastradsmallfile.cl2pipe: smallfile.in vndcompress 401.3Sriastrad head -c 54321 < /usr/share/dict/words \ 411.3Sriastrad | ./vndcompress -l 12345 /dev/stdin ${.TARGET}.tmp \ 421.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 431.3Sriastrad 441.3SriastradTESTFILES+= onechunk 451.3Sriastradonechunk.in: 461.3Sriastrad head -c 65536 < /usr/share/dict/words > ${.TARGET}.tmp \ 471.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 481.3Sriastrad 491.3SriastradTESTFILES+= tenchunk 501.3Sriastradtenchunk.in: 511.3Sriastrad head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \ 521.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 531.3Sriastrad 541.3SriastradTESTFILES+= extrablock 551.3SriastradXFAIL+= extrablock.in-outx 561.3SriastradXFAIL+= extrablock.cl2-cl2x 571.3Sriastradextrablock.in: 581.3Sriastrad head -c $$((65536 + 512)) < /usr/share/dict/words > ${.TARGET}.tmp \ 591.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 601.3Sriastrad 611.3SriastradTESTFILES+= medfile 621.3SriastradXFAIL+= medfile.in-outx 631.3SriastradXFAIL+= medfile.cl2-cl2x 641.3Sriastradmedfile.in: 651.3Sriastrad head -c 123456 < /usr/share/dict/words > ${.TARGET}.tmp \ 661.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 671.3Sriastrad 681.3SriastradTESTFILES+= onetinyblock 691.3SriastradBLOCKSIZE.onetinyblock= 512 701.3Sriastradonetinyblock.in: 711.3Sriastrad head -c 512 < /usr/share/dict/words > ${.TARGET}.tmp \ 721.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 731.3Sriastrad 741.3SriastradTESTFILES+= tentinyblock 751.3SriastradBLOCKSIZE.tentinyblock= 512 761.3Sriastradtentinyblock.in: 771.3Sriastrad head -c 5120 < /usr/share/dict/words > ${.TARGET}.tmp \ 781.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 791.3Sriastrad 801.3SriastradCHECKS+= check-pipe-restart 811.3SriastradCLEANFILES+= piperestart.in piperestart.in.tmp 821.3SriastradCLEANFILES+= piperestart.cl2 piperestart.cl2.tmp 831.3SriastradCLEANFILES+= piperestart.cl2restart piperestart.cl2restart.tmp 841.3SriastradCLEANFILES+= piperestart.cl2part piperestart.cl2part.tmp 851.3Sriastradcheck-pipe-restart: .PHONY piperestart.cl2 piperestart.cl2restart 861.3Sriastrad cmp ${.ALLSRC} 871.3Sriastradpiperestart.cl2restart: piperestart.cl2part vndcompress 881.3Sriastrad cp piperestart.cl2part ${.TARGET}.tmp \ 891.3Sriastrad && head -c 700000 < /usr/share/dict/words \ 901.3Sriastrad | ./vndcompress -l 655360 -k 1 -rR /dev/stdin ${.TARGET}.tmp \ 911.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 921.9Sriastrad# The following rule uses ; and not && on purpose: vndcompress is 931.9Sriastrad# supposed to fail (and it is even OK to interrupt!) so we can restart 941.9Sriastrad# and fill in the rest. 951.3Sriastradpiperestart.cl2part: vndcompress 961.3Sriastrad head -c 600000 < /usr/share/dict/words \ 971.3Sriastrad | ./vndcompress -l 655360 -k 1 /dev/stdin ${.TARGET}.tmp; \ 981.3Sriastrad mv -f ${.TARGET}.tmp ${.TARGET} 991.3Sriastradpiperestart.in: 1001.3Sriastrad head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \ 1011.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1021.3Sriastrad 1031.3SriastradCHECKS+= check-part 1041.3SriastradCLEANFILES+= part.orig part.cl2part part.cl2 part.out 1051.3Sriastradcheck-part: .PHONY part.orig part.out 1061.3Sriastrad cmp part.orig part.out 1071.3Sriastradpart.cl2: part.orig part.cl2part vndcompress 1081.3Sriastrad cp part.cl2part ${.TARGET}.tmp \ 1091.12Sriastrad && ./vndcompress -b 512 -rR part.orig ${.TARGET}.tmp \ 1101.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1111.3Sriastradpart.cl2part: part.orig vndcompress 1121.12Sriastrad ./vndcompress -b 512 -p 10 part.orig ${.TARGET}.tmp \ 1131.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1141.3Sriastradpart.orig: 1151.3Sriastrad head -c 12345 < /usr/share/dict/words > ${.TARGET}.tmp \ 1161.3Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1171.3Sriastrad 1181.10SriastradTESTFILES+= smallwindow 1191.10Sriastradsmallwindow.in: 1201.10Sriastrad head -c 655360 < /usr/share/dict/words > ${.TARGET}.tmp \ 1211.10Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1221.10Sriastradsmallwindow.cl2: smallwindow.in 1231.10Sriastrad ./vndcompress -w 1 ${.IMPSRC} ${.TARGET}.tmp \ 1241.10Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1251.10Sriastradsmallwindow.out: smallwindow.cl2 1261.10Sriastrad ./vndcompress -w 1 -d ${.IMPSRC} ${.TARGET}.tmp \ 1271.10Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 1281.10Sriastrad 1291.10SriastradCHECKS+= check-pipewindow 1301.10Sriastradcheck-pipewindow: smallwindow.cl2 1311.10Sriastrad @echo '# expecting failure...' 1321.10Sriastrad if cat smallwindow.cl2 | ./vndcompress -w 1 -d /dev/stdin /dev/null; \ 1331.10Sriastrad then \ 1341.10Sriastrad echo 'unexpected pass!' && exit 1; \ 1351.10Sriastrad fi 1361.10Sriastrad 1371.11Sriastrad# The following two tests try to ensure a limited window size means 1381.11Sriastrad# limited memory allocation. They don't work very well. The virtual 1391.11Sriastrad# address space rlimit (ulimit -v, RLIMIT_AS) must cover the stack size 1401.11Sriastrad# that is allocated automatically for the process, which varies from 1411.11Sriastrad# machine architecture to machine architecture (the kernel's MAXSSIZ 1421.11Sriastrad# parameter), as well as any shared libraries that get loaded in and 1431.11Sriastrad# other auxiliary crud the loader or libc might allocate. 1441.11Sriastrad# 1451.11Sriastrad# In principle, the overhead from that and the program image should be 1461.11Sriastrad# constant, and the only substantial memory allocation performed by 1471.11Sriastrad# vndcompress should be w*8 bytes or (n/b)*8, where w is the window 1481.11Sriastrad# size if specified, n is the size of the input, and b is the block 1491.11Sriastrad# size. 1501.11Sriastrad# 1511.11Sriastrad# We could perhaps do an exponential growth and then binary search on 1521.11Sriastrad# the virtual address space limit to determine the overhead, but that's 1531.11Sriastrad# more trouble than I care to do in a makefile right now. Currently 1541.11Sriastrad# this is calibrated for NetBSD/amd64 6, where 128 MB of virtual 1551.11Sriastrad# address space is allocated for the stack. (Note `ulimit -v' takes a 1561.11Sriastrad# number of kilobytes, not a number of bytes.) Since this is not 1571.11Sriastrad# reliable, however, these are commented out. 1581.11Sriastrad 1591.11Sriastrad#CHECKS+= check-ulimit 1601.11Sriastrad#check-ulimit: 1611.11Sriastrad# @echo '# expecting failure...' 1621.11Sriastrad# if head -c $$((64 * 1024 * 1024)) < /dev/zero \ 1631.11Sriastrad# | (ulimit -v $$((139 * 1024)) && \ 1641.13Sriastrad# ./vndcompress -w 0 -l 64m -b 512 /dev/stdin /dev/null); then \ 1651.11Sriastrad# echo 'unexpected pass!' && exit 1; \ 1661.11Sriastrad# fi 1671.11Sriastrad# 1681.11Sriastrad#CHECKS+= check-ulimit-window 1691.11Sriastrad#check-ulimit-window: 1701.11Sriastrad# head -c $$((64 * 1024 * 1024)) < /dev/zero \ 1711.11Sriastrad# | (ulimit -v $$((139 * 1024)) && \ 1721.12Sriastrad# ./vndcompress -w 8192 -l 64m -b 512 /dev/stdin /dev/null) 1731.10Sriastrad 1741.3SriastradTESTSUFFIXES+= in cl2 cl2x out outx 1751.3Sriastrad 1761.3SriastradTESTFORMS+= cl2 cl2x 1771.3SriastradTESTFORMS+= in out 1781.3SriastradTESTFORMS+= in outx 1791.3Sriastrad 1801.3Sriastrad.for testfile in ${TESTFILES} 1811.3Sriastrad. for suffix in ${TESTSUFFIXES} 1821.3SriastradCLEANFILES+= ${testfile}.${suffix} 1831.3SriastradCLEANFILES+= ${testfile}.${suffix}.tmp 1841.3Sriastrad. endfor 1851.3Sriastrad. for left right in ${TESTFORMS} 1861.3SriastradCHECKS.${testfile}+= check-${testfile}.${left}-${right} 1871.3Sriastradcheck-${testfile}.${left}-${right}: .PHONY \ 1881.3Sriastrad ${testfile}.${left} ${testfile}.${right} 1891.3Sriastrad. if empty(XFAIL:M${testfile}.${left}-${right}) 1901.3Sriastrad cmp ${testfile}.${left} ${testfile}.${right} 1911.3Sriastrad. else 1921.3Sriastrad @echo '# expecting failure...' \ 1931.3Sriastrad && echo 'cmp ${testfile}.${left} ${testfile}.${right}' \ 1941.3Sriastrad && if cmp ${testfile}.${left} ${testfile}.${right}; then \ 1951.3Sriastrad echo 'unexpected pass!' \ 1961.3Sriastrad && exit 1; \ 1971.3Sriastrad fi 1981.3Sriastrad. endif 1991.3Sriastrad. endfor 2001.3Sriastradcheck-${testfile}: ${CHECKS.${testfile}} 2011.3SriastradCHECKS+= check-${testfile} 2021.3Sriastrad.endfor 2031.3Sriastrad 2041.3Sriastradcheck: .PHONY ${CHECKS} 2051.3Sriastrad 2061.3Sriastrad.SUFFIXES: .cl2 .cl2x .in .out .outx 2071.3Sriastrad 2081.10Sriastrad# XXX These tests should automatically try different window sizes, but 2091.10Sriastrad# that is tricky to express in make. 2101.10Sriastrad 2111.3Sriastrad.in.cl2: vndcompress 2121.7Sriastrad ./vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \ 2131.7Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 2141.3Sriastrad 2151.3Sriastrad.in.cl2x: 2161.7Sriastrad vndcompress ${.IMPSRC} ${.TARGET}.tmp ${BLOCKSIZE.${.PREFIX}} \ 2171.7Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 2181.3Sriastrad 2191.3Sriastrad.cl2.out: vndcompress 2201.7Sriastrad ./vndcompress -d ${.IMPSRC} ${.TARGET}.tmp \ 2211.7Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 2221.3Sriastrad 2231.3Sriastrad.cl2.outx: 2241.7Sriastrad vnduncompress ${.IMPSRC} ${.TARGET}.tmp \ 2251.7Sriastrad && mv -f ${.TARGET}.tmp ${.TARGET} 226