#	Copyright (c) 1986 by National Semiconductor Corp.
#	All Rights Reserved
#
#ident	"@(#)makefile	3.12	5/16/88 Copyright (c) 1985, 1988 by National Semiconductor Corp."
#
SYS	= unix
NODE	= unix
REL	= 3.1
VER	= VDS
MACH	= vme532

#
# Variables set by each makefile unless overridden by environment
#
ROOT	=
SRC	= /usr/src
UTS	= ..

INS	= install
INSDIR	= $(ROOT)/
NAME	= $(NODE)$(MACH)
TYPE	= ns32000

#
# Variables passed along via arguments to lower level makefiles
#
CC	= cc
LD	= ld
INC	= $(ROOT)/usr/include
TCPINC	= $(ROOT)/usr/netinclude
DASHG	=
KFLAGS	= fil
MORECPP	=
FRC	=
RM	= /bin/rm

#
# Variables assigned and used within this makefile and constructed from above
#
CFLAGS	= $(PFLAGS) -Dns32000 $(CONFLAGS)
PFLAGS	= $(DASHG) -O$(KFLAGS) -I$(TCPINC) -I$(INC) -DINKERNEL $(MORECPP)
CONFLAGS= -DMACH=$(MACH) -DVER=$(VER) -DNODE=$(NODE) -DREL=$(REL) -DSYS=$(SYS)

all:	build $(UTS)/$(NAME)

fast:	$(UTS)/$(NAME)
	-if test -z "$(ROOT)" ; \
	then \
		chown bin conf.c low.s conf.o low.o ; \
		chgrp bin conf.c low.s conf.o low.o ; \
		chmod 664 conf.o low.o ; \
	fi;

build:
	cd $(SRC)/uts/$(MACH); \
	$(MAKE) -$(MAKEFLAGS) -f unix.mk \
		"INS=$(INS)" "INSDIR=$(INSDIR)" "INC=$(INC)" \
		"FRC=$(FRC)" "SYS=$(SYS)" "MORECPP=$(MORECPP)" \
		"CC=$(CC)" "LD=$(LD)" "DASHG=$(DASHG)" \
		"NODE=$(NODE)" "REL=$(REL)" "VER=$(VER)" "MACH=$(MACH)" \
		"TYPE=$(TYPE)" "KFLAGS=$(KFLAGS)" build

$(UTS)/$(NAME): $(UTS)/locore.o low.o conf.o $(UTS)/[0-9]*lib.* $(UTS)/name.o $(UTS)/disp.o
	-$(LD) -o $(UTS)/$(NAME) ld.file -e start -x $(UTS)/locore.o \
		 low.o conf.o $(UTS)/[0-9]*lib.* \
		 $(UTS)/name.o $(UTS)/disp.o
	-if test -z "$(ROOT)" ; \
	then \
		chmod 755 $(UTS)/$(NAME); \
		chown bin $(UTS)/$(NAME); \
		chgrp bin $(UTS)/$(NAME); \
	fi;

low.o:	low.s

low.s conf.c:	$(ROOT)/etc/master  makefile $(ROOT)/etc/master.d/[a-z]* \
		$(ROOT)/etc/master.d
	config -m $(ROOT)/etc/master $(ROOT)/etc/master.d/[a-z]*  
	-if test -z "$(ROOT)" ; \
	then \
		chmod 664 conf.c config.h low.s; \
	fi

clean:
	cd $(SRC)/uts/$(MACH); \
	$(MAKE) -$(MAKEFLAGS) -f unix.mk \
		"INS=$(INS)" "INSDIR=$(INSDIR)" "INC=$(INC)" \
		"FRC=$(FRC)" "SYS=$(SYS)" "MORECPP=$(MORECPP)" \
		"CC=$(CC)" "LD=$(LD)" "DASHG=$(DASHG)" \
		"NODE=$(NODE)" "REL=$(REL)" "VER=$(VER)" "MACH=$(MACH)"\
		"TYPE=$(TYPE)" "KFLAGS=$(KFLAGS)" clean
	$(RM) -f *.o

clobber:
	cd $(SRC)/uts/$(MACH); \
	$(MAKE) -$(MAKEFLAGS) -f unix.mk \
		"INS=$(INS)" "INSDIR=$(INSDIR)" "INC=$(INC)" \
		"FRC=$(FRC)" "SYS=$(SYS)" "MORECPP=$(MORECPP)" \
		"CC=$(CC)" "LD=$(LD)" "DASHG=$(DASHG)" \
		"NODE=$(NODE)" "REL=$(REL)" "VER=$(VER)" "MACH=$(MACH)"\
		"TYPE=$(TYPE)" "KFLAGS=$(KFLAGS)" clobber
	$(RM) -f $(UTS)/$(NAME) *.o low.s conf.c config.h

conf.o: conf.c \
	config.h \
	$(INC)/sys/param.h \
	$(INC)/sys/types.h \
	$(INC)/sys/sysmacros.h \
	$(INC)/sys/conf.h \
	$(INC)/sys/acct.h \
	$(INC)/sys/tty.h \
	$(INC)/sys/buf.h \
	$(INC)/sys/file.h \
	$(INC)/sys/inode.h \
	$(INC)/sys/proc.h \
	$(INC)/sys/map.h \
	$(INC)/sys/callo.h \
	$(INC)/sys/mount.h \
	$(INC)/sys/sysinfo.h \
	$(INC)/sys/var.h \
	$(INC)/sys/immu.h \
	$(INC)/sys/region.h \
	$(INC)/sys/pfdat.h \
	$(INC)/sys/tuneable.h \
	$(INC)/sys/swap.h \
	$(INC)/sys/iobuf.h \
	$(INC)/sys/ipc.h \
	$(INC)/sys/msg.h \
	$(INC)/sys/sem.h \
	$(INC)/sys/shm.h \
	$(INC)/sys/flock.h \
	$(FRC)

install:	all
	$(INS) -f $(INSDIR) "$(UTS)/$(SYS)$(MACH)"
