diff options
Diffstat (limited to 'sw-avr/rom-loader/makefile')
-rw-r--r-- | sw-avr/rom-loader/makefile | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/sw-avr/rom-loader/makefile b/sw-avr/rom-loader/makefile index e68174f..85222c8 100644 --- a/sw-avr/rom-loader/makefile +++ b/sw-avr/rom-loader/makefile @@ -1,17 +1,24 @@ -CC=avr-gcc -CARGS=-Wall -mmcu=atmega328p -D__AVR_ATmega328p__ -Os -I. +SOURCES := main.c usart.c +OBJECTS := $(patsubst %.c,%.o,$(SOURCES)) -SOURCES=main.c +CFLAGS := -Wall -mmcu=atmega328p -Os -I. \ + -D__AVR_ATmega328p__ -DF_CPU=1000000UL -DBAUD=9600 +LDFLAGS := .PHONY: all flash clean -all: rom-loader.bin +all: rom-loader.hex -flash: rom-loader.bin - avrdude -c usbasp -p atmega328p +flash: rom-loader.hex + avrdude -c usbasp -p atmega328p -U flash:w:$< clean: - rm rom-loader.bin + rm -f *.bin *.hex *.o -rom-loader.bin: $(SOURCES) - $(CC) $(CARGS) $< -o $@ +rom-loader.hex: rom-loader.bin + avr-objcopy -R .eeprom -O ihex $< $@ +rom-loader.bin: $(OBJECTS) + avr-gcc $(CFLAGS) $(OBJECTS) -o $@ $(LDFLAGS) + +%.o: %.c + avr-gcc $(CFLAGS) $< -c -o $@ $(LDFLAGS) |