# Programs to delete and copy files with
REMOVE = rm -f

# The C and C++ compilers
GCC = /usr/cross/x86-64/bin/x86_64-elf-gcc -ffreestanding -mcmodel=large -nostdlib -O0
G++ = gcc 

# The linker
LD  = /usr/cross/x86-64/bin/x86_64-elf-ld -nostdlib -nodefaultlibs -T fuze64.ld 

INCLUDEDIR = include

# The object files belonging to the kernel
OBJS = \
\
arch/amd64/entry.o arch/amd64/gdt.o arch/amd64/grub.o \
arch/amd64/idt.o arch/amd64/paging.o \
arch/amd64/debugcon/debugconsole.o  \
arch/amd64/mp.o arch/amd64/acpi.o \
arch/amd64/apboot.o arch/amd64/apic.o \
arch/amd64/atomic.o arch/amd64/isr.o\
arch/amd64/page_fault.o \
\
main.o irqdispatch.o spinlock.o page_alloc.o heap_alloc.o \
\
lib/string.o lib/do_printf.o \
\

# The kernel filename
KERNELFN = fuze64

# Link the kernel statically with fixed text+data address @1M
$(KERNELFN) : $(OBJS)
	$(LD) -nostdlib -o $@ $(OBJS) -Bstatic

# Compile the source files
.cc.o:
	$(G++)  -Wall -fomit-frame-pointer -O -I$(INCLUDEDIR) -c -o $@ $<

.cc.s:
	$(G++)  -Wall -fomit-frame-pointer -O -I(INCLUDEDIR) -S -o $@ $<

.c.o:
	$(GCC)  -fomit-frame-pointer -O -I$(INCLUDEDIR) -c -o $@ $<

.c.s:
	$(GCC)  -fomit-frame-pointer -O -I(INCLUDEDIR) -S -o $@ $<

.S.o:
	$(GCC)  -fomit-frame-pointer -c -o $@ $<

.a.o:   $(GCC)  -fomit-frame-pointer -c -o $@ $<

# Clean up the junk
clean:
	$(REMOVE) $(OBJS) $(KERNELFN)


