#
#	$Id$
#
# Configuration stuff.
#
#COPTS=-O
COPTS = -bs -sabm -wl
INCLUDE = /include
DEFINES = -DAMIGA -DFJE
CFLAGS = $(COPTS) -I$(INCLUDE) $(DEFINES)

#LIBS = ../libcnews.a
LD = ln
LDFLAGS = -g
LIB  = /libcnews.lib
LIBS = +l $(LIB) +l -lc

# =()<NEWSARTS = @<NEWSARTS>@>()=
#NEWSARTS = /usr/spool/news
# =()<NEWSBIN = @<NEWSBIN>@>()=
#NEWSBIN = /usr/lib/newsbin
# =()<NEWSCTL = @<NEWSCTL>@>()=
#NEWSCTL = /usr/lib/news

#OUTGOING = $(NEWSARTS)/Out.Going
#PGMDIR = $(NEWSBIN)/batch

# workaround for System V make bug
SHELL = /bin/sh

PGMS=batcher batchih batchsm batchsplit comp compcun nocomp viainews viauux \
	sendbatches compc7 c7encode viamail viapmail bencode compb viauuxz \
	viaemail viarsh viauuxl viauuxcun
#ALL = $(PGMS) batchparms
ALL = batcher c7encode bencode

all:	$(ALL)
	chmod +x $(PGMS)

batcher:	batcher.o $(LIB)
	$(LD) $(LDFLAGS) batcher.o -o $@ $(LIBS)

c7encode:	c7encode.o $(LIB)
	$(LD) $(LDFLAGS) c7encode.o -o $@ $(LIBS)

bencode:	bencode.o crctab.o $(LIB)
	$(LD) $(LDFLAGS) bencode.o crctab.o -o $@ $(LIBS)

bencode.o:	coder.h

#bininstall:	$(ALL)
#	-if test ! -d $(PGMDIR) ; then mkdir $(PGMDIR) ; fi
#	cp $(PGMS) $(PGMDIR)

#cmp:	$(PGMS)
#	for f in $(PGMS) ; do cmp $(PGMDIR)/$$f $$f ; done

#check:	$(PGMS)
#	for f in $(PGMS) ; do cmp $(PGMDIR)/$$f $$f || true ; done

#newsinstall:	batchparms
#	-if test ! -d $(OUTGOING) ; then mkdir $(OUTGOING) ; fi
#	-if test ! -r $(NEWSCTL)/batchparms ; then cp batchparms $(NEWSCTL) ; fi

#batchparms:	Makefile
#	echo '# 100KB, after compress, is 10 minutes at 1200 baud' >$@
#	echo '# 20 batches is somewhat arbitrary, about 1MB per site' >>$@
#	echo '# defaults:  2.11-compatible compression, transfer by uux' >>$@
#	echo '#' >>$@
#	echo '# site		size	limit	batcher	muncher	sender' >>$@
#	echo '# ----		----	-----	-------	-------	------' >>$@
#	echo '/default/	100000	20	batcher	compcun	viauux' >>$@
#	echo '#' >>$@
#	echo '# sample ihave/sendme setup' >>$@
#	echo 'louie.ihave	100000	20	batchih	nocomp	viainews' >>$@
#	echo 'louie.sendme	100000	20	batchsm	nocomp	viainews' >>$@

#batchsm:	batchih
#	sed 's/ihave/sendme/g' batchih >$@

#viauuxz:	viauux
#	sed '$$s/-r/-r -z/' viauux >$@

#viauuxcun:	viauux
#	sed '$$s/rnews/cunbatch/' viauux >$@

#viaemail:	viamail
#	sed '$$s/rnews/enews/' viamail >$@

#test.1:
#	echo 'a test' >$@

#test.2:
#	echo 'another test' >$@

#test.3:
#	cat batcher.c batcher.c batcher.c batcher.c batcher.c >$@

