#	BSDI Makefile,v 1.3 1994/12/15 06:09:00 polk Exp

PROG=tcsh
# perhaps should just turn these off...
.if   ${MACHINE} == "i386"
CFLAGS+=-fcombine-regs -finline-functions -fstrength-reduce 
.endif
INCLUDES=-I${.CURDIR} -I. 
CFLAGS+=${INCLUDES} -DBSD4_4
LDADD+= -ltermcap
DPADD+=	${LIBTERMCAP}
SRCS=	sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
	sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
	sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
	sh.set.c sh.time.c glob.c mi.termios.c ma.setp.c \
	tw.help.c tw.init.c tw.parse.c tw.spell.c tw.comp.c ed.chared.c \
	ed.defns.c ed.init.c ed.inputl.c ed.refresh.c ed.screen.c \
	ed.xmap.c ed.term.c tc.alloc.c tc.bind.c tc.const.c \
	tc.disc.c tc.func.c tc.os.c tc.printf.c tc.prompt.c \
	tc.sched.c tc.sig.c tc.str.c tc.vers.c tc.who.c getmachine.c
CLEANFILES+=tc.const.h sh.err.h ed.defns.h getmachine.c gethost

afterinstall:
	-rm -f ${DESTDIR}/bin/${PROG}
	ln -s ../usr/contrib/bin/${PROG} ${DESTDIR}/bin/${PROG}

ed.defns.h: ed.defns.c
	@rm -f $@
	@echo '/* Do not edit this file, make creates it. */' > $@
	@echo '#ifndef _h_ed_defns' >> $@
	@echo '#define _h_ed_defns' >> $@
	grep '[FV]_' ${.CURDIR}/ed.defns.c | grep '^#define' >> $@
	@echo '#endif /* _h_ed_defns */' >> $@

sh.err.h: sh.err.c
	@rm -f $@
	@echo '/* Do not edit this file, make creates it. */' > $@
	@echo '#ifndef _h_sh_err' >> $@
	@echo '#define _h_sh_err' >> $@
	grep 'ERR_' ${.CURDIR}/sh.err.c | grep '^#define' >> $@
	@echo '#endif /* _h_sh_err */' >> $@

tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
	@rm -f $@
	@echo '/* Do not edit this file, make creates it. */' > $@
	@echo '#ifndef _h_tc_const' >> $@
	@echo '#define _h_tc_const' >> $@
	${CC} -E $(INCLUDES) -D_h_tc_const ${.CURDIR}/tc.const.c | \
	    grep 'Char STR' | \
	    sed -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
	    sort >> $@
	@echo '#endif /* _h_tc_const */' >> $@

getmachine.c: gethost.c host.defs sh.err.h tc.const.h ed.defns.h
	cc ${CFLAGS} -o gethost ${.CURDIR}/gethost.c
	./gethost ${.CURDIR}/host.defs > getmachine.c

.depend: tc.const.h sh.err.h ed.defns.h getmachine.c

.include <bsd.prog.mk>
