# $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987 Sequent Computer Systems, Inc.
# All rights reserved
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.

# $Header: Makefile 2.1 87/04/06 $
#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
#
CFLAGS	= -O -DTELL -DVMUNIX -Ddebug -DVFORK ${INCLUDE}
XSTR	= /usr/ucb/xstr
CXREF	= /usr/ucb/cxref
VGRIND	= csh /usr/ucb/vgrind
CTAGS	= /usr/ucb/ctags

# strings.o must be last in OBJS since it can change when previous files compile
OBJS=	alloc.o printf.o sh.o sh.dir.o sh.dol.o sh.err.o sh.exec.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.sig.o sh.time.o \
	strings.o 

# Special massaging of C files for sharing of strings
.c.o:
	${CC} -E ${CFLAGS} $*.c | ${XSTR} -c -
	@sed '/\*rcsid/d' < x.c > $*.x.c
	${CC} -c ${CFLAGS} $*.x.c
	@rm -f x.c $*.x.c
	@mv $*.x.o $*.o

all:	csh

csh:	strings ${OBJS} sh.local.h
	rm -f csh
	${CC} ${OBJS} -o csh

strings:
	touch strings
	chmod +w strings

# strings.o and sh.init.o are specially processed to be shared
strings.o: strings
	${XSTR}
	$(CC) -R -c xs.c
	@rm -f xs.c
	@mv xs.o strings.o

sh.init.o:
	$(CC) -E $(CFLAGS) sh.init.c | $(XSTR) -c -
	$(CC) -R -c x.c
	@rm -f x.c
	@mv x.o sh.init.o
	
lint:
	lint ${CFLAGS} sh*.c

print:
	@pr READ_ME
	@pr makefile makefile.*
	@(size -l a.out; size *.o) | pr -h SIZES
	@${CXREF} sh*.c | pr -h XREF
	@ls -l | pr 
	@pr sh*.h [a-rt-z]*.h sh*.c alloc.c

vprint:
	@pr -l84 READ_ME TODO
	@pr -l84 makefile makefile.*
	@(size -l a.out; size *.o) | pr -l84 -h SIZES
	@${CXREF} sh*.c | pr -l84 -h XREF
	@ls -l | pr -l84
	@${CXREF} sh*.c | pr -l84 -h XREF
	@pr -l84 sh*.h [a-rt-z]*.h sh*.c alloc.c

vgrind:
	@cp /dev/null index
	@for i in *.h; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
	@for i in *.c; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
	@vgrind -t -x -h Index index >index.t

install:
	install -s csh ${DESTDIR}/bin/csh

clean:
	rm -f a.out strings x*.c *.x.c csh errs
	rm -f *.o sh.prof.c

tags: FRC
	${CTAGS} sh*.c

FRC:
