2010-06-09 14:43:22 +00:00
|
|
|
# -*- makefile -*-
|
|
|
|
|
|
|
|
# Adapted from Makefile.msp430
|
|
|
|
# Adapted from Makefile.at91sam7
|
|
|
|
|
|
|
|
### Define the CPU directory
|
|
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/mc1322x
|
|
|
|
|
|
|
|
### Define the source files we have in the AT91SAM7S port
|
|
|
|
|
|
|
|
CONTIKI_CPU_DIRS = . lib src board dev ../arm/common/dbg-io
|
|
|
|
|
2013-02-03 19:50:30 +00:00
|
|
|
MC1322X = debug-uart.c rtimer-arch.c watchdog.c contiki-maca.c contiki-misc.c leds-arch.c leds.c contiki-uart.c slip-uart1.c init.c config.c
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
DBG_IO = dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c
|
|
|
|
|
|
|
|
CPU_LIBS = $(notdir $(wildcard $(CONTIKI_CPU)/lib/*.c))
|
|
|
|
CPU_SRCS = $(notdir $(wildcard $(CONTIKI_CPU)/src/*.c)) $(notdir $(wildcard $(CONTIKI_CPU)/src/*.S))
|
|
|
|
|
|
|
|
CONTIKI_TARGET_SOURCEFILES += $(MC1322X) $(DBG_IO) $(CPU_LIBS) $(CPU_SRCS) $(SYSAPPS) $(ELFLOADER) \
|
|
|
|
$(TARGETLIBS) $(UIPDRIVERS) $(USB)
|
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
THREADS =
|
|
|
|
|
2010-11-17 20:04:31 +00:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2010-11-09 13:13:45 +00:00
|
|
|
CROSS ?= $(CROSS_COMPILE)
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
### Compiler definitions
|
|
|
|
CC = $(CROSS)gcc
|
|
|
|
LD = $(CROSS)gcc
|
|
|
|
AS = $(CROSS)as
|
|
|
|
AR = $(CROSS)ar
|
|
|
|
NM = $(CROSS)nm
|
|
|
|
OBJCOPY = $(CROSS)objcopy
|
2013-12-01 21:22:37 +00:00
|
|
|
OBJDUMP = $(CROSS)objdump
|
2010-06-09 14:43:22 +00:00
|
|
|
STRIP = $(CROSS)strip
|
|
|
|
|
|
|
|
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
|
|
|
|
|
|
|
|
TEXT_BASE = 0x00400000
|
|
|
|
export TEXT_BASE
|
2013-01-05 22:08:59 +00:00
|
|
|
LINKERSCRIPT = $(OBJECTDIR)/mc1322x.lds
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
STARTUP=$(OBJECTDIR)/start.o
|
|
|
|
|
|
|
|
ARCH_FLAGS= -mcpu=arm7tdmi-s -mthumb-interwork -march=armv4t -mtune=arm7tdmi-s -DCONFIG_ARM -D__ARM__ #-Wcast-align
|
|
|
|
THUMB_FLAGS= -mthumb -mcallee-super-interworking
|
2011-01-13 12:03:29 +00:00
|
|
|
ARM_FLAGS= -marm
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
CFLAGSNO = -I. -I$(CONTIKI)/core -I$(CONTIKI_CPU) -I$(CONTIKI_CPU)/loader \
|
|
|
|
-I$(CONTIKI_CPU)/dbg-io \
|
|
|
|
-I$(CONTIKI)/platform/$(TARGET) \
|
|
|
|
-I$(CONTIKI_CPU)/lib/include \
|
|
|
|
-I$(CONTIKI_CPU)/src \
|
|
|
|
-I$(CONTIKI_CPU)/board \
|
|
|
|
${addprefix -I,$(APPDIRS)} \
|
|
|
|
-DWITH_ASCII -DMCK=$(MCK) \
|
|
|
|
-Werror $(ARCH_FLAGS) -g
|
|
|
|
|
2012-05-06 13:24:06 +00:00
|
|
|
CFLAGS += $(CFLAGSNO) -Os -DRUN_AS_SYSTEM -DROM_RUN -fno-strict-aliasing -fno-common -ffixed-r8 -msoft-float -DTEXT_BASE=$(TEXT_BASE) -fno-builtin-printf -fno-builtin-sprintf -ffunction-sections -fdata-sections -MMD
|
2012-05-06 16:19:20 +00:00
|
|
|
LDFLAGS += -T $(LINKERSCRIPT) -nostartfiles -static -u_start -Wl,-Map=contiki-$(TARGET).map,-export-dynamic,--gc-sections
|
2010-06-09 14:43:22 +00:00
|
|
|
AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) -gstabs
|
|
|
|
|
|
|
|
CDEPFLAGS = $(CFLAGS) -D __MAKING_DEPS__
|
|
|
|
|
|
|
|
### Setup directory search path for source files
|
|
|
|
|
|
|
|
CUSTOM_RULE_C_TO_OBJECTDIR_O=yes
|
|
|
|
CUSTOM_RULE_C_TO_O=yes
|
|
|
|
|
|
|
|
CFLAGS += -I$(OBJECTDIR) -I$(CONTIKI_CPU)/board -DBOARD=$(TARGET)
|
2013-01-05 22:08:59 +00:00
|
|
|
CPPFLAGS += -P -C ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}}
|
|
|
|
|
2010-06-09 14:43:22 +00:00
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/board.h: $(CONTIKI_CPU)/board/board.h | $(OBJECTDIR)
|
2012-02-21 23:57:22 +00:00
|
|
|
ifeq ($(HOST_OS),Windows)
|
2013-06-20 22:45:41 +00:00
|
|
|
ln -f $< $@
|
2011-03-04 21:53:39 +00:00
|
|
|
else
|
2013-06-20 22:45:41 +00:00
|
|
|
ln -sf ../$< $@
|
2011-03-04 21:53:39 +00:00
|
|
|
endif
|
2010-06-09 14:43:22 +00:00
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/%.lds: $(CONTIKI_CPU)/%.lds.S | $(OBJECTDIR)
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CPP) $(CPPFLAGS) $< > $@
|
2010-06-09 14:43:22 +00:00
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/isr.o: $(CONTIKI_CPU)/src/isr.c | $(OBJECTDIR)
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
%.o: %.c
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) $(THUMB_FLAGS) $< -c
|
2010-06-09 14:43:22 +00:00
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.c | $(OBJECTDIR)
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) $(THUMB_FLAGS) -c $< -o $@
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
CUSTOM_RULE_S_TO_OBJECTDIR_O = yes
|
|
|
|
|
2013-06-20 22:45:41 +00:00
|
|
|
$(OBJECTDIR)/%.o: %.S | $(OBJECTDIR)
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) $(AFLAGS) $(ARM_FLAGS) $< -c -o $@
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
CUSTOM_RULE_C_TO_CO=yes
|
|
|
|
|
|
|
|
%.co: %.c
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $(THUMB_FLAGS) $< -c -o $@
|
2010-06-09 14:43:22 +00:00
|
|
|
|
|
|
|
.PRECIOUS: %.bin %_$(TARGET).bin
|
|
|
|
|
|
|
|
%.ihex: %.$(TARGET)
|
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
|
|
|
|
|
|
|
%_$(TARGET).bin: %.elf
|
|
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
%.$(TARGET): %_$(TARGET).bin
|
|
|
|
@
|
|
|
|
|
2013-01-05 22:08:59 +00:00
|
|
|
%.elf: $(OBJECTDIR)/board.h %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a $(STARTUP) $(OBJECTDIR)/mc1322x.lds
|
2013-11-22 14:53:30 +00:00
|
|
|
$(TRACE_CC)
|
|
|
|
$(Q)$(CC) $(LDFLAGS) $(CFLAGS) -nostartfiles -o $@ $(filter-out %.a %.lds,$^) $(filter %.a,$^) $(filter %.a,$^)
|
2010-06-09 14:43:22 +00:00
|
|
|
|
2013-12-01 21:22:37 +00:00
|
|
|
%.lst: %.elf
|
|
|
|
$(OBJDUMP) -DS $< > $@
|
2010-06-09 14:43:22 +00:00
|
|
|
|