#!smake
#ident  "$Revision: 1.11 $"

BASEVERSION=n32bit
WANTPARALLEL=yes-please

include $(ROOT)/usr/include/make/cmdcommondefs

COMMANDS=tcsh

LCDEFS= -D_BSD_TIME -D_OLD_TERMIOS
LLDLIBS=-ltermlib
LDIRT=	ed.defns.h sh.err.h tc.const.h

SHOBJS=	sh.o sh.dir.o sh.dol.o sh.err.o sh.exec.o \
	sh.char.o sh.exp.o sh.func.o sh.glob.o \
	sh.hist.o sh.init.o sh.lex.o sh.misc.o \
	sh.parse.o sh.print.o sh.proc.o sh.sem.o \
	sh.set.o sh.time.o glob.o mi.termios.o \
	ma.setp.o

TWOBJS=	tw.help.o tw.init.o tw.parse.o tw.spell.o tw.comp.o

EDOBJS=	ed.chared.o ed.refresh.o ed.screen.o ed.init.o \
	ed.inputl.o ed.defns.o ed.xmap.o ed.term.o

TCOBJS=	tc.alloc.o tc.bind.o tc.const.o tc.disc.o \
	tc.func.o tc.os.o tc.printf.o \
	tc.prompt.o tc.sched.o tc.sig.o tc.str.o \
	tc.vers.o tc.who.o 

OBJS= ${SHOBJS} ${TWOBJS} ${EDOBJS} ${TCOBJS}
CFILES= ${OBJS:.o=.c}

default: $(TARGETS)

include $(CMDCOMMONRULES)

tcsh: tcsh.precord
	${CORD} $@.precord $@.fb -o $@

tcsh.precord: ${OBJECTS} 
	${CCF} ${OBJECTS} ${LDFLAGS} -o $@

n32bitinstall: default
	$(INSTALL) -m 555 -F /usr/bin tcsh

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' >> $@
	egrep '[FV]_' ed.defns.c | egrep '^#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' >> $@
	egrep 'ERR_' sh.err.c | egrep '^#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. */' > $@
	${CCF} -E tc.const.c | egrep 'Char STR' | \
	    sed -e 's/Char \([a-zA-Z0-9_]*\)\(.*\)/extern Char \1[];/' | \
	    sort >> $@

# Dependencies.
#
# Don't know if we need all of these, but some of the dependencies are not
# obvious, so I left these in from the orignial tcsh Makefile. --pdc

config.h: config_f.h

${OBJECTS}: config.h sh.h sh.types.h sh.char.h sh.err.h sh.dir.h sh.proc.h \
	    pathnames.h sh.decls.h tc.h tc.const.h tc.decls.h tc.os.h tc.sig.h

EDINC=sh.o sh.func.o sh.lex.o sh.print.o sh.proc.o \
      sh.set.o tc.bind.o tc.os.o tc.prompt.o \
      tc.sched.o tw.parse.o
${EDOBJS} ${EDINC} : ed.h ed.decls.h

TWINC=ed.chared.o ed.inputl.o sh.exec.o sh.func.o \
      sh.set.o tc.func.o
${TWOBJS} ${TWINC}: tw.h tw.decls.h

glob.o sh.glob.o: glob.h

EDDINC=tc.bind.o tc.func.o tc.os.o
${EDOBJS} ${EDDINC}: ed.defns.h
