update Makefile
This commit is contained in:
parent
9e69670da0
commit
5e460cb33f
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,4 +3,5 @@
|
|||||||
*.bin
|
*.bin
|
||||||
*.hex
|
*.hex
|
||||||
*.lst
|
*.lst
|
||||||
|
*.lss
|
||||||
*.map
|
*.map
|
||||||
|
78
Makefile
78
Makefile
@ -1,56 +1,48 @@
|
|||||||
PRG = epromsim
|
CC := avr-gcc
|
||||||
OBJ = main.o
|
LD := avr-ld
|
||||||
MCU_TARGET = attiny2313
|
OBJCOPY := avr-objcopy
|
||||||
OPTIMIZE = -Os
|
OBJDUMP := avr-objdump
|
||||||
|
SIZE := avr-size
|
||||||
|
|
||||||
#AVRDUDE_PROG = -c avr910 -b 115200 -P /dev/ispprog
|
TARGET = epromsim
|
||||||
AVRDUDE_PROG = -c dragon_isp -P usb
|
SOURCE = $(wildcard *.c)
|
||||||
AVRDUDE_MCU = attiny2313
|
|
||||||
|
|
||||||
DEFS =
|
MCU=attiny2313
|
||||||
LIBS =
|
AVRDUDE_MCU=attiny2313
|
||||||
|
|
||||||
# Override is only needed by avr-lib build system.
|
AVRDUDE_FUSES=lfuse:w:0xff:m hfuse:w:0xdb:m efuse:w:0xff:m
|
||||||
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
|
#AVRDUDE_PROG := -c avr910 -b 115200 -P /dev/ispprog
|
||||||
override LDFLAGS = -Wl,-Map,$(PRG).map
|
AVRDUDE_PROG := -c dragon_isp -P usb
|
||||||
|
|
||||||
CC = avr-gcc
|
# ---------------------------------------------------------------------------
|
||||||
OBJCOPY = avr-objcopy
|
|
||||||
OBJDUMP = avr-objdump
|
|
||||||
SIZE = avr-size
|
|
||||||
|
|
||||||
all: $(PRG).elf lst text
|
CFLAGS = -pipe -g -Os -mmcu=$(MCU) -Wall
|
||||||
$(SIZE) -x -A $(PRG).elf
|
CFLAGS += -fdata-sections -ffunction-sections
|
||||||
|
CFLAGS += -Wa,-adhlns=$(*F).lst
|
||||||
|
LDFLAGS = -Wl,-Map,$(@:.elf=.map),--cref
|
||||||
|
LDFLAGS += -Wl,--relax,--gc-sections
|
||||||
|
|
||||||
$(PRG).elf: $(OBJ)
|
# ---------------------------------------------------------------------------
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
|
||||||
|
$(TARGET): $(TARGET).elf
|
||||||
|
@$(SIZE) -B -x --mcu=$(MCU) $<
|
||||||
|
|
||||||
|
$(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)
|
||||||
|
|
||||||
%.o: %.c $(MAKEFILE_LIST)
|
%.o: %.c $(MAKEFILE_LIST)
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
@echo " Building file: $<"
|
||||||
|
@$(CC) $(CFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o $(PRG).lst $(PRG).map $(PRG).elf $(PRG).hex $(PRG).bin
|
rm -rf $(SOURCE:.c=.o) $(SOURCE:.c=.lst) $(addprefix $(TARGET), .elf .map .lss .hex .bin)
|
||||||
|
|
||||||
lst: $(PRG).lst
|
install: $(TARGET).elf
|
||||||
|
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U flash:w:$(<:.elf=.hex)
|
||||||
%.lst: %.elf
|
|
||||||
$(OBJDUMP) -h -S $< > $@
|
|
||||||
|
|
||||||
text: hex bin
|
|
||||||
|
|
||||||
hex: $(PRG).hex
|
|
||||||
bin: $(PRG).bin
|
|
||||||
|
|
||||||
%.hex: %.elf
|
|
||||||
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
|
||||||
|
|
||||||
%.bin: %.elf
|
|
||||||
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
|
||||||
|
|
||||||
install: text
|
|
||||||
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -V -U flash:w:$(PRG).hex
|
|
||||||
|
|
||||||
fuses:
|
fuses:
|
||||||
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U efuse:w:0xff:m
|
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) $(patsubst %,-U %, $(AVRDUDE_FUSES))
|
||||||
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U hfuse:w:0xdb:m
|
|
||||||
avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U lfuse:w:0xff:m
|
|
||||||
|
Loading…
Reference in New Issue
Block a user