nes-proj/arch/cpu/msp430/Makefile.msp430
George Oikonomou c7e36a3d55 Change clean target to be more explicit
Previously, the clean target would delete a number of file extensions, many of which currently unknown to our build system (old platforms?). This commit changes the target so that it only cleans what we know we are building. Platforms / CPUs can append to the target with platform-specific build artifacts.
2018-03-30 21:22:59 +01:00

237 lines
6.3 KiB
Makefile

# $Id: Makefile.msp430,v 1.35 2011/01/19 07:30:31 adamdunkels Exp $
COOJA_PATH ?= $(CONTIKI)/tools/cooja
ifdef nodeid
CFLAGS += -DNODEID=$(nodeid)
endif
CFLAGS += -gstabs+
.SUFFIXES:
### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/arch/cpu/msp430
### Define the source files we have in the MSP430 port
ifndef CONTIKI_CPU_FAM_DIR
ifneq (,$(findstring msp430f1,$(MCU)))
CONTIKI_CPU_FAM_DIR = f1xxx
endif
endif
ifndef CONTIKI_CPU_FAM_DIR
ifneq (,$(findstring msp430f5,$(MCU)))
CONTIKI_CPU_FAM_DIR = f5xxx
endif
endif
ifndef CONTIKI_CPU_FAM_DIR
ifneq (,$(findstring msp430f2,$(MCU)))
CONTIKI_CPU_FAM_DIR = f2xxx f1xxx
endif
endif
ifndef CONTIKI_CPU_FAM_DIR
${error Unhandled MSP430 family: "$(MCU)"}
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 rtimer-arch.c int-master.c
UIPDRIVERS = slip.c crc16.c
CONTIKI_TARGET_SOURCEFILES += $(MSP430) \
$(SYSAPPS) \
$(UIPDRIVERS)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
### Compiler definitions
ifeq ($(WERROR),1)
CFLAGSWERROR= -Wall -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
LDFLAGSNO += -B -l $(CONTIKI_NG_PROJECT_MAP) -s __program_start
# Stack and heap size in hex
ifndef IAR_STACK_SIZE
IAR_STACK_SIZE=300
endif
# Set this to a positive number (hex) to enable malloc/free with IAR compiler
ifndef IAR_DATA16_HEAP_SIZE
IAR_DATA16_HEAP_SIZE=100
endif
ifndef IAR_DATA20_HEAP_SIZE
IAR_DATA20_HEAP_SIZE=0
endif
LDFLAGSNO += -D_STACK_SIZE=$(IAR_STACK_SIZE) -D_DATA16_HEAP_SIZE=$(IAR_DATA16_HEAP_SIZE) -D_DATA20_HEAP_SIZE=$(IAR_DATA20_HEAP_SIZE)
CUSTOM_RULE_C_TO_O = 1
%.o: %.c
$(TRACE_CC)
$(Q)$(CC) $(CFLAGS) $< -o $@
define FINALIZE_CYGWIN_DEPENDENCY
sed -e 's/ \([A-Z]\):\\/ \/cygdrive\/\L\1\//' -e 's/\\/\//g' \
<$(@:.o=.P) >$(@:.o=.d); \
rm -f $(@:.o=.P)
endef
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
$(TRACE_CC)
$(Q)$(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@
ifeq ($(HOST_OS),Windows)
@$(FINALIZE_CYGWIN_DEPENDENCY)
endif
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
# From version 4.6.x, mspgcc does not support generic MCU identifiers such as
# msp430x1611 in contrast to msp430f1611
ifndef CC_MCU
ifndef MSPGCC_VERSION
MSPGCC_VERSION := ${shell $(CC) -dumpversion}
endif
endif
ifndef CC_MCU
ifneq (,$(findstring 4.4.,$(MSPGCC_VERSION)))
CC_MCU := ${subst msp430f,msp430x,$(MCU)}
endif
endif
ifndef CC_MCU
ifneq (,$(findstring 3.2.,$(MSPGCC_VERSION)))
CC_MCU := ${subst msp430f,msp430x,$(MCU)}
endif
endif
ifndef CC_MCU
CC_MCU := $(MCU)
endif
### Checks for compiler version to enable 20-bit support
ifndef IAR
ifneq (,$(findstring 4.7.,$(shell msp430-gcc -dumpversion)))
ifdef CPU_HAS_MSP430X
ifeq ($(TARGET_MEMORY_MODEL),large)
CFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL)
CFLAGS += -mcode-region=far -mdata-region=far -msr20 -mc20 -md20
LDFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL) -mcode-region=far -mdata-region=far -msr20 -mc20 -md20
else
TARGET_MEMORY_MODEL = medium
CFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL)
CFLAGS += -ffunction-sections -fdata-sections -mcode-region=any
LDFLAGS += -mmemory-model=$(TARGET_MEMORY_MODEL) -Wl,-gc-sections
endif
endif
endif
endif
ifndef CFLAGSNO
CFLAGSNO = -Wall -mmcu=$(CC_MCU) $(CFLAGSWERROR)
endif
CFLAGS += -Os -fno-strict-aliasing
LDFLAGS += -mmcu=$(CC_MCU) -Wl,-Map=$(CONTIKI_NG_PROJECT_MAP)
### These flags can reduce the code size and RAM usage with up to 10%
SMALL ?= 1
ifeq ($(SMALL),1)
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
# Define the `_stack` symbol used by the stack check library to be equal to `_end`
LDFLAGS += -Wl,--defsym=_stack=_end
CFLAGS += $(CFLAGSNO)
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
### CPU-dependent cleanup files
CLEAN += *.firmware *.ihex
### Compilation rules
%-stripped.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIP) --strip-unneeded -g -x $@
%-stripped.o: %.o
$(STRIP) --strip-unneeded -g -x -o $@ $<
%.firmware: %.${TARGET}
mv $< $@
ifdef IAR
%.ihex: %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_NG_TARGET_LIB)
$(LD) $(LDFLAGSNO) -Fintel-extended $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
else
%.ihex: %.$(TARGET)
$(OBJCOPY) $^ -O ihex $@
endif
$(COOJA_PATH)/build.xml:
@echo '----------------'
@echo 'Could not find the COOJA build file. Did you run "git submodule update --init --recursive"?'
@echo '----------------'
$(COOJA_PATH)/mspsim/build.xml: $(COOJA_PATH)/build.xml
@echo '----------------'
@echo 'Could not find the MSPSim build file. Did you run "git submodule update --init --recursive"?'
@echo '----------------'
$(COOJA_PATH)/mspsim/mspsim.jar: $(COOJA_PATH)/mspsim/build.xml
(cd $(COOJA_PATH)/mspsim && ant jar)
%.mspsim: %.${TARGET} ${COOJA_PATH}/mspsim/mspsim.jar
java -jar ${COOJA_PATH}/mspsim/mspsim.jar -platform=${TARGET} $<
%.mspsim-maptable: %.$(TARGET)
java -classpath ${COOJA_PATH}/mspsim/mspsim.jar se.sics.mspsim.util.MapTable $(CONTIKI_NG_PROJECT_MAP)
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