2010-06-09 16:43:22 +02: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 20:50:30 +01: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 16:43:22 +02: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 21:04:31 +01:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
2010-11-09 14:13:45 +01:00
|
|
|
CROSS ?= $(CROSS_COMPILE)
|
2010-06-09 16:43:22 +02:00
|
|
|
|
|
|
|
### Compiler definitions
|
|
|
|
CC = $(CROSS)gcc
|
|
|
|
LD = $(CROSS)gcc
|
|
|
|
AS = $(CROSS)as
|
|
|
|
AR = $(CROSS)ar
|
|
|
|
NM = $(CROSS)nm
|
|
|
|
OBJCOPY = $(CROSS)objcopy
|
|
|
|
STRIP = $(CROSS)strip
|
|
|
|
|
|
|
|
PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}
|
|
|
|
|
|
|
|
TEXT_BASE = 0x00400000
|
|
|
|
export TEXT_BASE
|
2013-01-05 23:08:59 +01:00
|
|
|
LINKERSCRIPT = $(OBJECTDIR)/mc1322x.lds
|
2010-06-09 16:43:22 +02: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 13:03:29 +01:00
|
|
|
ARM_FLAGS= -marm
|
2010-06-09 16:43:22 +02: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 15:24:06 +02: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 18:19:20 +02:00
|
|
|
LDFLAGS += -T $(LINKERSCRIPT) -nostartfiles -static -u_start -Wl,-Map=contiki-$(TARGET).map,-export-dynamic,--gc-sections
|
2010-06-09 16:43:22 +02: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 23:08:59 +01:00
|
|
|
CPPFLAGS += -P -C ${addprefix -D,${subst $(COMMA), ,$(DEFINES)}}
|
|
|
|
|
2010-06-09 16:43:22 +02:00
|
|
|
|
|
|
|
$(OBJECTDIR)/board.h: $(OBJECTDIR)
|
2012-02-22 00:57:22 +01:00
|
|
|
ifeq ($(HOST_OS),Windows)
|
2012-02-10 17:01:59 +01:00
|
|
|
ln -f $(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
|
2011-03-04 22:53:39 +01:00
|
|
|
else
|
2012-02-10 17:01:59 +01:00
|
|
|
ln -sf ../$(CONTIKI_CPU)/board/board.h $(OBJECTDIR)/board.h
|
2011-03-04 22:53:39 +01:00
|
|
|
endif
|
2010-06-09 16:43:22 +02:00
|
|
|
|
2013-01-05 23:08:59 +01:00
|
|
|
$(OBJECTDIR)/%.lds: $(CONTIKI_CPU)/%.lds.S
|
|
|
|
$(CPP) $(CPPFLAGS) $< > $@
|
2010-06-09 16:43:22 +02:00
|
|
|
|
|
|
|
$(OBJECTDIR)/isr.o: $(CONTIKI_CPU)/src/isr.c
|
|
|
|
$(CC) $(CFLAGS) $(ARM_FLAGS) $< -c -o $@
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(THUMB_FLAGS) $< -c
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(THUMB_FLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
CUSTOM_RULE_S_TO_OBJECTDIR_O = yes
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.o: %.S
|
|
|
|
$(CC) $(CFLAGS) $(AFLAGS) $(ARM_FLAGS) $< -c -o $@
|
|
|
|
|
|
|
|
CUSTOM_RULE_C_TO_CO=yes
|
|
|
|
|
|
|
|
%.co: %.c
|
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $(THUMB_FLAGS) $< -c -o $@
|
|
|
|
|
|
|
|
.PRECIOUS: %.bin %_$(TARGET).bin
|
|
|
|
|
|
|
|
%.ihex: %.$(TARGET)
|
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
|
|
|
|
|
|
|
%_$(TARGET).bin: %.elf
|
|
|
|
$(OBJCOPY) -O binary $< $@
|
|
|
|
|
|
|
|
%.$(TARGET): %_$(TARGET).bin
|
|
|
|
@
|
|
|
|
|
2013-01-05 23:08:59 +01:00
|
|
|
%.elf: $(OBJECTDIR)/board.h %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a $(STARTUP) $(OBJECTDIR)/mc1322x.lds
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -nostartfiles -o $@ $(filter-out %.a %.lds,$^) $(filter %.a,$^) $(filter %.a,$^)
|
2010-06-09 16:43:22 +02:00
|
|
|
|
|
|
|
|