@echo off

rem /*
rem     exDOS - Experimental 32 Bit protected mode scripted operating system
rem     (C) 2005 Jason Hunt
rem     
rem     This program is free software; you can redistribute it and/or
rem     modify it under the terms of the GNU General Public License
rem     as published by the Free Software Foundation; either version 2
rem     of the License, or (at your option) any later version.
rem 
rem     This program is distributed in the hope that it will be useful,
rem     but WITHOUT ANY WARRANTY; without even the implied warranty of
rem     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
rem     GNU General Public License for more details.
rem 
rem     You should have received a copy of the GNU General Public License
rem     along with this program; if not, write to the Free Software
rem     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
rem 
rem     Contact: nulluser@gmail.com
rem 
rem     
rem     File: make.bat
rem */


path %path%;c:\progra~1\dev-cpp\bin;.\tools;


echo exDOS Build. (C) 2005 Jason Hunt
echo.
echo Assembling boot loader
rem echo.

nasmw -f bin -o boot.bin boot\boot.asm 


echo Assembling 16bit kernel loader
rem echo.

nasmw -f bin -o kload.bin kernel\kload.asm


rem goto done


echo Compiling kernel
rem echo.

rem -ffreestanding 


gcc -c -Wall -fverbose-asm -march=i486 -fno-builtin -nostdlib -nostdinc -mno-stack-arg-probe -I include kernel\*.c

gcc -c -Wall -I include kernel\*.s

rem as	 -I include kernel\*.s


echo Linking
rem echo.

ld -T link.ln -o kernel.obj *.o

objdump -D --line-numbers --source kernel.obj > kernel.lst
objdump -D --line-numbers --source system.o > system.lst

rem strip kernel.obj

rem Remove 512 byte header

objcopy -S kernel.obj -O binary

rem Now kernel is a flat version of the C code

echo Creating disk image
rem echo.

rem Stack the kernel on top of the loader

copy /b kload.bin + kernel.obj kernel.bin > nul

rem now kernel.bin has the loader and the C code

move kernel.bin disk > nul

rem make the disk

bfi -t="144" -b=boot.bin -f=floppy.img disk

rem clean up:
objdump -D --line-numbers --all-headers --full-contents --source cmd.o > cmd.lst

del *.o
del *.obj
del *.bin

:done

echo Done.
echo.

pause

