-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.alternative
63 lines (48 loc) · 1.6 KB
/
Makefile.alternative
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
################################################################################
# Simple makefile for the led example
################################################################################
TARGET := simpleled
SRC := simpleled.c
RM := rm -rf
OBJS := $(SRC:%.c=%.o)
# All Target
all: $(TARGET).hex
# Tool invocations
%.o: %.c
@echo 'Building file: $<'
@echo 'Invoking: AVR Compiler'
avr-gcc -Wall -Os -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega2560 -DF_CPU=16000000UL -MMD -MP -MF"$(@:%.o=%.dep)" -MT"$(@:%.o=%.dep)" -c -o"$@" "$<"
@echo 'Finished building: $<'
@echo ' '
$(TARGET).elf: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: AVR C Linker'
avr-gcc -mmcu=atmega2560 -o$(TARGET).elf $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
$(TARGET).hex: $(TARGET).elf
@echo 'Create Flash image (ihex format)'
-avr-objcopy -R .eeprom -O ihex $(TARGET).elf $(TARGET).hex
@echo 'Finished building: $@'
@echo ' '
sizedummy: $(TARGET).elf
@echo 'Invoking: Print Size'
-avr-size --format=berkeley -t $(TARGET).elf
@echo 'Finished building: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(OBJS) $(TARGET).elf $(TARGET).hex $(SRC:%.c=%.dep)
-@echo ' '
program: $(TARGET).hex
@echo 'Invoking: Avrdude'
avrdude -c stk500v2 -p m2560 -P /dev/ttyACM0 -U flash:w:$(TARGET).hex
@echo 'Finished uploading: $@'
@echo ' '
program_check:
@echo 'Invoking: Avrdude'
avrdude -c stk500v2 -p m2560 -P /dev/ttyACM0
@echo ' '
.PHONY: all clean dependents sizedummy program program_check
.SECONDARY:
-include $(SRC:%.c=%.dep)