2011-06-15 21:31:02 +00:00
|
|
|
DIR?= loadable
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# User configuration and firmware specific object files
|
|
|
|
##########################################################################
|
|
|
|
SRCS = $(wildcard $(DIR)/*.c)
|
|
|
|
OBJS = $(foreach mod,$(SRCS),$(subst .c,.o,$(mod)))
|
|
|
|
ELFS = $(foreach mod,$(SRCS),$(subst .c,.elf,$(mod)))
|
|
|
|
BINS = $(foreach mod,$(SRCS),$(subst .c,.bin,$(mod)))
|
|
|
|
HDRS = $(foreach mod,$(SRCS),$(subst .c,.h,$(mod)))
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# GNU GCC compiler flags
|
|
|
|
##########################################################################
|
|
|
|
ROOT_PATH?= .
|
|
|
|
|
|
|
|
INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/core
|
|
|
|
|
|
|
|
include $(ROOT_PATH)/Makefile.inc
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Compiler settings, parameters and flags
|
|
|
|
##########################################################################
|
|
|
|
FIRMWARE=$(ROOT_PATH)/$(OUTFILE).elf
|
2011-07-05 00:45:55 +00:00
|
|
|
LDSRCFILE=$(DIR)/ram.ld
|
2011-06-15 21:31:02 +00:00
|
|
|
LDFILE=$(DIR)/loadable.ld
|
|
|
|
CFLAGS+=-mlong-calls
|
|
|
|
LDFLAGS+= -R $(FIRMWARE)
|
|
|
|
|
|
|
|
all: $(OBJS) $(ELFS) $(BINS) $(HDRS)
|
|
|
|
|
2011-07-05 00:45:55 +00:00
|
|
|
$(LDFILE):
|
|
|
|
-@echo "MEMORY" > $(LDFILE)
|
|
|
|
-@echo "{" >> $(LDFILE)
|
|
|
|
-@echo " sram(rwx): ORIGIN = 0x10002000 - $(RAMCODE), LENGTH = $(RAMCODE)" >> $(LDFILE)
|
|
|
|
-@echo "}" >> $(LDFILE)
|
|
|
|
-@echo "INCLUDE $(LDSRCFILE)" >> $(LDFILE)
|
|
|
|
|
2011-06-15 21:31:02 +00:00
|
|
|
%.o : %.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
%.elf: %.o $(FIRMWARE) $(LDFILE)
|
|
|
|
$(LD) $(LDFLAGS) -T $(LDFILE) -o $@ $<
|
|
|
|
$(SIZE) $@
|
|
|
|
|
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) $(OCFLAGS) -O binary $< $@
|
|
|
|
|
|
|
|
%.h: %.bin $(DIR)/bin2h.pl
|
|
|
|
$(DIR)/bin2h.pl $<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
cd $(DIR) && rm -f *.o *.elf *.bin
|
|
|
|
|
|
|
|
.SUFFIXES:
|
2011-07-05 00:45:55 +00:00
|
|
|
|
|
|
|
.PHONY: $(LDFILE)
|