#
# HISTORY
#   
#   8-Jan-88 Mary Thompson @ Carnegie Mellon
#	Added install of rc.sh  as /usr/mach/.rc
#
#  10-Nov-87 Mary Thompson @ Carnegie Mellon
#	This version uses the mach sources and installs them in 
#	$(DSTDIR)/bin
#
#  These sources are kept here for safekeeping.  The installed
#  version of w and ps come from facilities.
#
DSTDIR=/usr/mach
CFLAGS = -O
LIBS=${DSTDIR}/lib/libmach.a -ltermcap
INSTALL= mach_install

all:	ps.x 
install: ps.install rc.install

ps.o:	ps.mach.c
	${CC} -c  ${CENV} -DKERNEL_FEATURES ${CFLAGS} ps.mach.c && \
	mv -f ps.mach.o ps.o

ps.x:	ps.o
	@rm -f iv.x; make iv.x
	iv.x >ps.iv
	${CC} -DKERNEL_FEATURES -o ps.x ps.o ${LIBS}

w.o:	w.database.c
	${CC} -c ${CENV} -DKERNEL_FEATURES ${CFLAGS} w.database.c && \
	mv -f w.database.o w.o

w.x:	w.o
	@rm -f iv.x; make iv.x
	iv.x >w.iv
	${CC} -DKERNEL_FEATURES -o w.x w.o 

iv.x: iv.c
	cc ${CENV} -DKERNEL_FEATURES -o iv.x iv.c

iv.c:
	@echo '#include <sys/version.h>' >iv.c
	@echo '#include <stdio.h>' >>iv.c
	@echo 'main(){fprintf(stderr,"INCLUDE VERSION: %d\n",INCLUDE_VERSION);\
	              printf("%d\n", INCLUDE_VERSION);}' >>iv.c


rc.install: rc.csh
	${INSTALL} -c rc.csh ${DSTDIR}/.rc
	touch rc.install

# must set group to kmem and setgid

ps.install: ps.x ps.iv
	${INSTALL} -c -s -g kmem -m 6755 ps.x ${DSTDIR}/bin/ps.iv`cat ps.iv` && \
	touch ps.install

w.install: w.x w.iv
	${INSTALL} -c -s -g kmem -m 2755 w.x ${DSTDIR}/bin/w.iv`cat w.iv` && \
	touch w.install

