-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
32 lines (25 loc) · 837 Bytes
/
makefile
File metadata and controls
32 lines (25 loc) · 837 Bytes
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
name = output
device = /dev/tty.usbmodem14401
src = main.c
flags = -std=c11 -Os
baud = 9600
printf_min = -Wl,-u,vfprintf -lprintf_min #only int/string support
printf_float = -Wl,-u,vfprintf -lprintf_flt -lm #with float/double support
link_printf = #default
#link_printf = $(printf_min)
#link_printf = $(printf_float)
all : build program clean
build: $(src)
avr-gcc $(flags) -DBAUD=$(baud) -DF_CPU=16000000UL -mmcu=atmega328p \
$(link_printf) -o $(name).elf $(src)
avr-objcopy -O ihex -R .eeprom $(name).elf $(name).ihex
rm $(name).elf
list: $(src)
avr-gcc -c -g -Wa,-a,-ad $(flags) -DBAUD=$(baud) -DF_CPU=16000000UL \
-mmcu=atmega328p $(src) > $(name).lst
rm $(name).elf
program: build
avrdude -F -V -c arduino -p ATMEGA328P -P $(device) -b 115200 \
-U flash:w:$(name).ihex
clean:
rm -f $(name).ihex $(name).lst