#r:	all test.1 test.2 test.3
#	echo a 1 >togo
#	echo b 1 >>togo
#	echo c 1 >>togo
#	echo d 1 >>togo
#	echo e 1 >>togo
#	echo f 1 >>togo
#	echo g 1 >>togo
#	echo h 3 >>togo
#	echo i 20 >>togo
#	echo j 999 >>togo
#	rm -rf bin
#	mkdir bin
#	echo 'ln $$* >/dev/null 2>/dev/null' >bin/newslock
#	echo 'cat' >bin/munch
#	echo '( echo --- ; cat ) >>`pwd`/output' >bin/xmit
#	echo 'echo 2 ; cat' >bin/munch2
#	echo '( echo +++ ; cat ) >>`pwd`/output2' >bin/xmit2
#	echo 'echo 4' >bin/queuelen
#	echo 'echo 99' >bin/spacefor
#	ln batcher bin/batcher
#	ln batchsplit bin/batchsplit
#	chmod +x bin/*
#	NEWSCTL=`pwd` ./batchsplit 1
#	echo a 1 >test.good ; cmp test.good togo.1
#	echo b 1 >test.good ; cmp test.good togo.2
#	echo c 1 >test.good ; cmp test.good togo.3
#	echo d 1 >test.good ; cmp test.good togo.4
#	echo e 1 >test.good ; cmp test.good togo.5
#	echo f 1 >test.good ; cmp test.good togo.6
#	echo g 1 >test.good ; cmp test.good togo.7
#	echo h 3 >test.good ; echo i 20 >>test.good ; cmp test.good togo.next
#	echo j 999 >test.good ; cmp test.good togo.more
#	test ! -s togo ;
#	rm togo.*
#	echo `pwd`/test.1 >togo
#	echo ./test.2 >>togo
#	echo `pwd`/test.3 666 >>togo
#	./batcher togo >test.out
#	echo "#! rnews `wc -c test.1 | awk '{print $$1}'`" >test.good
#	cat test.1 >>test.good
#	echo "#! rnews `wc -c test.2 | awk '{print $$1}'`" >>test.good
#	cat test.2 >>test.good
#	( echo --- ; cat test.good ) >test.out1
#	( echo +++ ; echo 2 ; cat test.good ) >test.out2
#	echo "#! rnews `wc -c test.3 | awk '{print $$1}'`" >test.temp
#	cat test.3 >>test.temp
#	cat test.temp >>test.good
#	( echo --- ; cat test.temp ) >>test.out1
#	cmp test.good test.out
#	rm test.out togo
# 	rm -rf out.going batchparms test.out test.good output output2
#	mkdir out.going out.going/foo out.going/bar
#	echo 'foo	500	10	batcher	munch	xmit' >batchparms
#	NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches -d >test.out
#	echo foo >test.good
#	cmp test.out test.good
#	echo '/default/	10000	5	batcher	munch2	xmit2' >>batchparms
#	NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches -d | sort >test.out
#	( echo foo ; echo bar ) | sort >test.good
#	cmp test.out test.good
#	NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches -d bletch >test.out
#	echo bletch >test.good
#	cmp test.out test.good
#	>batchlog
#	NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches
#	test ! -s out.going/foo/output ;
#	test ! -s out.going/bar/output ;
#	echo `pwd`/test.1 200 >out.going/foo/togo
#	echo `pwd`/test.2 200 >>out.going/foo/togo
#	echo `pwd`/test.3 200 >>out.going/foo/togo
#	echo `pwd`/test.1 4000 >out.going/bar/togo
	rm -f output output2
#	echo `pwd`/test.2 4000 >>out.going/bar/togo
#	echo `pwd`/test.3 4000 >>out.going/bar/togo
#	echo `pwd`/test.3 4000 >test.left
#	NEWSARTS=`pwd` NEWSCTL=`pwd` ./sendbatches
#	cmp out.going/foo/output test.out1
#	cmp out.going/bar/output test.out2
#	test ! -s output ;
#	test ! -s output2 ;
#	cmp test.left out.going/bar/togo.2
#	sed '/^$$/q' batchlog | sed '1d;$$d' | sed '$$d' >test.log
#	test ! -s test.log ;
#	sed '1,/^$$/d' batchlog | sed '1d;$$d' | sed '$$d' >test.log
#	echo 'bar	backlog 1 (batches flowing)' >test.good
#	cmp test.good test.log
#	rm -rf test.* togo out.going bin batchparms batchlog batchlog.*

#clean:
#	rm -rf out.going bin
#	rm -f *.o test.* togo togo.* batchparms batcher batchsm viauuxcun
#	rm -f batchlog batchlog.* c7encode bencode viauuxz viaemail
