TARGET= kernel
MAPFILE= kernel.map
MAKEDEPEND=/usr/bin/makedepend
START= 0x100000
CC=/usr/bin/gcc
CXX=/usr/bin/g++
CFLAGS= -nostdlib -nostdinc -fno-stack-protector -Wall -fno-builtin -O2
CXXFLAGS= $(CFLAGS) -fno-exceptions -fno-rtti -fno-strict-aliasing -Wno-non-virtual-dtor
INCFLAGS= -I.
LDFLAGS= -Ttext $(START) -e start -Map $(MAPFILE)

DEPENDENCY=	./dependency

SRCS=	boot.S kernel.cc asmcore.S gdt.cc idt.cc intmgr.cc crtbegin.c crtend.c memmgr.cc timer.cc list.cc screen.cc task.cc keyboard.cc shell.cc shellcmd.cc string.cc fddrv.cc
OBJS=   boot.o kernel.o asmcore.o gdt.o idt.o intmgr.o crtbegin.o crtend.o memmgr.o timer.o list.o screen.o task.o keyboard.o shell.o shellcmd.o string.o fddrv.o

.c.o:
	$(CC) $(CFLAGS) $(INCFLAGS) -c $*.c
.cc.o:
	$(CXX) $(CXXFLAGS) $(INCFLAGS) -c $*.cc
.S.o:
	$(CC) $(CFLAGS) $(INCFLAGS) -c $*.S

all:    $(TARGET)
$(TARGET):      $(OBJS)
	$(LD) $(LDFLAGS) -o $@ $(OBJS) 

clean::
	rm -f $(TARGET) $(MAPFILE) $(OBJS) *~

install::	$(TARGET)
	sudo mount -t vfat /dev/fd0 ~/floppy
	sudo cp kernel ~/floppy/boot/.
	sudo umount ~/floppy

depend::
	$(MAKEDEPEND) -f$(DEPENDENCY) -- $(CXXFLAGS) $(INCFLAGS) -- $(SRCS)

include	$(DEPENDENCY)
