#
#	Script_OS - 32 Bit protected mode scripted operating system
#	(C) 2005 Jason Hunt
#
#	File: Makefile
#
#	GNU Make Makefile for Script_OS

all: 
	mv	include/asm.inc.linux include/asm.inc
	cp	include/asm.inc	include/asm.inc.linux	
	nasm -f bin -o boot.bin boot/boot.asm
	nasm -f bin -o kload.bin kernel/kload.asm
	gcc -c -Wall -fverbose-asm -fno-builtin -nostdlib -nostdinc -mno-stack-arg-probe -march=i486 -I include kernel/*.c
	gcc -c -Wall -x assembler-with-cpp -march=i486 -nostdlib -D fix_underscore -I include kernel/*.s
	ld -T link.ln -o kernel.obj *.o
	
	objdump -D --line-numbers --source kernel.obj > kernel.1st
	objdump -D --line-numbers --source system.o > system.1st
	objcopy -S kernel.obj -O binary

disk: kernel.obj kload.bin boot.bin
	dd if=/dev/zero of=floppy.img bs=512 count=2880
	dd if=boot.bin of=floppy.img bs=512 conv=notrunc
	cat kload.bin > kernel.bin
	cat kernel.obj >> kernel.bin
	losetup /dev/loop1 floppy.img
	mount -t msdos /dev/loop1 mnt/
	cp kernel.bin mnt/
	umount mnt/
	losetup -d /dev/loop1
