
SRC = /home/inferno/fei/workspace/MiniIR

# Comment/uncomment the following line to enable/disable debugging
DEBUG = n
DEBUG2 = n

.SUFFIXES : .o .c .S

PROJECT = kernel.img

OBJS = loader.o \
       gdt.o \
       idt.o \
       exception.o \
       irq.o \
       timer.o \
       libc/libc.o \
       libc/printk.o \
       io.o \
       console.o \
       kernel.o
       

# if need to enable debug
ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DUSE_DEBUG # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

# if need to enable debug for level 2
ifeq ($(DEBUG2),y)
  DEBFLAGS = -O -g -DUSE_DEBUG2 # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif




INCLUDE = -I${SRC}/include
CFLAGS = -Wall \
		 -fstrength-reduce \
		 -fomit-frame-pointer \
		 -finline-functions \
		 -fno-builtin \
		 #-Werror \
		 -nostdlib \
		 -nostartfiles \
		 -nodefaultlibs


CC := gcc
LD := ld
AS := as


.c.o:
	$(CC) $(INCLUDE) $(CFLAGS) -c $<

.S.o:
	$(AS) $< -o $*.o
	
clean:
	find -iname "*.o" -or -iname "*~" | xargs rm -fr
	rm -fr ${PROJECT}