# makefile for C news relaynews

# =()<NEWSARTS = @<NEWSARTS>@>()=
#	AMIGA
#	NEWSARTS = /usr/spool/news
NEWSARTS = News:
# =()<NEWSBIN = @<NEWSBIN>@>()=
#	AMIGA
#	NEWSBIN = /usr/lib/newsbin
NEWSBIN = News:newsbin
# =()<NEWSCTL = @<NEWSCTL>@>()=
#	AMIGA
#	NEWSCTL = /usr/lib/news
NEWSCTL = News:news
# 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= /include
DEFINES= -DFJE -DAMIGA -DVOID=int -DFLUSHEVERY=6 -I$(INCLUDE)

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

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

#	AMIGA
#	DBM = -ldbm
DBM =

LIBS= $(DBM) vfprintf.o heapmem.o -lc

#	LINT=lint
#	LINTFLAGS=-haz $(DEFINES)
#	LLIBS=-llocal
# I wish I could make lint shut the fk up about some things.  Grrr!
#	LINTFILT=egrep -v '(possible pointer|long assign|can.t take|never used|nnfree|getdate|:$$)'

#	PROPTS=
#	P=stpr
#	PP=pp -Tpsc -fR # lazywriter
#	PPBACK=dps | stps # lazywriter

#	AMIGA
#	What is LIBSRCS for???
#	LIBOBJS=../libcnews.a
LIBSRCS=
LIBOBJS= /libcnews.lib

SRC=relaynews.c active.c article.c caches.c mkdirs.c control.c fileart.c \
	hdrdefs.c hdrcommon.c hdrparse.c hdrmunge.c \
	history.c io.c msgs.c procart.c \
	sys.c transmit.c trbatch.c ihave_no.c amiga.c $(LIBSRCS)
OBJ=relaynews.o active.o article.o caches.o mkdirs.o control.o fileart.o \
	hdrdefs.o hdrcommon.o hdrparse.o hdrmunge.o \
	history.o io.o msgs.o procart.o \
	sys.o transmit.o trbatch.o ihave_no.o amiga.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= $(INCLUDE)/*.h \
	active.h article.h caches.h mkdirs.h control.h cpu.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

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

relaynews: $(OBJ)
	ln $(OBJ) -o $@ $(LIBOBJS) $(LIBS)
#	blink from lib:c.o $(OBJ) to $@ lib $(LIBOBJS) $(LIBS)
#	$(CC) $(CFLAGS) $(OBJ) $(LIBS) $(LIBOBJS) -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
#		cp relaynews $(NEWSBIN)/relay
#		: needs to be news-owned, setuid -- build looks after that
#		chmod +x sh/* aux/* ctl/*
#		cp sh/* $(NEWSBIN)/inject
#		cp ctl/* $(NEWSBIN)/ctl
#		cp aux/* $(NEWSBIN)/relay
#		cp sh/postnews sh/inews $(BIN)

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

#	v7 v8 v9 usg bsd42:
#		test -d libos && exit 1
#		mv lib$@ libos # or ln -s lib$@ libos
#		make

#	print: printc printnonc
#		touch $@
#	printc: $(CFILES)
#		$(PP) $? | $(PPBACK)
#		touch $@
#	printnonc: $(NONCFILES)
#		pr $(PROPTS) $? | $P
#		touch $@
#	distr: $(FILES)
#		(echo relaynews update of `date`; echo ""; bundle $?) | /bin/mail cnews-update
#		touch $@

clean:
	rm -f core a.out relaynews *.o

# header dependencies follow

active.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
active.o:		active.h
article.o:		$(INCLUDE)/news.h article.h headers.h
caches.o:		$(INCLUDE)/news.h active.h caches.h transmit.h
mkdirs.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h
control.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
control.o:		headers.h article.h caches.h history.h
fileart.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
fileart.o:		active.h mkdirs.h headers.h article.h history.h system.h
hdrcommon.o:	$(INCLUDE)/news.h headers.h hdrint.h
hdrdefs.o:		$(INCLUDE)/news.h headers.h hdrint.h
hdrmunge.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h fileart.h headers.h
hdrmunge.o:		article.h hdrint.h
hdrparse.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h headers.h hdrint.h
history.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
history.o:		$(INCLUDE)/fgetmfs.h headers.h article.h history.h
hostname.o:		$(INCLUDE)/news.h $(INCLUDE)/config.h
ihave_no.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
ihave_no.o:		headers.h article.h caches.h history.h
io.o:			$(INCLUDE)/news.h headers.h article.h
msgs.o:			$(INCLUDE)/news.h headers.h article.h
procart.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h active.h control.h
procart.o:		headers.h article.h history.h system.h
relaynews.o:	$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
relaynews.o:	$(INCLUDE)/fgetmfs.h active.h caches.h cpu.h headers.h
relaynews.o:	history.h
string.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h
sys.o:			$(INCLUDE)/libc.h $(INCLUDE)/fgetmfs.h $(INCLUDE)/news.h
sys.o:			$(INCLUDE)/config.h system.h
transmit.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h $(INCLUDE)/config.h
transmit.o:		headers.h active.h article.h system.h trbatch.h transmit.h
trbatch.o:		$(INCLUDE)/libc.h $(INCLUDE)/news.h trbatch.h
