# makefile for C news relaynews
#
#	$Id$
#	$Log$

# =()<NEWSARTS = @<NEWSARTS>@>()=
#	AMIGA
#	NEWSARTS = /usr/spool/news
NEWSARTS = NewsArts:
# =()<NEWSBIN = @<NEWSBIN>@>()=
#	AMIGA
#	NEWSBIN = /usr/lib/newsbin
NEWSBIN = NewsBin:
# =()<NEWSCTL = @<NEWSCTL>@>()=
#	AMIGA
#	NEWSCTL = /usr/lib/news
NEWSCTL = NewsCtl:

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

BIN=/bin
NPROC=2

# -DVOID=int for libc.h & old lint libraries
#	AMIGA
#	DEFINES= -I../include -I. -DVOID=int -DFLUSHEVERY=6
INCLUDE= -ICN:include
DEFINES= -DFJE -DAMIGA -DVOID=int -DFLUSHEVERY=6 $(INCLUDE)

#	AMIGA
CC = cc
#CC=CC +V
#CC=gcc -ansi -pedantic -Wall -S
#CC=redcc

#	AMIGA
#	COPTS= -O # -pg -g
COPTS= -bs
CFLAGS=$(DEFINES) $(COPTS)

#	AMIGA
#	DBM = -ldbm
DBM =

#	AMIGA
#	LIBS= $(DBM) vfprintf.o heapmem.o -lc
LDFLAGS= -g -w
LIBS= $(DBM) -lc

# LINT=lint
# LINTFLAGS=-haz $(DEFINES)
# LLIBS=-llocal -lmalloc
# I wish I could make lint shut the fk up about some things.  Grrr!
# LINTFILT=egrep -v '(possible pointer|long assign|nnfree|getdate|:$$)'
# PROPTS=
# P=stpr
# PP=pp -Tpsc -fR # lazywriter
# PPBACK=dps | stps # lazywriter

#	AMIGA
#	What is LIBSRCS for???
#	LIBOBJS=../libcnews.a
LIBSRCS=
LIBOBJS= +l CN:libcnews.lib +l

SRC=relaynews.c active.c article.c caches.c mkdirs.c control.c fileart.c \
	hdrdefs.c hdrparse.c hdrmunge.c \
	history.c io.c msgs.c procart.c \
	sys.c transmit.c trbatch.c ihave.c $(LIBSRCS)
OBJ=relaynews.o active.o article.o caches.o mkdirs.o control.o fileart.o \
	hdrdefs.o hdrparse.o hdrmunge.o \
	history.o io.o msgs.o procart.o \
	sys.o transmit.o trbatch.o ihave.o
NONCFILES= TODO* README ads/README ads/[0-9]* \
	sh/inews sh/tear sh/anne.jones sh/defhdrs.awk \
	sh/realrnews sh/serverrnews makefile
