-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (48 loc) · 1.25 KB
/
Makefile
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
TARG = WS2
MCU = atmega32u4
F_CPU = 16000000
# Includes
INCLUDES = -I. -I/usr/include/avr -Iinclude -Iusb
# Source files
SRCS = \
usb/usb_serial.c \
timer.c \
i2c.c \
dht22.c \
bmp085.c \
ds3231.c \
lcd.c \
usart.c \
nmea.c \
main.c
# Compiler options
OPTIMIZE = -Os -mcall-prologues
#CFLAGS = -g -Wall -Werror -lm $(OPTIMIZE) -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DTWO_LINE_LCD -std=c99 $(INCLUDES)
CFLAGS = -g -Wall -lm $(OPTIMIZE) -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DTWO_LINE_LCD -std=c99 $(INCLUDES)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wundef
#LDFLAGS = -g -Wall -Werror -mmcu=$(MCU)
LDFLAGS = -g -Wall -mmcu=$(MCU)
# AVR toolchain and flasher
CC = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
AVRDUDE = avrdude
PORT = /dev/arduino
OBJS = $(SRCS:.c=.o)
all: $(TARG)
$(TARG): $(OBJS)
$(CC) $(LDFLAGS) -o $@.elf $(OBJS) -lm
$(OBJCOPY) -O ihex -R .eeprom -R .nwram $@.elf $@.hex
$(OBJDUMP) -S $@.elf > $@.asm
$(SIZE) $@.elf
$(SIZE) --target=ihex $@.hex
# rm $@.elf
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(TARG).elf $(TARG).hex $(TARG).asm $(OBJS)
install: flash
flash: $(TARG)
$(AVRDUDE) -cavr109 -P$(PORT) -p $(MCU) -U flash:w:$(TARG).hex:i