include ../../../../../Utils/scripts/makedefs

DR_OBJ = ./output
DR_Utils = ../../../../../Utils/
DR_KERNEL = ../../../../../Kernel/
DR_KERNEL_LIB = $(DR_KERNEL)Library/
DR_KERNEL_INC = $(DR_KERNEL)Include/
DR_SRC_APP = ../../src/app/
DR_SRC_WEB = ../../src/web/
DR_SRC_SET = ../../src/settings/
INC_COM = $(DR_KERNEL_INC)com/
INC_RTOS = $(DR_KERNEL_INC)rtos/include/
INC_IPV4 = $(DR_KERNEL_INC)lwip/ipv4/

MY_INCLUDE_PATH = -I $(DR_KERNEL_INC) -I $(INC_COM) -I $(INC_RTOS) \
					-I $(INC_IPV4) -I $(DR_SRC_SET) -I $(DR_SRC_WEB)

FILES = $(DR_OBJ)/system_LPC17xx.o $(DR_OBJ)/startup_LPC17xx_gcc.o \
		$(DR_OBJ)/settings.o $(DR_OBJ)/web_ajax.o $(DR_OBJ)/user_main.o

all: clean $(FILES)
	$(CPP) $(OPTS) $(FILES) -T $(DR_Utils)/$(LD_SCRIPT) $(LK) -L$(DR_KERNEL_LIB) -lp212_kernel -o $(DR_OBJ)/user_main.axf -Wl,-Map=$(DR_OBJ)/output.map
	$(OBJ) -O binary $(DR_OBJ)/user_main.axf $(DR_OBJ)/user_main.bin
	java -jar $(DR_Utils)Bin/bin2aff_v3.jar $(DR_OBJ)/user_main.bin -c f1 -o $(DR_OBJ)/user_main.aff
	cs-rm *.tmp

$(DR_OBJ)/system_LPC17xx.o: $(DR_KERNEL_LIB)system_LPC17xx.c
	$(CC) $(OPTS) $(MY_INCLUDE_PATH) -c $(DR_KERNEL_LIB)system_LPC17xx.c -o $(DR_OBJ)/system_LPC17xx.o

$(DR_OBJ)/startup_LPC17xx_gcc.o: $(DR_KERNEL_LIB)startup_LPC17xx_gcc.s
	$(AS) $(AOPTS) $(MY_INCLUDE_PATH) $(DR_KERNEL_LIB)startup_LPC17xx_gcc.s -o $(DR_OBJ)/startup_LPC17xx_gcc.o

$(DR_OBJ)/settings.o: $(DR_SRC_SET)settings.c
	$(CC) $(OPTS) $(MY_INCLUDE_PATH) -c $(DR_SRC_SET)settings.c -o $(DR_OBJ)/settings.o

$(DR_OBJ)/web_ajax.o: $(DR_SRC_WEB)web_ajax.c
	$(CC) $(OPTS) $(MY_INCLUDE_PATH) -c $(DR_SRC_WEB)web_ajax.c -o $(DR_OBJ)/web_ajax.o

$(DR_OBJ)/user_main.o: $(DR_SRC_APP)user_main.c
	$(CC) $(OPTS) $(MY_INCLUDE_PATH) -c $(DR_SRC_APP)user_main.c -o $(DR_OBJ)/user_main.o

	
clean:
	cs-rm -f $(DR_OBJ)/*.o		