summaryrefslogtreecommitdiffstats
path: root/sw/programmer/avr/makefile
blob: 95fb5fe94ce173e7432bd8bed882cbe39fde52ca (plain)
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
###
# Project settings
#
TARGET := programmer
SOURCES := $(wildcard *.c)

###
# Compiler settings
#
CC   := avr-gcc
PORT := /dev/ttyUSB0
MCU  := atmega328p

CFLAGS  := -g -Wall -mcall-prologues -mmcu=$(MCU) -Os -I . \
			-DF_CPU=1000000UL
LDFLAGS := -Wl,-gc-sections -Wl,-relax

.PHONY: all clean program
all: $(TARGET).hex

clean:
	rm -f *.o *.hex *.obj *.bin

$(TARGET).hex: $(TARGET).bin
	avr-objcopy -R .eeprom -O ihex $(TARGET).bin $@

$(TARGET).bin: $(SOURCES)
	$(CC) $(CFLAGS) $(SOURCES) -o $@ $(LDFLAGS)

program: $(TARGET).hex
	avrdude -p $(MCU) -c usbasp -P usb -U flash:w:$(TARGET).hex