CONF=k8cpu
CONFLIST=k8cpu

# override with the list of paths where to put extra
# copies of the kernel. for each word $w in OTHERCOPIES,
# the kernel is copied to $w/$objtype/...
OTHERCOPIES=''

objtype=amd64
</$objtype/mkfile
p=9


9k:V:	$p$CONF

<| awk -f ../mk/parse $CONF
<../mk/bootmkfile
<../mk/portmkfile

OBJ=$MACH $CONF.root.$O $DEVS $PORT

$p$CONF:	$CONF.c $OBJ $LIB
	$CC $CFLAGS '-DKERNDATE='`{date -n} $CONF.c
	$LD -o $target -T0xfffffffff0110000 -R4096 -l $OBJ $CONF.$O $LIB
	$LD -o $target.elf -H5 -8 -T0xfffffffff0110000 -l $OBJ $CONF.$O $LIB
	size $target

$p$CONF.gz:	$p$CONF
	strip -o /fd/1 $p$CONF | gzip -9 > $p$CONF.gz

install:QV:	$p$CONF $p$CONF.gz
	for(d in '' $OTHERCOPIES){
		if(test -d $d/$objtype){
			cp $p$CONF $d/$objtype/$p$CONF 
			cp $p$CONF.gz $d/$objtype/$p$CONF.gz
			ls -l $d/$objtype/$p$CONF $d/$objtype/$p$CONF.gz
		}
	}
	echo done

init.out:	init9.$O initcode.$O /$objtype/lib/libc.a
	$LD -l -R1 -s -o init.out init9.$O initcode.$O -lc

l32p.$O:	${objtype}l.h
l64idt.$O:	${objtype}l.h
l64syscall.$O:	${objtype}l.h
l64sipi.$O:	${objtype}l.h
l64v.$O:	${objtype}l.h
l64acidt.$O:	${objtype}l.h
l64acsyscall.$O:	${objtype}l.h

${objtype}l.h:	$objtype.h
	rc ../mk/mkenum $objtype.h > $target

apic.$O:	apic.h io.h
devarch.$O:	../port/error.h /$objtype/include/ureg.h
fpu.$O:		amd64.h
fpu.$O:		/$objtype/include/ureg.h
ioapic.$O:	apic.h io.h
main.$O:	/sys/include/pool.h init.h
memory.$O:	amd64.h
mmu.$O:		amd64.h
mp.$O:		apic.h
sipi.$O:	apic.h sipi.h
svm.$O:		amd64.h
svm.$O:		/$objtype/include/ureg.h
syscall.$O:	../port/error.h /sys/src/libc/9syscall/sys.h
syscall.$O:	/sys/include/tos.h /$objtype/include/ureg.h
syscall.$O:	amd64.h
trap.$O:	../port/error.h io.h
trap.$O:	/sys/include/tos.h /$objtype/include/ureg.h

devaoe.$O:	../port/error.h ../port/netif.h ../ip/ip.h
devaoe.$O:	../386/aoe.h etherif.h
devether.$O:	../port/error.h ../port/netif.h etherif.h
devrtc.$O:	../port/error.h
ether8169.$O:	../port/error.h ../port/ethermii.h ../port/netif.h
ether8169.$O:	etherif.h
ether82557.$O:	../port/netif.h
ether82557.$O:	etherif.h io.h
etherigbe.$O:	../port/error.h ../port/ethermii.h ../port/netif.h
etherigbe.$O:	etherif.h io.h
etherm10g.$O:	../port/error.h ../port/netif.h
etherm10g.$O:	etherif.h io.h
etherm10g.$O:	../386/etherm10g2k.i ../386/etherm10g4k.i
i8259.$O:	io.h
kbd.$O:		../port/error.h io.h
pci.$O:		io.h
sdaoe.$O:	../port/error.h ../port/netif.h ../port/sd.h
sdaoe.$O:	../386/aoe.h etherif.h io.h
sdscsi.$O:	../port/error.h

random.$O:	../port/error.h
devacpi.$O: acpi.h
physalloc.$O: acpi.h

sipi.h:		l64sipi.$O
	$LD -o l64sipi.out -T0xfffffffff0003000 -R4 -l -s $prereq
	{echo 'uchar sipihandler[]={'
	 xd -1x l64sipi.out |
	 sed -e 's/^[0-9a-f]+ //'				\
	     -e '1,2d' -e '3s/^ .. .. .. .. .. .. .. ..//'	\
	     -e 's/ ([0-9a-f][0-9a-f])/0x\1,/g'
	 echo '};'} > $target

../root/nvram: 
	dd -if /dev/zero -of ../root/nvram -bs 512 -count 1
	nvram=../root/nvram auth/wrkey
