2011-01-19 08:30:31 +01:00
|
|
|
# $Id: Makefile.msp430,v 1.35 2011/01/19 07:30:31 adamdunkels Exp $
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2006-10-09 11:15:48 +02:00
|
|
|
ifdef nodeid
|
|
|
|
CFLAGS += -DNODEID=$(nodeid)
|
|
|
|
endif
|
|
|
|
|
2006-06-18 00:41:10 +02:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
### Define the CPU directory
|
|
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/msp430
|
|
|
|
|
|
|
|
### Define the source files we have in the MSP430 port
|
|
|
|
|
2011-11-21 16:14:22 +01:00
|
|
|
ifneq (,$(findstring msp430x1,$(MCU)))
|
|
|
|
CONTIKI_CPU_FAM_DIR = f1xxx
|
2011-09-23 15:01:13 +02:00
|
|
|
else
|
2011-11-21 16:14:22 +01:00
|
|
|
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
|
2011-10-06 14:05:57 +02:00
|
|
|
endif
|
2011-09-23 15:01:13 +02:00
|
|
|
endif
|
2007-05-13 10:41:11 +02:00
|
|
|
|
2011-11-21 16:14:22 +01:00
|
|
|
CONTIKI_CPU_DIRS = $(CONTIKI_CPU_FAM_DIR) . dev
|
2011-10-06 14:05:57 +02:00
|
|
|
|
2006-12-19 10:22:25 +01:00
|
|
|
MSP430 = msp430.c flash.c clock.c leds.c leds-arch.c \
|
2010-08-24 18:23:20 +02:00
|
|
|
watchdog.c lpm.c mtarch.c rtimer-arch.c
|
2006-06-18 00:41:10 +02:00
|
|
|
UIPDRIVERS = me.c me_tabs.c slip.c crc16.c
|
2006-12-18 16:17:47 +01:00
|
|
|
ELFLOADER = elfloader.c elfloader-msp430.c symtab.c
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(MSP430) \
|
|
|
|
$(SYSAPPS) $(ELFLOADER) \
|
2009-11-19 18:33:05 +01:00
|
|
|
$(UIPDRIVERS)
|
2006-06-18 00:41:10 +02:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
### Compiler definitions
|
2011-12-19 18:13:40 +01:00
|
|
|
|
|
|
|
ifdef WERROR
|
|
|
|
CFLAGSWERROR=-Werror
|
|
|
|
endif
|
|
|
|
|
2011-04-06 20:08:48 +02:00
|
|
|
ifdef IAR
|
|
|
|
CC = icc430
|
|
|
|
LD = xlink
|
|
|
|
AS = iasm430
|
|
|
|
AR = xar
|
|
|
|
OBJCOPY = ielftool
|
|
|
|
STRIP = strip
|
|
|
|
|
|
|
|
ifndef IAR_PATH
|
|
|
|
# This works with cygwin...
|
2011-05-02 15:19:28 +02:00
|
|
|
IAR_BIN_PATH = $(shell dirname "`which $(CC)`")
|
|
|
|
IAR_PATH_C = $(shell dirname "$(IAR_BIN_PATH)")
|
|
|
|
IAR_PATH = $(shell cygpath -m "$(IAR_PATH_C)")
|
2011-04-06 20:08:48 +02:00
|
|
|
endif
|
|
|
|
|
2011-09-26 10:38:41 +02:00
|
|
|
CFLAGS += --diag_suppress=Pa050 --silent
|
|
|
|
|
2011-09-11 17:18:02 +02:00
|
|
|
#defaults on the MSP430X core include file here (xlfn.h)
|
|
|
|
ifndef CFLAGSNO
|
2011-06-05 00:21:47 +02:00
|
|
|
CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430xlfn.h" $(CFLAGSWERROR)
|
2011-05-02 15:19:28 +02:00
|
|
|
# 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
|
2011-09-11 17:18:02 +02:00
|
|
|
endif
|
|
|
|
|
2011-04-06 20:08:48 +02:00
|
|
|
CUSTOM_RULE_C_TO_O = 1
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $< -o $@
|
|
|
|
|
2012-03-07 23:03:15 +01:00
|
|
|
define FINALIZE_CYGWIN_DEPENDENCY
|
|
|
|
sed -e 's/ \([A-Z]\):\\/ \/cygdrive\/\L\1\//' -e 's/\\/\//g' \
|
|
|
|
<$(@:.o=.P) >$(@:.o=.d); \
|
|
|
|
rm -f $(@:.o=.P)
|
|
|
|
endef
|
|
|
|
|
2011-04-06 20:08:48 +02:00
|
|
|
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
|
|
|
|
$(OBJECTDIR)/%.o: %.c
|
2012-03-07 23:03:15 +01:00
|
|
|
$(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@
|
|
|
|
ifeq ($(HOST_OS),Windows)
|
|
|
|
@$(FINALIZE_CYGWIN_DEPENDENCY)
|
|
|
|
endif
|
|
|
|
|
2011-04-06 20:08:48 +02:00
|
|
|
CUSTOM_RULE_C_TO_CO = 1
|
|
|
|
%.co: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
|
|
|
|
|
|
|
|
AROPTS = -o
|
|
|
|
|
|
|
|
else
|
2012-03-07 23:03:15 +01:00
|
|
|
|
2011-04-06 20:08:48 +02:00
|
|
|
GCC = 1
|
2006-06-18 00:41:10 +02:00
|
|
|
CC = msp430-gcc
|
2007-01-24 17:11:48 +01:00
|
|
|
LD = msp430-gcc
|
2006-06-18 00:41:10 +02:00
|
|
|
AS = msp430-as
|
|
|
|
AR = msp430-ar
|
2007-03-23 00:57:33 +01:00
|
|
|
NM = msp430-nm
|
2006-06-18 00:41:10 +02:00
|
|
|
OBJCOPY = msp430-objcopy
|
|
|
|
STRIP = msp430-strip
|
|
|
|
BSL = msp430-bsl
|
2011-12-19 18:13:40 +01:00
|
|
|
ifndef CFLAGSNO
|
2008-01-08 09:01:01 +01:00
|
|
|
CFLAGSNO = -Wall -mmcu=$(MCU) -g $(CFLAGSWERROR)
|
2011-04-06 20:08:48 +02:00
|
|
|
endif
|
2011-12-19 18:13:40 +01:00
|
|
|
CFLAGS += -Os -fno-strict-aliasing
|
|
|
|
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map
|
2011-01-19 08:24:37 +01:00
|
|
|
|
|
|
|
### These flags can reduce the code size and RAM usage with up to 10%
|
2012-03-06 15:29:31 +01:00
|
|
|
ifeq ($(SMALL),1)
|
2011-01-19 08:24:37 +01:00
|
|
|
CFLAGS += -ffunction-sections
|
2011-09-21 20:02:04 +02:00
|
|
|
# CFLAGS += -fdata-sections
|
2011-01-19 08:24:37 +01:00
|
|
|
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
|
|
|
|
endif # SMALL
|
|
|
|
|
2011-12-19 18:13:40 +01:00
|
|
|
endif # IAR
|
|
|
|
|
|
|
|
CFLAGS += $(CFLAGSNO)
|
2011-01-19 08:24:37 +01:00
|
|
|
|
2006-06-18 00:41:10 +02:00
|
|
|
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)) $<
|
|
|
|
|
2008-12-16 14:54:25 +01:00
|
|
|
%.firmware: %.${TARGET}
|
|
|
|
mv $< $@
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2012-03-07 23:03:15 +01:00
|
|
|
ifdef IAR
|
|
|
|
%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
|
|
|
$(LD) $(LDFLAGSNO) -Fintel-extended -yn $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
|
|
|
else
|
2008-07-02 16:11:34 +02:00
|
|
|
%.ihex: %.$(TARGET)
|
2006-06-18 00:41:10 +02:00
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
2012-03-07 23:03:15 +01:00
|
|
|
endif
|
2006-06-18 00:41:10 +02:00
|
|
|
|
2008-12-16 14:54:25 +01:00
|
|
|
%.mspsim: %.${TARGET}
|
2008-11-24 12:09:36 +01:00
|
|
|
java -jar ${CONTIKI}/tools/mspsim/mspsim.jar -platform=${TARGET} $<
|
|
|
|
|
2010-04-20 17:38:09 +02:00
|
|
|
mspsim-maptable: contiki-${TARGET}.map
|
|
|
|
java -classpath ${CONTIKI}/tools/mspsim/mspsim.jar se.sics.mspsim.util.MapTable $<
|
|
|
|
|
2008-12-16 14:54:25 +01:00
|
|
|
core-labels.o: core.${TARGET}
|
|
|
|
${CONTIKI}/tools/msp430-make-labels core.${TARGET} > core-labels.S
|
2006-06-18 00:41:10 +02:00
|
|
|
$(AS) -o $@ core-labels.S
|
|
|
|
# cp core-labels.o app/
|
|
|
|
|
2008-12-16 14:54:25 +01:00
|
|
|
core-globals.o: core.${TARGET}
|
|
|
|
${CONTIKI}/tools/msp430-make-globals core.${TARGET} > core-globals.S
|
2006-06-18 00:41:10 +02:00
|
|
|
$(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/
|
|
|
|
|
2006-12-19 10:22:25 +01:00
|
|
|
.PHONY: symbols.c symbols.h
|
|
|
|
ifdef CORE
|
2007-01-24 17:11:48 +01:00
|
|
|
symbols.c:
|
2009-09-03 19:41:58 +02:00
|
|
|
$(NM) $(CORE) | awk -f $(CONTIKI)/tools/mknmlist > symbols.c
|
2006-12-19 10:22:25 +01:00
|
|
|
else
|
|
|
|
symbols.c symbols.h:
|
2011-04-03 13:24:58 +02:00
|
|
|
cp ${CONTIKI}/tools/empty-symbols.c symbols.c
|
|
|
|
cp ${CONTIKI}/tools/empty-symbols.h symbols.h
|
2006-12-19 10:22:25 +01:00
|
|
|
endif
|