2011-08-03 14:34:09 +00:00
|
|
|
##########################################################################
|
|
|
|
# User configuration and firmware specific object files
|
|
|
|
##########################################################################
|
|
|
|
SRCS = $(wildcard *.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)))
|
2011-08-04 22:21:20 +00:00
|
|
|
CODS = $(foreach mod,$(SRCS),$(subst .c,.c0d,$(mod)))
|
|
|
|
NIKS = $(foreach mod,$(wildcard nick_*.c),$(subst .c,.nik,$(subst nick_,,$(mod))))
|
2011-08-03 14:34:09 +00:00
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# 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
|
|
|
|
##########################################################################
|
|
|
|
LDSRCFILE=ram.ld
|
|
|
|
LDFILE=loadable.ld
|
|
|
|
CFLAGS+=-mlong-calls -fno-toplevel-reorder
|
|
|
|
|
2011-08-11 08:16:55 +00:00
|
|
|
DOCRYPT=0
|
|
|
|
CRYPT=../../tools/crypto/xxtea
|
2011-08-04 22:21:20 +00:00
|
|
|
CRYPTFLAGS=-p
|
|
|
|
|
2011-08-11 08:16:55 +00:00
|
|
|
skey=`cd .. && ./getkey.pl l0dable_sign`
|
|
|
|
ekey=`cd .. && ./getkey.pl l0dable_crypt`
|
|
|
|
|
2011-08-05 00:00:32 +00:00
|
|
|
all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int
|
2011-08-03 14:34:09 +00:00
|
|
|
|
|
|
|
$(LDFILE):
|
|
|
|
-@echo "MEMORY" > $(LDFILE)
|
|
|
|
-@echo "{" >> $(LDFILE)
|
|
|
|
-@echo " sram(rwx): ORIGIN = 0x10002000 - $(RAMCODE), LENGTH = $(RAMCODE)" >> $(LDFILE)
|
|
|
|
-@echo "}" >> $(LDFILE)
|
|
|
|
-@echo "INCLUDE $(LDSRCFILE)" >> $(LDFILE)
|
|
|
|
|
|
|
|
%.o : %.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
%.elf: %.o $(FIRMWARE) $(LDFILE)
|
|
|
|
$(LD) $(LDFLAGS) -T $(LDFILE) -o $@ $<
|
|
|
|
$(SIZE) $@
|
|
|
|
|
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) $(OCFLAGS) -O binary $< $@
|
|
|
|
|
2011-08-04 22:21:20 +00:00
|
|
|
%.c0d: %.bin
|
2011-08-11 08:16:55 +00:00
|
|
|
ifeq "$(DOCRYPT)" "1"
|
|
|
|
$(CRYPT) -e -k $(ekey) -o $<.tmp $<
|
|
|
|
$(CRYPT) -s -k $(skey) -o $@ $<.tmp
|
|
|
|
rm -f $<.tmp
|
|
|
|
else
|
|
|
|
cp $< $@
|
|
|
|
endif
|
2011-08-04 22:21:20 +00:00
|
|
|
|
|
|
|
%.nik: .PHONY
|
|
|
|
@a=$@;a=nick_$${a%.nik}.c0d;echo mv $$a $@;mv $$a $@
|
|
|
|
|
|
|
|
1boot.int: 1boot.c0d .PHONY
|
|
|
|
mv $< $@
|
|
|
|
|
2011-08-05 00:19:22 +00:00
|
|
|
debug.int: debug.c0d .PHONY
|
|
|
|
mv $< $@
|
|
|
|
|
2011-08-03 14:34:09 +00:00
|
|
|
clean:
|
2011-08-04 09:07:32 +00:00
|
|
|
rm -f *.o *.elf *.bin usetable.h
|
2011-08-03 14:34:09 +00:00
|
|
|
|
|
|
|
$(OBJS): usetable.h
|
|
|
|
|
2011-08-04 09:07:32 +00:00
|
|
|
usetable.h:
|
|
|
|
./mktable.pl
|
|
|
|
|
2011-08-03 14:34:09 +00:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
.PHONY: $(LDFILE)
|