ROOTDEV = # This must be your Minix root file system.

LIB=/usr/lib
CFLAGS = -D_POSIX_SOURCE -D_MINIX
IMAGE = /tmp/minix.sys

all:	Edit_me_please_!!! and comment out me :-)
# Thanks a lot.
# You must edit this file to select your own Minix root partition. Please 
# check or modify first line, then comment out or delete above line to compile.

all:	init bootblok build menu

init:	$(LIB)/libc.a init.s $(LIB)/head.s
	asld -o init  $(LIB)/head.s init.s $(LIB)/libc.a  $(LIB)/end.s
	@echo init done.

# bootblok.s is the source of the MINIX boot block.  The bootblock is the
# first 512 bytes on the image file and on the boot diskette.  When bootblok.s
# is assembled, it generates a short binary file (less than 400 bytes) that
# must be stripped of its header and copied to the file bootblok.  The dd
# command below does this.  If everything has been done right, the bootblok
# file should begin with the following 8 words, in hex:
# c0b8 8e07 33d8 b8f6 2fe0 c08e ff33 00b9
# The exact procedure for going from bootblok.s to the binary file stripped of
# its header is somewhat operating system dependent.  Some assemblers make
# an object (.s) file; others make an a.sut file directly. If your boot 
# diskette does not start out by printing 'Booting MINIX X.Y' the problem is
# probably that you have not made a good boot block.

bootblok: bootblok.x
	/usr/lib/cpp -DASLD -P bootblok.x > bootblok.s
	asld  bootblok.s 
	dd if=a.out of=bootblok bs=16w skip=1 count=16 2>/dev/null
	@rm a.out
	@echo bootblok done.

mxboot:	mxboot.x
	/usr/lib/cpp -DASLD -P mxboot.x > mxboot.s
	asld mxboot.s 
	dd if=a.out of=mxboot bs=16w skip=1 count=32 2>/dev/null
	@rm a.out
	@ls -l mxboot
	@getlf "pause... Hit <ENTER> to install"
	mxinstall $(ROOTDEV) mxboot

mxinstall: mxinstall.c
	cc $(CFLAGS) -o mxinstall mxinstall.c

assistIPL: assistIPL.x
	/usr/lib/cpp -DASLD -P assistIPL.x > assistIPL.s
	asld assistIPL.s
	dd if=a.out of=assistIPL bs=16w skip=1 count=16 2>/dev/null
	@rm a.out
	@echo 'ok.'

FDassist: assistIPL.x
	/usr/lib/cpp -DASLD -DFDTEST -P assistIPL.x > FDassist.s
	asld FDassist.s
	dd if=a.out of=FDassist bs=16w skip=1 count=16 2>/dev/null
	@rm a.out
	@getlf "Insert blank diskette in drive 0 and hit return"
	cp FDassist /dev/fd0
	@echo 'ok.'

build:	build.c
	cc $(CFLAGS) -o build build.c
	@echo build done.

menu:	menu.s menu1.s loadfont.s
	@echo "Start linking menu. "
	asld -o menu menu1.s menu.s loadfont.s $(LIB)/libc.a $(LIB)/end.s
	@echo menu done.
menu.s: menu.c
	cc -c $(CFLAGS) -DDBCS -DDEBUG menu.c
menu1.s: menu1.x
	/usr/lib/cpp -DQUIET -P menu1.x > menu1.s
loadfont.s:	loadfont.c
	cc -c $(CFLAGS) -DDBCS -DDEBUG loadfont.c

# 'make image'  combines the bootblock, kernel, memory manager, file 
# system, init and menu into a single file, called image.  Each of these pieces
# appears in the image file just as the original does on the disk, except that
# the header at the front is removed, and each piece is padded out to an
# integral multiple of 16 bytes.  Build also prints a message telling how big
# the various pieces (except menu) are.
#
# 'make net' does the same thing, only with the networking code from the
# 'amoeba directory included
#
image:	build bootblok init menu ../kernel/kernel ../mm/mm ../fs/fs
	@build bootblok ../kernel/kernel ../mm/mm ../fs/fs init menu $(IMAGE)
	@getlf "Insert blank diskette in drive 0 and hit return"
	@cp $(IMAGE) /dev/fd1

net:	build bootblok init menu
	@getlf "Insert blank diskette in drive 0 and hit return"
	@build bootblok ../amoeba/kernel/kernel ../amoeba/mm/mm \
		../amoeba/fs/fs init menu net_image
	@cp net_image /dev/fd0

clean:	
	@rm -f *.bak
