home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / news / cnews.tar / batch / makefile < prev    next >
Makefile  |  1995-04-27  |  6KB  |  238 lines

  1. # =()<@<INCLUDE>@>()=
  2. .include "../include/config.make"
  3.  
  4. DEST=$(NEWSBIN)/batch
  5.  
  6. BINS=batcher bencode c7encode
  7. PROGS=$(BINS) batchih batchsm batchsplit compcun viainews viauux \
  8.     sendbatches viamail \
  9.     viarsh batchcheck batchra \
  10.     batchsplitter bpfind nencode usenntpxmit
  11. BP=batchparms.eg
  12. ALL=$(PROGS) $(BP)
  13.  
  14. all:    $(ALL)
  15.     $(MX) $(PROGS)
  16.  
  17. install:    $(ALL)
  18.     $(MKDIR) $(DEST)
  19.     $(TO) $(DEST) $(PROGS)
  20.  
  21. setup:    $(BP)
  22.     $(MKDIR) $(NEWSARTS)/out.going $(NEWSARTS)/out.nntp
  23.     $(TO) -n -e $(NEWSCTL) $(BP)
  24.  
  25. cmp:    $(ALL)
  26.     @$(IN) $(DEST) $(PROGS)
  27.     @$(IN) -i -e $(NEWSCTL) $(BP)
  28.     : checking batchparms format
  29.     @awk '$$0 !~ /^#/ && $$2 ~ /00/' $(NEWSCTL)/batchparms >bp.00 ; true
  30.     @test ! -s bp.00 ;
  31.     @rm -f bp.00
  32.     : okay
  33.  
  34. $(BINS):    $(LIB)
  35.  
  36. batcher:    batcher.o
  37.     $(CC) $(LDFLAGS) batcher.o $(LIBS) -o $@
  38.  
  39. c7encode:    c7encode.o
  40.     $(CC) $(LDFLAGS) c7encode.o $(LIBS) -o $@
  41.  
  42. bencode:    bencode.o crctab.o
  43.     $(CC) $(LDFLAGS) bencode.o crctab.o $(LIBS) -o $@
  44.  
  45. bencode.o:    coder.h
  46.  
  47. rsetup:    test.1 test.2 test.3 test.good bin arts bp.huey bp.nobody
  48.  
  49. test.1:
  50.     echo 'a test' >$@
  51.  
  52. test.2:
  53.     echo 'another test' >$@
  54.  
  55. test.3:
  56.     cat batcher.c batcher.c batcher.c batcher.c batcher.c >$@
  57.  
  58. test.good:
  59.     echo "#! rnews `wc -c test.1 | awk '{print $$1}'`" >test.good
  60.     cat test.1 >>test.good
  61.     echo "#! rnews `wc -c test.2 | awk '{print $$1}'`" >>test.good
  62.     cat test.2 >>test.good
  63.     ( echo --- ; cat test.good ) >test.out1
  64.     ( echo +++ ; echo 2 ; cat test.good ) >test.out2
  65.     echo "#! rnews `wc -c test.3 | awk '{print $$1}'`" >test.temp
  66.     cat test.3 >>test.temp
  67.     cat test.temp >>test.good
  68.     ( echo --- ; cat test.temp ) >>test.out1
  69.  
  70. bin:    $(PROGS)
  71.     mkdir bin
  72.     echo 'cat' >bin/munch
  73.     echo "( echo --- ; cat ) >>`pwd`/output" >bin/xmit
  74.     echo 'echo 2 ; cat' >bin/munch2
  75.     echo "( echo +++ ; cat ) >>`pwd`/output2" >bin/xmit2
  76.     echo 'echo 4' >bin/queuelen
  77.     echo 'echo 99' >bin/spacefor
  78.     echo '' >bin/lock
  79.     echo '' >bin/unlock
  80.     echo 'echo $$* ; echo === ; cat ; echo ===' >bin/report
  81.     echo 'cat >>$$NEWSSITEDIR/togo.leftover' >bin/staller
  82.     $(MX) bin/*
  83.  
  84. arts:
  85.     mkdir arts
  86.     mkdir arts/out.going arts/out.going/foo arts/out.going/bar
  87.  
  88. bp.huey:
  89.     echo "bpokay=y" >$@
  90.     echo "bpsite='huey'" >>$@
  91.     echo "bpclass='u'" >>$@
  92.     echo "bpsize='500000'" >>$@
  93.     echo "bpmax='750000'" >>$@
  94.     echo "bpqueue='20'" >>$@
  95.     echo "bpcmd='batcher | gzip -9 | viauux -d gunzip'" >>$@
  96.  
  97. bp.nobody:
  98.     echo "bpokay=y" >$@
  99.     echo "bpsite='/default/'" >>$@
  100.     echo "bpclass='u'" >>$@
  101.     echo "bpsize='500000'" >>$@
  102.     echo "bpmax='1500000'" >>$@
  103.     echo "bpqueue='20'" >>$@
  104.     echo "bpcmd='batcher | compcun | viauux'" >>$@
  105.  
  106. r:    all rclean rsetup r.bpf r.split r.batcher r.sendwho r.sendbatches
  107.     : success!
  108.  
  109. r.bpf:    bpfind
  110.     $(MX) bpfind
  111.     $(HERE) ./bpfind . huey batchparms.eg >bp.tmp
  112.     cmp bp.huey bp.tmp || diff bp.huey bp.tmp
  113.     $(HERE) ./bpfind u huey batchparms.eg >bp.tmp
  114.     cmp bp.huey bp.tmp || diff bp.huey bp.tmp
  115.     $(HERE) ./bpfind u nobody batchparms.eg >bp.tmp
  116.     cmp bp.nobody bp.tmp || diff bp.nobody bp.tmp
  117.     $(HERE) ./bpfind u donald batchparms.eg >bp.tmp
  118.     test " `cat bp.tmp`" = " bpokay=x" ;
  119.  
  120. r.split:
  121.     echo x 1 >togo
  122.     echo a 1 >>togo
  123.     echo b 1 >>togo
  124.     echo c 1 >>togo
  125.     echo d 1 >>togo
  126.     echo e 1 >>togo
  127.     echo f 1 >>togo
  128.     echo g 1 >>togo
  129.     echo h 1 >>togo
  130.     echo i 1 >>togo
  131.     echo j 3 >>togo
  132.     echo k 20 >>togo
  133.     echo l 99999 >>togo
  134.     cp togo togo.save
  135.     ( cd arts ; touch x a b c d e f g h i j k l )
  136.     $(HERE) ./batchsplit -X 16 1000000
  137.     test -r togo ;
  138.     test ! -s togo ;
  139.     test " `cat togo.1`" = " x 1" ;
  140.     test " `cat togo.2`" = " a 1" ;
  141.     test " `cat togo.3`" = " b 1" ;
  142.     test " `cat togo.4`" = " c 1" ;
  143.     test " `cat togo.5`" = " d 1" ;
  144.     test " `cat togo.6`" = " e 1" ;
  145.     test " `cat togo.7`" = " f 1" ;
  146.     sed '1,7d' togo.save >togo.sp
  147.     cat togo.next togo.more >togo.tmp
  148.     cmp togo.tmp togo.sp
  149.     test " `wc -l <togo.next`" -eq 5 ;
  150.     mv togo.save togo
  151.     rm togo.*
  152.     cp togo togo.save
  153.     rm arts/x
  154.     $(HERE) ./batchsplit -X 16 1000000
  155.     test " `cat togo.1`" = " a 1" ;
  156.     test " `cat togo.2`" = " b 1" ;
  157.     test " `cat togo.3`" = " c 1" ;
  158.     test " `cat togo.4`" = " d 1" ;
  159.     test " `cat togo.5`" = " e 1" ;
  160.     test " `cat togo.6`" = " f 1" ;
  161.     test " `cat togo.7`" = " g 1" ;
  162.     sed '1,8d' togo.save >togo.sp
  163.     cat togo.next togo.more >togo.tmp
  164.     cmp togo.tmp togo.sp
  165.     test " `wc -l <togo.next`" -eq 4 ;
  166.  
  167. r.batcher:
  168.     echo `pwd`/test.1 >togo
  169.     echo ./test.2 >>togo
  170.     cp test.2 arts
  171.     echo `pwd`/test.3 666 >>togo
  172.     ./batcher togo >test.out
  173.     cmp test.out test.good
  174.     ./batcher <togo >test.out
  175.     cmp test.out test.good
  176.  
  177. r.sendwho:
  178.     echo 'foo u 500 10 batcher | munch | xmit' >batchparms
  179.     $(HERE) ./sendbatches -d >test.out
  180.     echo foo >test.who
  181.     cmp test.out test.who
  182.     echo '/default/ u 10000 5 batcher | munch2 | xmit2' >>batchparms
  183.     $(HERE) ./sendbatches -d | sort >test.out
  184.     ( echo foo ; echo bar ) | sort >test.who
  185.     cmp test.out test.who
  186.     $(HERE) ./sendbatches -d bletch >test.out
  187.     echo bletch >test.who
  188.     cmp test.out test.who
  189.     egrep -v '^foo' batchparms >bp.n
  190.     echo "bar n 10000 - usesomething" >>bp.n
  191.     $(HERE) ./sendbatches -f `pwd`/bp.n -d -c n >test.out
  192.     test " `cat test.out`" = " bar" ;
  193.  
  194. r.sendbatches:
  195.     $(HERE) ./sendbatches
  196.     test ! -s output ;
  197.     test ! -s output2 ;
  198.     echo `pwd`/test.1 200 >arts/out.going/foo/togo
  199.     echo `pwd`/test.2 200 >>arts/out.going/foo/togo
  200.     echo `pwd`/test.3 200 >>arts/out.going/foo/togo
  201.     echo `pwd`/test.1 4000 >arts/out.going/bar/togo
  202.     echo `pwd`/test.2 4000 >>arts/out.going/bar/togo
  203.     echo `pwd`/test.3 4000 >>arts/out.going/bar/togo
  204.     echo `pwd`/test.3 4000 >test.left
  205.     echo 'foo u! 500 10 batcher | munch | xmit' >test.bp
  206.     $(HERE) ./sendbatches -f `pwd`/test.bp
  207.     test ! -s output ;
  208.     test ! -s output2 ;
  209.     $(HERE) ./sendbatches
  210.     cmp output test.out1
  211.     cmp output2 test.out2
  212.     test ! -s arts/out.going/foo/togo ;
  213.     test ! -s arts/out.going/bar/togo ;
  214.     cmp test.left arts/out.going/bar/togo.next
  215.     sed '/^$$/q' batchlog | sed '1d;$$d' | sed '$$d' >test.log
  216.     test ! -s test.log ;
  217.     sed '1,/^$$/d' batchlog | sed '/^$$/q' | sed '1d;$$d' | sed '$$d' >test.log
  218.     sed 's;/[^ ]*/;/;' test.log >test.log2
  219.     echo 'foo    backlog ? (disabled in /test.bp)' >test.logg
  220.     cmp test.log2 test.logg
  221.     sed '1,/^$$/d' batchlog | sed '1,/^$$/d' | sed '1d;$$d' | sed '$$d' >test.log
  222.     echo 'bar    backlog 1 (batches flowing)' >test.bar
  223.     cmp test.bar test.log
  224.     echo 'bar n 5000000 - staller' >batchparms
  225.     rm batchlog
  226.     $(HERE) ./sendbatches
  227.     sed '/^$$/d' batchlog | sed '1d;$$d' >test.log
  228.     echo 'bar    backlog 1 (batching slow or stalled)' >test.bar
  229.     cmp test.bar test.log
  230.  
  231. rclean:
  232.     rm -rf bin arts
  233.     rm -f test.* togo togo.* batchparms batchlog output output2
  234.     rm -f [a-l] bp.*
  235.  
  236. clean:    rclean
  237.     rm -f *.o $(BINS) bp.00
  238.