contiki/cpu/stm32w108/Makefile.stm32w108

179 lines
5.8 KiB
Makefile
Raw Normal View History

2010-10-25 09:03:38 +00:00
.SUFFIXES:
ifdef IAR
${info Using IAR...}
#IAR_PATH = C:/Program\ Files/IAR\ Systems/Embedded\ Workbench\ 5.4\ Evaluation
ifeq ($(IAR_PATH),)
${error IAR_PATH not defined! You must specify IAR root directory}
endif
endif
### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/cpu/stm32w108
### Define the source files we have in the STM32W port
CONTIKI_CPU_DIRS = . dev hal simplemac hal/micro/cortexm3 hal/micro/cortexm3/stm32w108
STM32W_C = leds-arch.c leds.c clock.c watchdog.c uart1.c uart1-putchar.c slip_uart1.c \
stm32w-radio.c stm32w_systick.c uip_arch.c rtimer-arch.c adc.c micro.c sleep.c \
micro-common.c micro-common-internal.c clocks.c mfg-token.c nvm.c flash.c rand.c
STM32W_S = spmr.s79 context-switch.s79
ifdef IAR
STM32W_C += low_level_init.c
STM32W_S += cstartup_M.s
else
STM32W_C += crt_stm32w108.c
endif
# .s and .s79 not specified here because in Makefile.include only .c and .S suffixes are replaced with .o.
CONTIKI_TARGET_SOURCEFILES += $(STM32W_C) \
$(SYSAPPS) $(ELFLOADER) \
$(TARGETLIBS)
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
ifdef IAR
TARGET_LIBFILES = $(CONTIKI_CPU)/simplemac/library/simplemac-library.a
else
ifdef PRINTF_FLOAT
TARGET_LIBFILES = $(CONTIKI_CPU)/simplemac/library/simplemac-library.a $(CONTIKI_CPU)/hal/micro/cortexm3/e_stdio_thumb2.a
else
TARGET_LIBFILES = $(CONTIKI_CPU)/simplemac/library/simplemac-library.a $(CONTIKI_CPU)/hal/micro/cortexm3/e_stdio_intonly_thumb2.a
endif
endif
# `$(CC) -print-file-name=thumb2/libc.a` `$(CC) -print-file-name=thumb2/libgcc.a`
### Compiler definitions
ifdef IAR
CC = iccarm
LD = ilinkarm
AS = iasmarm
AR = iarchive
OBJCOPY = ielftool
STRIP = strip
OPTI = -Ohz --no_unroll
CFLAGSNO = --endian=little --cpu=Cortex-M3 -e --diag_suppress Pa050 -D BOARD_HEADER=\"board.h\" \
-D BOARD_MB851 -D "PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/iar.h\"" -D CORTEXM3 \
-D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
-D __SOURCEFILE__=\"$*.c\" -lC $(OBJECTDIR) \
-I $(IAR_PATH)/arm/inc --dlib_config=DLib_Config_Normal.h
CFLAGS += $(CFLAGSNO) $(OPTI)
AROPTS = --create
ASFLAGS = -s+ -w+ --cpu Cortex-M3 -L$(OBJECTDIR)
LDFLAGS += --redirect _Printf=_PrintfSmall --redirect _Scanf=_ScanfSmall --map=contiki-$(TARGET).map \
--config $(CONTIKI_CPU)/hal/micro/cortexm3/stm32w108/iar-cfg.icf
OBJOPTS = --bin
else
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
AS = arm-none-eabi-gcc
AR = arm-none-eabi-ar
OBJCOPY = arm-none-eabi-objcopy
STRIP = arm-none-eabi-strip
SIZE = arm-none-eabi-size
OPTI = -Os -ffunction-sections -fshort-enums
CFLAGSNO = -mthumb -mcpu=cortex-m3 -fsigned-char -D "PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/gnu.h\"" \
-D BOARD_HEADER=\"board.h\" -g -Wall -Wno-strict-aliasing -mlittle-endian \
-D BOARD_MB851 -D CORTEXM3 -D CORTEXM3_STM32W108 -D PHY_STM32W108XX -D DISABLE_WATCHDOG -D ENABLE_ADC_EXTENDED_RANGE_BROKEN \
-D __SOURCEFILE__=\"$*.c\"
CFLAGS += $(CFLAGSNO) $(OPTI)
ASFLAGS = -mthumb -mcpu=cortex-m3 -fsigned-char -c -g -Wall -Os -ffunction-sections \
-mlittle-endian -fshort-enums -x assembler-with-cpp -Wa,-EL
LDFLAGS += -mcpu=cortex-m3 \
-mthumb \
-Wl,-T -Xlinker $(CONTIKI_CPU)/hal/micro/cortexm3/stm32w108/gnu.ld \
-Wl,-static \
-u Default_Handler \
-nostartfiles \
-Wl,-Map -Xlinker contiki-$(TARGET).map \
-Wl,--gc-sections
SIZEFLAGS = -A
OBJOPTS = -O binary
endif
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/linux/stm32w_flasher
# Check if we are running under Windows
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
FLASHER = $(CONTIKI)/tools/stm32w/stm32w_flasher/win/stm32w_flasher
endif
endif
ifndef PORT
# Flash with jlink
FLASHEROPTS = -f -r
else
# Flash on serial port with on-board bootloader
FLASHEROPTS = -f -i rs232 -p $(PORT) -r
endif
### Custom rules
OBJECTDIR = obj_$(TARGET)
ssubst = ${patsubst %.s,%.o,${patsubst %.s79,%.o,$(1)}}
CONTIKI_OBJECTFILES += ${addprefix $(OBJECTDIR)/,${call ssubst, $(STM32W_S)}}
vpath %.s79 $(CONTIKI_CPU)/hal/micro/cortexm3
vpath %.s $(CONTIKI_CPU)/hal/micro/cortexm3
ifdef IAR
# Check if we are in cygwin environment, so we must have paths like /cygdrive/c/... (checking TERM doesn't always work.)
2010-10-26 07:26:40 +00:00
ifneq (,$(findstring cygdrive,$(shell pwd)))
2010-10-25 09:03:38 +00:00
${info Cygwin detected.}
SEDCOMMAND = sed -e '1s,\($(OBJECTDIR)\\$*\)\.o: \(.\):,\1.o : /cygdrive/\l\2,g' -e '1!s,\($(OBJECTDIR)\\$*\)\.o: \(.\):, /cygdrive/\l\2,g' -e 's,\\\([^ ]\),/\1,g' -e 's,$$, \\,' -e '$$s, \\$$,,' < $(@:.o=.P) > $(@:.o=.d)
else
SEDCOMMAND = sed -e '1s,\($(OBJECTDIR)\\$*\)\.o:,\1.o : ,g' -e '1!s,\($(OBJECTDIR)\\$*\)\.o:, ,g' -e 's,\\\([^ ]\),/\1,g' -e 's,$$, \\,' -e '$$s, \\$$,,' < $(@:.o=.P) > $(@:.o=.d)
endif
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@
@$(SEDCOMMAND); rm -f $(@:.o=.P)
@$(FINALIZE_DEPENDENCY)
CUSTOM_RULE_C_TO_CO = 1
%.co: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
else #IAR
CUSTOM_RULE_LINK = 1
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
$(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} -Wl,-\( ${filter %.a,$^} $(TARGET_LIBFILES) -Wl,-\) -o $@
@echo >> contiki-$(TARGET).map
@$(SIZE) $(SIZEFLAGS) $@ >> contiki-$(TARGET).map
#%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(CONTIKI_OBJECTFILES)
# $(LD) $(LDFLAGS) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
# @echo "\n" >> contiki-$(TARGET).map
# @$(SIZE) $(SIZEFLAGS) $@ >> contiki-$(TARGET).map
endif #IAR
$(OBJECTDIR)/%.o: %.s79
$(AS) $(ASFLAGS) -o $@ $<
$(OBJECTDIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
%.bin: %.$(TARGET)
$(OBJCOPY) $(OBJOPTS) $< $@
%.flash: %.bin
$(FLASHER) $(FLASHEROPTS) $<