CC = gcc
CFLAGS	= -Wall -O2 -c
BOOT = boot
SECOND = second
TEST = test

all :${BOOT} ${SECOND}.bin ${BOOT}.bin
test	:${TEST}.bin

${SECOND}.bin: ${SECOND}.o
	ld -T ${SECOND}.ls -o $@ ${SECOND}.o -Map ${SECOND}.map

${BOOT}: ${BOOT}.o
	ld -T ${BOOT}.ls -o $@ ${BOOT}.o -Map ${BOOT}.map

${SECOND}.o: ${SECOND}.S
	${CC} ${CFLAGS} $<

${BOOT}.o: ${BOOT}.S
	${CC} ${CFLAGS} $<

${BOOT}.bin:${BOOT}
	dd if=/dev/zero of=${BOOT}.bin bs=512 count=2880
	dd if=${BOOT} of=${BOOT}.bin conv=notrunc
	dd if=${SECOND}.bin of=${BOOT}.bin bs=512 seek=1 conv=notrunc
	cp ${BOOT}.bin /dev/fd1

${TEST}.bin:${SECOND}.bin
	dd if=/dev/zero of=${TEST}.bin bs=512 count=2880
	dd if=${SECOND}.bin of=${TEST}.bin conv=notrunc
#	cp ${TEST}.bin /dev/fd1
	

clean:
	rm -f *.o *.map ${BOOT} ${SECOND}.bin ${SECOND}.o ${SECOND}.map *.bin
