Split Makefile and configuration, restructure targets

This commit is contained in:
2018-09-08 14:01:17 +02:00
parent 61c131486b
commit e18133d6f4
2 changed files with 61 additions and 10 deletions

View File

@ -1,16 +1,41 @@
CC=avr-gcc
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=attiny2313
OBJ2HEX=avr-objcopy
AVRDUDE=avrdude
TARGET=midifs
# Include environment config
include Makefile.config
# Project specific settings
TARGET = midifs
MCU = t2313
help:
@echo
@echo "Availiable targets:"
@echo " help Displays this help"
@echo
@echo " compile Compiles source code"
@echo " info Outputs device memory information"
@echo " program Programs the device"
@echo " clean Deletes temporary files"
@echo
@echo " all Compile, info, program, clean"
@echo
# Some C flags
CFLAGS=-g -Os -Wall -mcall-prologues -mmcu=attiny2313
all: compile info program clean
compile: $(TARGET).hex
info:
avr-size $(TARGET).hex
program: compile
@$(AVRDUDE) -p $(MCU) -c $(PGMDEV) -P $(PGMOPT) -U flash:w:$(TARGET).hex:i
program : $(TARGET).hex
$(AVRDUDE) -p t2313 -c stk500v2 -P /dev/ttyS0 -U $(TARGET).hex
%.obj : %.o
$(CC) $(CFLAGS) $< -o $@
%.hex : %.obj
$(OBJ2HEX) -R .eeprom -O ihex $< $@
@$(OBJ2HEX) -R .eeprom -O ihex $< $@
clean :
rm -f *.hex *.obj *.o
clean:
@$(REMOVE) *.hex *.obj *.o