epromsim/Makefile

49 lines
1.3 KiB
Makefile
Raw Normal View History

2017-05-25 11:19:25 +02:00
CC := avr-gcc
LD := avr-ld
OBJCOPY := avr-objcopy
OBJDUMP := avr-objdump
SIZE := avr-size
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
TARGET = epromsim
SOURCE = $(wildcard *.c)
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
MCU=attiny2313
AVRDUDE_MCU=attiny2313
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
AVRDUDE_FUSES=lfuse:w:0xff:m hfuse:w:0xdb:m efuse:w:0xff:m
2019-08-11 11:12:23 +02:00
AVRDUDE_PROG := -c avr910 -b 115200 -P /dev/ispprog
#AVRDUDE_PROG := -c dragon_isp -P usb
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
# ---------------------------------------------------------------------------
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
CFLAGS = -pipe -g -Os -mmcu=$(MCU) -Wall
CFLAGS += -fdata-sections -ffunction-sections
CFLAGS += -Wa,-adhlns=$(*F).lst
LDFLAGS = -Wl,-Map,$(@:.elf=.map),--cref
LDFLAGS += -Wl,--relax,--gc-sections
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
# ---------------------------------------------------------------------------
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
$(TARGET): $(TARGET).elf
@$(SIZE) -B -x --mcu=$(MCU) $<
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
$(TARGET).elf: $(SOURCE:.c=.o)
@echo " Linking file: $@"
@$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 2> /dev/null
@$(OBJDUMP) -h -S $@ > $(@:.elf=.lss)
@$(OBJCOPY) -j .text -j .data -O ihex $@ $(@:.elf=.hex)
@$(OBJCOPY) -j .text -j .data -O binary $@ $(@:.elf=.bin)
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
%.o: %.c $(MAKEFILE_LIST)
@echo " Building file: $<"
@$(CC) $(CFLAGS) -o $@ -c $<
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
clean:
rm -rf $(SOURCE:.c=.o) $(SOURCE:.c=.lst) $(addprefix $(TARGET), .elf .map .lss .hex .bin)
2017-05-25 11:15:22 +02:00
2017-05-25 11:19:25 +02:00
install: $(TARGET).elf
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U flash:w:$(<:.elf=.hex)
2017-05-25 11:15:22 +02:00
fuses:
2017-05-25 11:19:25 +02:00
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) $(patsubst %,-U %, $(AVRDUDE_FUSES))