2009-09-08 22:07:35 +02:00
|
|
|
### Compiler definitions
|
|
|
|
CC = sdcc
|
|
|
|
LD = sdcc
|
|
|
|
AS = sdcc
|
|
|
|
AR = sdcclib
|
|
|
|
OBJCOPY = objcopy
|
|
|
|
STRIP = strip
|
|
|
|
|
|
|
|
CFLAGS += --std-c99 --model-large --stack-auto -DSDCC_CC2430
|
|
|
|
ASFLAGS += -plosgff
|
|
|
|
LDFLAGS += --model-large --stack-auto -DSDCC_CC2430 --out-fmt-ihx
|
|
|
|
LDFLAGS += --xram-loc 57344 --xram-size 8192
|
2010-01-21 16:33:19 +01:00
|
|
|
##LDFLAGS += -L /home/user/local/share/sdcc/lib/large-stack-auto
|
|
|
|
##LDFLAGS += --verbose
|
|
|
|
##LDFLAGS += -V
|
2009-09-08 22:07:35 +02:00
|
|
|
AROPTS = -a
|
2010-01-21 16:33:19 +01:00
|
|
|
##HAVE_BANKING=1
|
|
|
|
ifeq ($(HAVE_BANKING),1)
|
|
|
|
#banking
|
|
|
|
LDFLAGS += --code-size 0x20000
|
|
|
|
LDFLAGS += -Wl-bCSEG=0x000000
|
|
|
|
LDFLAGS += -Wl-bBANK1=0x018000
|
|
|
|
LDFLAGS += -Wl-bBANK2=0x028000
|
|
|
|
LDFLAGS += -Wl-bBANK3=0x038000
|
|
|
|
#relocated code (for bank switching )
|
|
|
|
LDFLAGS += -Wl-r
|
|
|
|
CFLAGS += -DHAVE_SDCC_BANKING
|
|
|
|
#use this in $(call code_segment,$<) to get segment for a source file.
|
|
|
|
code_segment = --codeseg $(word 1,$(shell cat ${OBJECTDIR}/segment.rules | perl ${CONTIKI_CPU}/segment.rules.pl $1 ) CSEG )
|
|
|
|
|
|
|
|
else
|
|
|
|
#no banking
|
|
|
|
LDFLAGS += --code-loc 0000 --code-size 65500
|
|
|
|
code_segment =
|
|
|
|
endif
|
2009-09-08 22:07:35 +02:00
|
|
|
|
|
|
|
### CPU-dependent cleanup files
|
2010-01-21 16:33:19 +01:00
|
|
|
CLEAN += *.lnk *.sym *.lib *.ihx *.rel *.mem *.rst *.asm *_linear.hex
|
2009-09-08 22:07:35 +02:00
|
|
|
|
|
|
|
### CPU-dependent directories
|
|
|
|
CONTIKI_CPU_DIRS = . dev
|
|
|
|
|
|
|
|
### CPU-dependent source files
|
|
|
|
CONTIKI_SOURCEFILES += bus.c clock.c uart.c cc2430_rf.c dma.c
|
2010-01-21 16:33:19 +01:00
|
|
|
##CONTIKI_SOURCEFILES += uart_init.c uart_intr.c cc2430_rf_intr.c dma_intr.c adc.c clock_intr.c
|
2009-09-08 22:07:35 +02:00
|
|
|
CONTIKI_ASMFILES +=
|
|
|
|
|
|
|
|
CONTIKI_ASMOBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_ASMFILES:.S=.o)}
|
|
|
|
|
|
|
|
CONTIKI_CASMOBJECTFILES = ${addprefix $(OBJECTDIR)/,$(CONTIKI_CASMFILES:.cS=.o)}
|
|
|
|
|
|
|
|
CONTIKI_PLATFORM_DIRS = $(PLATFORM_APPDIRS) \
|
|
|
|
${addprefix $(CONTIKI)/platform/$(TARGET)/, $(CONTIKI_TARGET_DIRS)}
|
|
|
|
|
2010-01-21 16:33:19 +01:00
|
|
|
CONTIKI_CPU_DIRS_LIST = ${addprefix $(CONTIKI_CPU)/, \
|
|
|
|
$(CONTIKI_CPU_DIRS)}
|
|
|
|
|
2009-09-08 22:07:35 +02:00
|
|
|
### Compilation rules
|
|
|
|
|
2010-01-21 16:33:19 +01:00
|
|
|
|
|
|
|
SEGMENT_RULE_FILES = ${foreach dir, ${CONTIKI_PLATFORM_DIRS} ${CONTIKI_CPU_DIRS_LIST}, ${wildcard $(dir)/segment.rules} }
|
|
|
|
${OBJECTDIR}/segment.rules: ${SEGMENT_RULE_FILES}
|
|
|
|
echo ${SEGMENT_RULE_FILES}
|
|
|
|
cat ${SEGMENT_RULE_FILES} > $@
|
|
|
|
|
|
|
|
|
2009-09-09 09:32:02 +02:00
|
|
|
CUSTOM_RULE_C_TO_OBJECTDIR_O=1
|
2009-09-08 22:07:35 +02:00
|
|
|
CUSTOM_RULE_ALLOBJS_TO_TARGETLIB=1
|
|
|
|
|
2009-09-09 09:32:02 +02:00
|
|
|
ifdef CUSTOM_RULE_C_TO_OBJECTDIR_O
|
2010-01-21 16:33:19 +01:00
|
|
|
ifeq ($(HAVE_BANKING),1)
|
|
|
|
$(OBJECTDIR)/%.o: %.c ${OBJECTDIR}/segment.rules
|
|
|
|
@echo "Compile:"$<" to segment " $(call code_segment,$<)
|
|
|
|
$(CC) $(CFLAGS) -MM -c $< > $(@:.o=.d)
|
|
|
|
$(CC) $(call code_segment,$<) $(CFLAGS) -c $< -o $@
|
|
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
else
|
2009-09-09 09:32:02 +02:00
|
|
|
$(OBJECTDIR)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2009-10-15 14:43:53 +02:00
|
|
|
$(CC) $(CFLAGS) -MM -c $< > $(@:.o=.d)
|
2009-09-09 09:32:02 +02:00
|
|
|
@$(FINALIZE_DEPENDENCY)
|
|
|
|
endif
|
2010-01-21 16:33:19 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.rel: $(OBJECTDIR)/%.o
|
|
|
|
cp $< $@
|
|
|
|
|
2009-09-09 09:32:02 +02:00
|
|
|
|
2009-09-08 22:07:35 +02:00
|
|
|
ifdef CUSTOM_RULE_CS_TO_OBJECTDIR_O
|
|
|
|
$(OBJECTDIR)/%.o: %.cS
|
|
|
|
cp $< $(OBJECTDIR)/$*.c
|
|
|
|
$(CC) $(CFLAGS) -E $(OBJECTDIR)/$*.c > $(OBJECTDIR)/tmp
|
|
|
|
perl -pe "s/^#(.*)/;$$1/" $(OBJECTDIR)/tmp > $(OBJECTDIR)/$*.S
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $(OBJECTDIR)/$*.S
|
|
|
|
rm -f $(OBJECTDIR)/tmp
|
|
|
|
endif
|
|
|
|
|
|
|
|
#CUSTOM_RULE_ALLOBJS_TO_TARGETLIB
|
|
|
|
contiki-$(TARGET).lib: $(CONTIKI_OBJECTFILES) $(PROJECT_OBJECTFILES) $(CONTIKI_ASMOBJECTFILES) $(CONTIKI_CASMOBJECTFILES)
|
|
|
|
rm -f $@
|
|
|
|
for target in $^; do echo $$target >> $@; done
|
|
|
|
|
2010-01-21 16:33:19 +01:00
|
|
|
%.$(TARGET): %.ihx %_linear.hex
|
2009-09-08 22:07:35 +02:00
|
|
|
|
|
|
|
# .rel is the object file default suffix under sdcc
|
|
|
|
%.rel: %.co
|
|
|
|
mv $< $@
|
|
|
|
|
|
|
|
# .ihx is the sdcc binary output file
|
2010-01-21 16:33:19 +01:00
|
|
|
.PRECIOUS: %.ihx %.rel %_linear.hex
|
2009-09-08 22:07:35 +02:00
|
|
|
|
|
|
|
# .ihx is the sdcc binary output file
|
2010-01-21 16:33:19 +01:00
|
|
|
%.ihx: %.rel $(CONTIKI_TARGET_MAIN:.o=.rel) contiki-$(TARGET).lib
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(CONTIKI_TARGET_MAIN:.o=.rel) $*.rel -llibsdcc.lib -lcontiki-$(TARGET).lib
|
|
|
|
|
|
|
|
%_linear.hex: %.ihx
|
|
|
|
$(CONTIKI)/cpu/cc2430/converter/converter -f $< $@
|
2009-09-08 22:07:35 +02:00
|
|
|
|
|
|
|
# Force the compilation of %.$(TARGET) to compile the %.ihx file.
|
2010-01-21 16:33:19 +01:00
|
|
|
%.$(TARGET): %.ihx %_linear.hex
|
2009-09-08 22:07:35 +02:00
|
|
|
@
|