Project

General

Profile

Statistics
| Branch: | Revision:

root / arduino-1.0 / hardware / arduino / bootloaders / diskloader / Makefile @ 58d82c77

History | View | Annotate | Download (2.59 KB)

1 58d82c77 Tom Mullins
###############################################################################
2
# Makefile for DiskLoader
3
###############################################################################
4
5
## General Flags
6
PROJECT = DiskLoader
7
TARGET = DiskLoader.elf
8
CC = avr-gcc
9
10
# BOARD2
11
MCU = atmega32u4
12
AVR_FREQ   = 16000000L
13
14
# Specify the Arduino model using the assigned PID.  This is used by Descriptors.c
15
#   to set PID and product descriptor string
16
# Arduino Leonardo PID
17
ARDUINO_MODEL_PID = 0x0034
18
# Arduino Micro PID
19
#ARDUINO_MODEL_PID = 0x0035
20
21
# Change if your programmer is different
22
AVRDUDE_PROGRAMMER = avrispmkII
23
AVRDUDE_PORT = usb	   
24
25
# program name should not be changed...
26
PROGRAM    = DiskLoader
27
28
AVRDUDE = avrdude
29
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -p $(MCU)
30
31
## Options common to compile, link and assembly rules
32
COMMON = -mmcu=$(MCU)
33
34
override CFLAGS = -g -Wall -Os -mmcu=$(MCU) -DF_CPU=$(AVR_FREQ) -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) $(DEFS) -ffunction-sections -gdwarf-2 -fdata-sections -fno-split-wide-types
35
36
## Assembly specific flags
37
ASMFLAGS = $(COMMON)
38
ASMFLAGS += $(CFLAGS)
39
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
40
41
## Linker flags
42
LDFLAGS = $(COMMON)
43
LDFLAGS += -Wl,-gc-sections,-Map=DiskLoader.map,--section-start=.text=0x7800,--relax
44
LDFLAGS += -nodefaultlibs -nostartfiles
45
46
47
## Intel Hex file production flags
48
HEX_EEPROM_FLAGS = -j .eeprom
49
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
50
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
51
52
## Objects explicitly added by the user
53
LINKONLYOBJECTS = 
54
55
MODULES   := .
56
SRC_DIR   := $(addprefix src/,$(MODULES))
57
BUILD_DIR := $(addprefix build/,$(MODULES))
58
59
SRC       := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
60
OBJ       := $(patsubst src/%.cpp,build/%.o,$(SRC))
61
DEP		  := $(OBJ:%.o=%.d)
62
INCLUDES  := $(addprefix -I,$(SRC_DIR))
63
64
vpath %.cpp $(SRC_DIR)
65
66
.PHONY: all checkdirs clean
67
68
all: checkdirs $(TARGET) DiskLoader.hex DiskLoader.lss size
69
70
-include $(DEP)
71
72
checkdirs: $(BUILD_DIR)
73
74
$(BUILD_DIR):
75
	@mkdir -p $@
76
77
clean:
78
	@rm -rf build/
79
	@rm -f *.hex
80
	@rm -f *.elf
81
	@rm -f *.lss
82
	@rm -f *.map
83
84
define make-goal
85
$1/%.o: %.cpp
86
	$(CC) $(INCLUDES) $(CFLAGS) -c $$< -MD -o $$@
87
endef
88
89
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))
90
91
$(TARGET): $(OBJ)
92
	$(CC) $(LDFLAGS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) $^ -o $@
93
94
%.hex: $(TARGET)
95
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
96
	
97
%.lss: $(TARGET)
98
	avr-objdump -h -S $< > $@
99
100
size: $(TARGET)
101
	@echo
102
#	@avr-size -C --mcu=${MCU} ${TARGET}.elf
103
104
program: $(TARGET).hex
105
	$(AVRDUDE) $(AVRDUDE_FLAGS) -B 5 -u -U flash:w:$(TARGET).hex