CFILES= CN:include/*.h \
	active.h article.h caches.h mkdirs.h control.h fileart.h \
	hdrint.h headers.h history.h system.h transmit.h trbatch.h $(SRC)
FILES=$(NONCFILES) $(CFILES)

.c.o:
	$(CC) $(CFLAGS) $*.c

all: Makefile relaynews
#	chmod +x sh/[a-z]* aux/[a-z]* ctl/[a-z]*

#mkfile: makefile
#	sed '/mkfile/d' makefile | mkconv | sed 's/make/mk/g' >$@

relaynews: $(OBJ) /libcnews.lib
	ln $(LDFLAGS) $(OBJ) -o $@ $(LIBOBJS) $(LIBS)
#	cmp $(NEWSCTL)/inews sh/inews
#	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) $(PRE) $(LIBS) $(LIBOBJS) $(POST) -o $@

#lint: $(SRC)
#	$(LINT) $(LINTFLAGS) $(SRC) $(LLIBS) | $(LINTFILT)
#lint-p: $(SRC)
#	$(LINT) $(LINTFLAGS) -p $(SRC) $(LLIBS) | $(LINTFILT)

#newsinstall:
#	: nothing

# bininstall: make directories, install programs
#bininstall: install
#install: $(NEWSBIN)/relay/relaynews
#$(NEWSBIN)/relay/relaynews: relaynews
#	-mkdir $(NEWSBIN)/relay $(NEWSBIN)/inject $(NEWSBIN)/ctl
#	rm -f $(NEWSBIN)/relay/relaynews
#	cp relaynews $(NEWSBIN)/relay
#	: needs to be news-owned, setuid -- build looks after that
#	cp sh/[a-z]* $(NEWSBIN)/inject
#	cp ctl/[a-z]* $(NEWSBIN)/ctl
#	cp aux/[a-z]* $(NEWSBIN)/relay
#	rm -f $(BIN)/inews $(NEWSCTL)/inews
#	ln $(NEWSBIN)/inject/inews $(BIN)/inews 2>/dev/null || cp sh/inews $(BIN)
#	ln $(NEWSBIN)/inject/inews $(NEWSCTL)/inews 2>/dev/null || cp sh/inews $(NEWSCTL)

#cmp:	relaynews
#	cmp $(NEWSBIN)/relay/relaynews relaynews
#	for f in `ls sh` ; do cmp $(NEWSBIN)/inject/$$f sh/$$f ; done
#	for f in `ls ctl` ; do cmp $(NEWSBIN)/ctl/$$f ctl/$$f ; done
#	for f in `ls aux` ; do cmp $(NEWSBIN)/relay/$$f aux/$$f ; done
#	cmp $(BIN)/inews sh/inews
#	cmp $(NEWSCTL)/inews sh/inews
#	ls -lg $(NEWSBIN)/relay/relaynews | egrep -s '^-rwsrwsr-x  1 news     news'

#check:	relaynews
#	cmp $(NEWSBIN)/relay/relaynews relaynews || true
#	for f in `ls sh` ; do cmp $(NEWSBIN)/inject/$$f sh/$$f || true ; done
#	for f in `ls ctl` ; do cmp $(NEWSBIN)/ctl/$$f ctl/$$f || true ; done
#	for f in `ls aux` ; do cmp $(NEWSBIN)/relay/$$f aux/$$f || true ; done
#	cmp $(BIN)/inews sh/inews || true
#	ls -lg $(NEWSBIN)/relay/relaynews | egrep -s '^-rwsrwsr-x  1 news     news'

#TODO.grep: TODO
#	-egrep TODO ../include/*.h *.h *.c sh/* | tr -s " \11" " " >$@
#	-egrep TODO ../lib*/*.[ch] | tr -s " \11" " " >>$@

print: printc printnonc
#	touch $@
#printc: $(CFILES)
#	$(PP) $? | $(PPBACK)
#	touch $@
#printnonc: $(NONCFILES)
#	pr $(PROPTS) $? | $P
#	touch $@
#clean:
#	rm -f core a.out relaynews *.o	
#	rm -rf regress/tmp

#r:	relaynews
#	chmod +x regress/regress
#	(cd regress; ./regress)

# header dependencies follow

active.o: CN:include/libc.h CN:include/news.h CN:include/config.h
active.o: active.h
article.o: CN:include/news.h article.h headers.h
caches.o: CN:include/news.h active.h caches.h transmit.h
mkdirs.o: CN:include/libc.h CN:include/news.h
control.o: CN:include/libc.h CN:include/news.h CN:include/config.h
control.o: headers.h article.h caches.h history.h
fileart.o: CN:include/libc.h CN:include/news.h CN:include/config.h
fileart.o: active.h mkdirs.h headers.h article.h history.h system.h
hdrdefs.o: CN:include/news.h headers.h hdrint.h
hdrmunge.o: CN:include/libc.h CN:include/news.h fileart.h headers.h
hdrmunge.o: article.h hdrint.h
hdrparse.o: CN:include/libc.h CN:include/news.h headers.h hdrint.h
history.o: CN:include/libc.h CN:include/news.h CN:include/config.h
history.o: CN:include/fgetmfs.h headers.h article.h history.h
hostname.o: CN:include/news.h CN:include/config.h
ihave.o: CN:include/libc.h CN:include/news.h CN:include/config.h
ihave.o: headers.h article.h caches.h history.h
io.o: CN:include/news.h headers.h article.h
msgs.o: CN:include/news.h headers.h article.h
procart.o: CN:include/libc.h CN:include/news.h active.h control.h
procart.o: headers.h article.h history.h system.h
relaynews.o: CN:include/libc.h CN:include/news.h CN:include/config.h
relaynews.o: CN:include/fgetmfs.h active.h caches.h headers.h
relaynews.o: history.h
string.o: CN:include/libc.h CN:include/news.h
sys.o: CN:include/libc.h CN:include/fgetmfs.h CN:include/news.h
sys.o: CN:include/config.h system.h
transmit.o: CN:include/libc.h CN:include/news.h CN:include/config.h
transmit.o: headers.h active.h article.h system.h trbatch.h transmit.h
trbatch.o: CN:include/libc.h CN:include/news.h trbatch.h
