#
# Makefile for the linux kernel.
#
# Note! Dependencies are done automagically by 'make dep', which also
# removes any old dependencies. DON'T put your own dependencies here
# unless it's something special (ie not a .c file).
#

#
# re-use any ckcore/Dahua files that we can.  Perhaps we should create
# a Dahua directory for shared files ?
#

VPATH := $(VPATH):../DH2004

ifdef CONFIG_FULLDEBUG
	AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
endif

#
#
# If you want to play with the HW breakpoints then you will
# need to add define this,  which will give you a stack backtrace
# on the console port whenever a DBG interrupt occurs.  You have to
# set up you HW breakpoints to trigger a DBG interrupt:
#
# AFLAGS += -DTRAP_DBG_INTERRUPT
# EXTRA_CFLAGS += -DTRAP_DBG_INTERRUPT
#

.S.o:
	$(CC) -D__ASSEMBLY__ $(AFLAGS) -I. -c $< -o $*.o

all: $(BOARD)/crt0_$(MODEL).o entry.o platform.o
O_TARGET := platform.o
obj-y := entry.o config.o signal.o ints.o

$(BOARD)/crt0_$(MODEL).o: $(BOARD)/crt0_$(MODEL).S ../../../../include/asm/ckcore.h ../../../../include/linux/autoconf.h


entry.o: entry.S ckcore_defs.h

ckcore_defs.h: ../../kernel/ckcore_defs.c ../../kernel/ckcore_defs.head ../../../../include/asm/ckcore.h ../../../../include/linux/autoconf.h
	rm -f ckcore_defs.d
	$(CC) $(filter-out -MD,$(CFLAGS)) -S ../../kernel/ckcore_defs.c
	cp ../../kernel/ckcore_defs.head ckcore_defs.h
	grep '^#define' ckcore_defs.s >> ckcore_defs.h
	rm ckcore_defs.s
	rm -f ../../mm/init.o
	rm -f ../../../../drivers/block/blkmem.o
	rm -f ../../../../drivers/char/ckserial.o
-include ckcore_defs.d

include $(TOPDIR)/Rules.make
