# Makefile for the kernel image.

# Image name must be set.
image=un/known

MAKE=	exec make -$(MAKEFLAGS)
SYS=	..

programs:
	cd $(SYS)/kernel && $(MAKE)
	cd $(SYS)/mm && $(MAKE)
	cd $(SYS)/fs && $(MAKE)
	cd $(SYS)/task.stubs && $(MAKE)
	image=`build -name`; $(MAKE) image=$$image $$image

PROGRAMS=	$(SYS)/kernel/kernel $(SYS)/mm/mm $(SYS)/fs/fs \
		$(SYS)/task.stubs/init.stub

$(image):	$(PROGRAMS)
	installboot -image $(image) $(PROGRAMS)

# Standard Minix...
hdboot fdboot:
	@echo "There is no 'make $@', see build(8)." >&2; exit 1

# Generate Makefile dependencies / clean tree.
depend clean::
	cd $(SYS)/kernel && $(MAKE) $@
	cd $(SYS)/mm && $(MAKE) $@
	cd $(SYS)/fs && $(MAKE) $@
	cd $(SYS)/task.stubs && $(MAKE) $@

reallyclean:	clean
	rm -f *.*

# Make the root device bootable.
bootable:
	install -cs -m 644 /usr/mdec/boot /boot
	read root rest </etc/mtab && su root -c \
		"installboot -device $$root /usr/mdec/bootblock /boot"
