2008-02-07 19:56:56 +00:00
|
|
|
# $Id: Makefile.avr,v 1.10 2008/02/07 19:56:56 oliverschmidt Exp $
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
### Check if we are running under Windows
|
|
|
|
|
|
|
|
ifndef WINDIR
|
|
|
|
ifdef OS
|
|
|
|
ifneq (,$(findstring Windows,$(OS)))
|
|
|
|
WINDIR := Windows
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
### Define the CPU directory
|
|
|
|
CONTIKI_CPU=$(CONTIKI)/cpu/avr
|
|
|
|
|
|
|
|
### Define the source files we have in the AVR port
|
|
|
|
|
2007-11-16 09:19:22 +00:00
|
|
|
AVR = leds-arch.c leds.c clock.c random.c
|
2006-12-22 16:54:36 +00:00
|
|
|
ELFLOADER = elfloader.c elfloader-avr.c symtab-avr.c
|
|
|
|
TARGETLIBS = clock.c flash.c mtarch.c
|
2006-06-18 07:44:59 +00:00
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
CONTIKI_TARGET_SOURCEFILES += ${AVR} $(SENSORS) \
|
2006-06-18 07:44:59 +00:00
|
|
|
$(SYSAPPS) $(ELFLOADER) \
|
2007-11-16 09:19:22 +00:00
|
|
|
$(TARGETLIBS)
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
|
|
|
|
|
|
|
|
|
|
|
|
### Compiler definitions
|
|
|
|
CC = avr-gcc
|
2007-11-01 16:26:31 +00:00
|
|
|
LD = avr-gcc
|
2006-06-18 07:44:59 +00:00
|
|
|
AS = avr-as
|
|
|
|
AR = avr-ar
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
STRIP = avr-strip
|
|
|
|
CFLAGSNO = -I. -I$(CONTIKI)/core -I$(CONTIKI_CPU) \
|
|
|
|
-I$(CONTIKI)/platform/$(TARGET) \
|
|
|
|
${addprefix -I,$(APPDIRS)} \
|
2006-12-22 16:54:36 +00:00
|
|
|
-Wall -mmcu=$(MCU) -gstabs
|
2006-06-18 07:44:59 +00:00
|
|
|
CFLAGS = $(CFLAGSNO) -Os
|
2006-12-22 16:54:36 +00:00
|
|
|
BOOTLOADER_START = 0x1e000
|
|
|
|
LDFLAGS = -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
|
|
|
|
-Wl,--section-start=.bootloader=$(BOOTLOADER_START)
|
|
|
|
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
### Setup directory search path for source files
|
|
|
|
|
|
|
|
CONTIKI_TARGET_DIRS_CONCAT = ${addprefix $(CONTIKI)/platform/$(TARGET)/, \
|
|
|
|
$(CONTIKI_TARGET_DIRS)}
|
|
|
|
|
|
|
|
vpath %.c $(PROJECTDIRS) $(CONTIKI)/cpu/avr/dev \
|
|
|
|
$(CONTIKIDIRS) $(APPDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \
|
|
|
|
$(CONTIKI_CPU)
|
|
|
|
|
|
|
|
### Compilation rules
|
|
|
|
|
|
|
|
$(OBJECTDIR)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
%.ko: %.o
|
|
|
|
$(STRIP) -K _init -K _fini --strip-unneeded -g -x $< -o $@
|
|
|
|
|
2007-11-16 09:19:22 +00:00
|
|
|
%.elf: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a symbols.o
|
2006-06-18 07:44:59 +00:00
|
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(LDLIBS)
|
2006-12-22 16:54:36 +00:00
|
|
|
|
|
|
|
%.hex: %.out
|
2006-06-18 07:44:59 +00:00
|
|
|
$(OBJCOPY) $^ -O ihex $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
# Add a namelist to the kernel
|
2007-11-29 02:44:05 +00:00
|
|
|
%.out: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a
|
2006-12-22 16:54:36 +00:00
|
|
|
$(CONTIKI)/tools/make-empty-symbols
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
2007-11-23 06:22:52 +00:00
|
|
|
ifdef SYMBOLS
|
2006-12-22 16:54:36 +00:00
|
|
|
$(CONTIKI)/tools/avr-make-symbols $@
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
|
|
|
$(CONTIKI)/tools/avr-make-symbols $@
|
|
|
|
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
|
2007-11-23 06:22:52 +00:00
|
|
|
endif
|
2006-12-22 16:54:36 +00:00
|
|
|
|
|
|
|
#%.hex: %.elf
|
|
|
|
# $(OBJCOPY) -R .eeprom $^ -O ihex $@
|
|
|
|
|
|
|
|
%.eep: %.out
|
|
|
|
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
|
|
--change-section-lma .eeprom=0 -O ihex $^ $@
|
|
|
|
|
|
|
|
|
2006-06-18 07:44:59 +00:00
|
|
|
%-stripped.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
$(STRIP) --strip-unneeded -g -x $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
#%.ce: %.c
|
2008-02-07 19:56:56 +00:00
|
|
|
# $(CC) $(CFLAGS) -c $< -o $@
|
2007-11-16 09:19:22 +00:00
|
|
|
# $(STRIP) --strip-unneeded -g -x $@
|
2006-06-18 07:44:59 +00:00
|
|
|
|
2007-11-16 09:19:22 +00:00
|
|
|
#%.ce: %.co
|
|
|
|
# $(LD) -i -r --unresolved-symbols=ignore-in-object-files -mavr5 -o $@ $^
|
|
|
|
# $(STRIP) --strip-unneeded -g -x $@
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
%.co: %.c
|
2007-11-16 09:19:22 +00:00
|
|
|
$(CONTIKI)/tools/make-empty-symbols
|
2006-06-20 21:23:09 +00:00
|
|
|
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
|
2006-06-18 07:44:59 +00:00
|
|
|
|
|
|
|
%-stripped.o: %.o
|
|
|
|
$(STRIP) --strip-unneeded -g -x -o $@ $<
|
|
|
|
|
|
|
|
%.o: ${CONTIKI_TARGET}/loader/%.S
|
|
|
|
$(AS) -o $(notdir $(<:.S=.o)) $<
|
|
|
|
|
|
|
|
%.srec: %.$(TARGET)
|
|
|
|
$(OBJCOPY) -O srec $< $@
|
|
|
|
|
2006-12-22 16:54:36 +00:00
|
|
|
### Upload image
|
|
|
|
%.u: %.hex
|
|
|
|
avrdude ${AVRDUDE_OPTIONS} -P ${AVRDUDE_PORT} -c ${AVRDUDE_PROGRAMMER} -p ${MCU} -U flash:w:$<
|
|
|
|
|
2006-06-18 07:44:59 +00:00
|
|
|
symbols.c:
|
2007-11-16 09:19:22 +00:00
|
|
|
@${CONTIKI}/tools/make-empty-symbols
|