nes-proj/cpu/msp430/Makefile.msp430

163 lines
4.0 KiB
Makefile

# $Id: Makefile.msp430,v 1.35 2011/01/19 07:30:31 adamdunkels Exp $
ifdef nodeid
CFLAGS += -DNODEID=$(nodeid)
endif
.SUFFIXES:
### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/cpu/msp430
### Define the source files we have in the MSP430 port
ifneq (,$(findstring msp430x1,$(MCU)))
CONTIKI_CPU_FAM_DIR = f1xxx
else
ifneq (,$(findstring msp430x5,$(MCU)))
CONTIKI_CPU_FAM_DIR = f5xxx
else
ifneq (,$(findstring msp430x2,$(MCU)))
CONTIKI_CPU_FAM_DIR = f2xxx f1xxx
else
${error Unhandled MSP430 family: "$(MCU)"}
endif
endif
endif
CONTIKI_CPU_DIRS = $(CONTIKI_CPU_FAM_DIR) . dev
MSP430 = msp430.c flash.c clock.c leds.c leds-arch.c \
watchdog.c lpm.c mtarch.c rtimer-arch.c
UIPDRIVERS = me.c me_tabs.c slip.c crc16.c
ELFLOADER = elfloader.c elfloader-msp430.c symtab.c
CONTIKI_TARGET_SOURCEFILES += $(MSP430) \
$(SYSAPPS) $(ELFLOADER) \
$(UIPDRIVERS)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
### Compiler definitions
ifdef WERROR
CFLAGSWERROR=-Werror
endif
ifdef IAR
CC = icc430
LD = xlink
AS = iasm430
AR = xar
OBJCOPY = ielftool
STRIP = strip
ifndef IAR_PATH
# This works with cygwin...
IAR_BIN_PATH = $(shell dirname "`which $(CC)`")
IAR_PATH_C = $(shell dirname "$(IAR_BIN_PATH)")
IAR_PATH = $(shell cygpath -m "$(IAR_PATH_C)")
endif
CFLAGS += --diag_suppress=Pa050 --silent
#defaults on the MSP430X core include file here (xlfn.h)
ifndef CFLAGSNO
CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430xlfn.h" $(CFLAGSWERROR)
# CFLAGSNO = --dlib_config $(IAR_PATH)/LIB/DLIB/dl430xlfn.h -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X $(CFLAGSWERROR) --data_model large --double=32
endif
CUSTOM_RULE_C_TO_O = 1
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) $< -o $@
# @$(FINALIZE_DEPENDENCY)
CUSTOM_RULE_C_TO_CO = 1
%.co: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
AROPTS = -o
else
GCC = 1
CC = msp430-gcc
LD = msp430-gcc
AS = msp430-as
AR = msp430-ar
NM = msp430-nm
OBJCOPY = msp430-objcopy
STRIP = msp430-strip
BSL = msp430-bsl
ifndef CFLAGSNO
CFLAGSNO = -Wall -mmcu=$(MCU) -g $(CFLAGSWERROR)
endif
CFLAGS += -Os -fno-strict-aliasing
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map
### These flags can reduce the code size and RAM usage with up to 10%
ifdef SMALL
CFLAGS += -ffunction-sections
# CFLAGS += -fdata-sections
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
endif # SMALL
endif # IAR
CFLAGS += $(CFLAGSNO)
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
### Compilation rules
%-stripped.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIP) --strip-unneeded -g -x $@
%.cm: %.co
$(LD) -i -r --unresolved-symbols=ignore-in-object-files -mmsp430x149 -o $@ $^
$(STRIP) --strip-unneeded -g -x $@
%-stripped.o: %.o
$(STRIP) --strip-unneeded -g -x -o $@ $<
%.o: ${CONTIKI_TARGET}/loader/%.S
$(AS) -o $(notdir $(<:.S=.o)) $<
%.firmware: %.${TARGET}
mv $< $@
%.ihex: %.$(TARGET)
$(OBJCOPY) $^ -O ihex $@
%.mspsim: %.${TARGET}
java -jar ${CONTIKI}/tools/mspsim/mspsim.jar -platform=${TARGET} $<
mspsim-maptable: contiki-${TARGET}.map
java -classpath ${CONTIKI}/tools/mspsim/mspsim.jar se.sics.mspsim.util.MapTable $<
core-labels.o: core.${TARGET}
${CONTIKI}/tools/msp430-make-labels core.${TARGET} > core-labels.S
$(AS) -o $@ core-labels.S
# cp core-labels.o app/
core-globals.o: core.${TARGET}
${CONTIKI}/tools/msp430-make-globals core.${TARGET} > core-globals.S
$(AS) -o $@ core-globals.S
loader-init.o: ${CONTIKI_TARGET}/loader/loader-init.S
$(AS) -o $(notdir $(<:.S=.o)) $<
# cp loader-init.o build-app/
.PHONY: symbols.c symbols.h
ifdef CORE
symbols.c:
$(NM) $(CORE) | awk -f $(CONTIKI)/tools/mknmlist > symbols.c
else
symbols.c symbols.h:
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
endif