# =()<NEWSARTS = @<NEWSARTS>@>()=
NEWSARTS = /usr/spool/news
# =()<NEWSBIN = @<NEWSBIN>@>()=
NEWSBIN = /usr/lib/newsbin
# =()<NEWSCTL = @<NEWSCTL>@>()=
NEWSCTL = /usr/lib/news
# workaround for System V make bug
SHELL = /bin/sh
NEWSUSER=news
NEWSGROUP=news
COPTS = -O
CFLAGS = $(COPTS) -I../include '-DNEWSUSER="$(NEWSUSER)"' '-DNEWSGROUP="$(NEWSG
OUP)"'
LIBS = ../libcnews.a
LIBDIRS = libbig libbsd42 libc libcnews libfake \
	libsmall libstdio libusg libv7 libv8
DIRS = batch conf expire h hfake input $(LIBDIRS) misc relay rna

PGMS = spacefor queuelen

all:	$(PGMS)

bininstall:	$(PGMS)
	chmod +x $(PGMS)
	cp $(PGMS) $(NEWSBIN)
	-if test -r hostname ; then chmod +x hostname ; cp hostname $(NEWSBIN) ; fi
	: and build takes care of setnewsids if needed

newsinstall:
	: build stuff does the real work

substs:	subst.hs subst.gc substitutions subst
	chmod +x subst
	: too late for h and hfake, include has already been built
	-egrep '^(h|hfake)/' subst.hs subst.gc >junk
	test ! -s junk
	rm -f junk
	./subst -f substitutions `sed 's;^;../;' subst.hs subst.gc`

spacefors:	spacefor.sysv spacefor.v7 spacefor.sgi spacefor.bsd spacefor.null

spacefor.bsd:	spacefor.proto Makefile
	cp spacefor.proto $@

spacefor.v7:	spacefor.proto Makefile
	sed '/dfunit=/s/1024/512/;/nr = 2/s//nr = 1/;/nf = 4/s//nf = 2/;/stupid/d' spa
efor.proto >$@

spacefor.sysv:	spacefor.proto Makefile
	sed '/dfunit=/s/1024/512/;/awk/s~|~| sed "s/.*:/: :/" |~;/nf = 4/s//nf = 3/;/s
upid/s/4BSD/System V/' spacefor.proto >$@

spacefor.sgi:	spacefor.proto Makefile
	sed '/dfunit=/s/1024/512/;/nf = 4/s//nf = 5/;/stupid/s/4BSD/SGI/' spacefor.pro
o >$@

spacefor.null:	Makefile
	echo '#! /bin/sh' >$@
	echo 'echo 100' >>$@

queuelen.hdb:
	: okay

queuelen.sub:
	: okay

queuelen.null:
	echo '#! /bin/sh' >$@
	echo 'echo 0' >>$@

setnewsids:	setnewsids.o $(LIBS)
	$(CC) $(CFLAGS) setnewsids.o $(LIBS) -o $@

../ranlibed:	../libcnews.a
	ranlib ../libcnews.a
	touch ../ranlibed

clean:
	rm -f spacefor.sysv spacefor.v7 spacefor.null queuelen.null
	rm -f spacefor.sgi
	rm -f allowed config mailname organization server whoami hostname errlog
	rm -f substitutions history history.pag history.dir active localgroups
	rm -f log mailpaths sys cron rc setnewsids setnewsids.o spacefor.bsd
	rm -f replyusepath spacefor queuelen junk

gclean:
	rm -f ../libcnews.a ../ranlibed
	rm -rf ../include
	for d in $(DIRS) ; do cd ../$$d ; make clean ; done

spotless:	gclean
	rm -f again.root doit.bin doit.news doit.root

lclean:
	rm -f ../ranlibed
	for d in $(LIBDIRS) ; do cd ../$$d ; make clean ; done
