#
#	@(#)Makefile.obj 1.10 90/07/26 SMI
#	Copyright (c) 1987-1990 Sun Microsystems, Inc.
#
#
# Makefile for Sun-4c SunOS
#
# This makefile is constructed from a machine description:
#	config machine
# Most changes should be made in the machine description
#	/sys/conf/``machineid''
# after which you should do
#	 config machineid
# Generic makefile changes should be made in
#	/sys/conf/Makefile.src
# after which config should be rerun for all machines.
#
# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
#
# -DTRACE	compile in kernel tracing hooks
# -DQUOTA	compile in file system quotas
#
ARCH=	sun4c
CPP=	/lib/cpp -undef -Dsparc -Dsun
CC=	cc -sparc
AS=	as
LD=	ld
AWK=	awk
GREP=	egrep
DESTDIR=
SYSDIR=	../..
CONFDIR=../../conf.common
MACHINE= ..
LDIR=	/usr/lib/lint
LINT1=	${LDIR}/lint1
LINT2=	${LDIR}/lint2
LCOPTS=	-C -Dlint ${CPPOPTS}
LOPTS=	-hbxn
LTMP=	/usr/tmp/lint.kernel
LTAIL=	${GREP} -v 'struct/union .* never defined' | \
	${GREP} -v 'possible pointer alignment problem' ; true

CPPOPTS=${IDENT} -DKERNEL -I. -I${MACHINE} -I${SYSDIR}
COPTS=	${CPPOPTS}
CFLAGS=	-O ${COPTS}

%OBJS

%CONFFILES

%CFILES

%SFILES

%LFILES

%LOAD

install: $(INSTALLFILES)
	install -d -o bin -m 755 ${DESTDIR}/usr/kvm/stand
	install -m 0755 $(INSTALLFILES) ${DESTDIR}/usr/kvm/stand

clean:
	$(RM) eddep $(INSTALLFILES) *.o *.pp *.L *errs makedep* makelinks
	@set -x; if ls *.s | ${GREP} -v mbglue.s; then \
	    $(RM) `ls *.s | ${GREP} -v mbglue.s`; fi

lint: Locore.L ${LFILES}
	@make lint2 LTMP=${LTMP}.$$$$

lint2:
	@cat Locore.L ${LFILES} > ${LTMP}
	@echo "Global Cross-checks:"
	@${LINT2} ${LTMP} ${LOPTS}
	@rm -f ${LTMP}

${SYSDIR}/sun/symbols.sort: ${SYSDIR}/sun/symbols.raw
	${GREP} -v '^#' ${SYSDIR}/sun/symbols.raw \
	    | sed 's/^	//' | sort -u > ${SYSDIR}/sun/symbols.sort

vers.o: ${CONFDIR}/newvers.sh ${CONFDIR}/RELEASE
	@sh ${CONFDIR}/newvers.sh ${CONFDIR}/RELEASE ${ARCH}
	@${CC} ${CFLAGS} -c vers.c

# the following is necessary because files depend on #if GENERIC
autoconf.o stubs.o : Makefile

# the following are necessary because the files depend on the types of
# sun cpu's included in the system configuration
machdep.o autoconf.o conf.o : Makefile

# depend on network configuration
af.o uipc_proto.o : Makefile

# depend on options
init_sysent.o vfs_conf.o : Makefile

depend: makedep
	echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
	echo '$$r makedep' >>eddep
	echo 'w' >>eddep
	cp Makefile Makefile.bak
	ex - Makefile < eddep
	rm eddep makedep makedep1 makedeperrs

makedep: ${CONFFILES} FRC
	@cat /dev/null >makedep
	-(for i in ${CFILES} ${SFILES} ; do \
		${CPP} -M ${CPPOPTS} ${SYSDIR}/$$i >> makedep; done) \
		2>makedeperrs
	sed \
		-e 's,^.*genassym\.o:,assym.s assym.L:,' \
		-e 's,^\(.*\)\.o:,\1.o \1.L:,' makedep > makedep1
	-(for i in ${CONFFILES} ; do \
		${CPP} -M ${CPPOPTS} $$i | sed \
		-e 's,^\(.*\)\.o:,\1.o \1.L:,' >>makedep1; done) \
		2>>makedeperrs
	${AWK} ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \
		else { if (length(rec $$3) > 78) { print rec; rec = $$0; } \
		       else rec = rec " " $$3 } } \
	      END { print rec } ' makedep1 > makedep
	@cat makedeperrs
	@(if [ -s makedeperrs ]; then false; fi)

FRC:

Locore.L:
	@echo Locore.c:
	@-(${CPP} ${LCOPTS} ${MACHINE}/Locore.c | \
	  ${LINT1} ${LOPTS} > Locore.L ) 2>&1 | ${LTAIL}

mbglue.o:
	${CPP} -DLOCORE ${CPPOPTS} mbglue.s >mbglue.pp
	${AS} -o mbglue.o mbglue.pp
	rm -f mbglue.pp

ioconf.o:
	${CC} -c ${CFLAGS} ioconf.c

ioconf.L:
	@echo ioconf.c:
	@-(${CPP} ${LCOPTS} ioconf.c | \
	  ${LINT1} ${LOPTS} > ioconf.L ) 2>&1 | ${LTAIL}

param.c: ${CONFDIR}/param.c
	rm -f param.c
	cp ${CONFDIR}/param.c .

param.o: param.c Makefile
	${CC} -c ${CFLAGS} ${PARAM} param.c

param.L:
	@echo param.c:
	@-(${CPP} ${LCOPTS} ${PARAM} ${CONFDIR}/param.c | \
	  ${LINT1} ${LOPTS} > param.L ) 2>&1 | ${LTAIL}

%RULES

# DO NOT DELETE THIS LINE -- make depend uses it

