osd-contiki/cpu/avr/Makefile.avr

129 lines
3.4 KiB
Makefile
Raw Normal View History

# $Id: Makefile.avr,v 1.11 2008/10/14 09:44:12 adamdunkels Exp $
2006-06-18 09:44:59 +02:00
### Check if we are running under Windows
ifndef WINDIR
ifdef OS
ifneq (,$(findstring Windows,$(OS)))
WINDIR := Windows
endif
endif
endif
.SUFFIXES:
### Optimization setting
OPTI=s
2006-06-18 09:44:59 +02:00
### Define the CPU directory
CONTIKI_CPU=$(CONTIKI)/cpu/avr
### Define the source files we have in the AVR port
AVR = leds-arch.c leds.c clock.c random.c
ELFLOADER = elfloader.c elfloader-avr.c symtab-avr.c
TARGETLIBS = clock.c flash.c mtarch.c
2006-06-18 09:44:59 +02:00
CONTIKI_TARGET_SOURCEFILES += ${AVR} $(SENSORS) \
2006-06-18 09:44:59 +02:00
$(SYSAPPS) $(ELFLOADER) \
$(TARGETLIBS)
2006-06-18 09:44:59 +02:00
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
### Compiler definitions
CC = avr-gcc
LD = avr-gcc
2006-06-18 09:44:59 +02:00
AS = avr-as
AR = avr-ar
OBJCOPY = avr-objcopy
STRIP = avr-strip
CFLAGSNO = -I. -I$(CONTIKI)/core -I$(CONTIKI_CPU) $(USB_INCLUDES) \
2006-06-18 09:44:59 +02:00
-I$(CONTIKI)/platform/$(TARGET) \
${addprefix -I,$(APPDIRS)} \
-Wall -mmcu=$(MCU) -gdwarf-2 $(CONTIKI_PLAT_DEFS)
CFLAGS += $(CFLAGSNO) -O$(OPTI)
BOOTLOADER_START = 0x1FC00
LDFLAGS = -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map \
-Wl,--section-start=.bootloader=$(BOOTLOADER_START)
2006-06-18 09:44:59 +02: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 $(CONTIKI)/cpu/avr/dev/usb \
$(CONTIKI)/cpu/avr/dev/usb/rndis $(CONTIKI)/cpu/avr/dev/usb/serial \
$(CONTIKI)/cpu/avr/dev/usb/storage \
2006-06-18 09:44:59 +02:00
$(CONTIKIDIRS) $(APPDIRS) $(CONTIKI_TARGET_DIRS_CONCAT) \
$(CONTIKI_CPU) $(CONTIKI)/cpu/avr/radio/rf230 $(CONTIKI)/cpu/avr/radio/mac
2006-06-18 09:44:59 +02:00
### Compilation rules
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
%.ko: %.o
$(STRIP) -K _init -K _fini --strip-unneeded -g -x $< -o $@
%.elf: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a symbols.o
2006-06-18 09:44:59 +02:00
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter-out %.a,$^) $(filter %.a,$^) $(LDLIBS)
%.hex: %.out
2006-06-18 09:44:59 +02:00
$(OBJCOPY) $^ -O ihex $@
# Add a namelist to the kernel
%.out: %.co $(PROJECT_OBJECTFILES) contiki-$(TARGET).a
$(CONTIKI)/tools/make-empty-symbols
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
ifdef SYMBOLS
$(CONTIKI)/tools/avr-make-symbols $@
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
$(CONTIKI)/tools/avr-make-symbols $@
$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBC) symbols.c
endif
#%.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 09:44:59 +02:00
%-stripped.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
$(STRIP) --strip-unneeded -g -x $@
#%.ce: %.c
# $(CC) $(CFLAGS) -c $< -o $@
# $(STRIP) --strip-unneeded -g -x $@
2006-06-18 09:44:59 +02:00
#%.ce: %.co
# $(LD) -i -r --unresolved-symbols=ignore-in-object-files -mavr5 -o $@ $^
# $(STRIP) --strip-unneeded -g -x $@
2006-06-18 09:44:59 +02:00
%.co: %.c
$(CONTIKI)/tools/make-empty-symbols
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE -c $< -o $@
2006-06-18 09:44:59 +02: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 $< $@
### Upload image
%.u: %.hex
avrdude ${AVRDUDE_OPTIONS} -P ${AVRDUDE_PORT} -c ${AVRDUDE_PROGRAMMER} -p ${MCU} -U flash:w:$<
2006-06-18 09:44:59 +02:00
symbols.c:
@${CONTIKI}/tools/make-empty-symbols