pentabug/fw_test/Makefile

76 lines
2.1 KiB
Makefile
Raw Normal View History

2012-10-01 05:15:13 +02:00
PROJECT=pentabug
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
OPTIMIZATION = -Os
MCU = atmega88pa
2012-09-20 20:55:19 +02:00
F_CPU = 8000000
QUARZ = 8MHZ
2012-10-01 05:15:13 +02:00
FUSES = lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0x01:m
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
#########################################################################
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
SRC=$(wildcard lib/*.c *.c)
OBJECTS= $(SRC:.c=.o)
LSTFILES= $(SRC:.c=.lst)
HEADERS=$(wildcard lib/*.h *.h)
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
# Compiler Options
GCFLAGS = -ffreestanding -std=gnu99 -mmcu=$(MCU) $(OPTIMIZATION) -Wl,-gc-sections -nostdlib -I.
# Warnings
GCFLAGS += -Wstrict-prototypes -Wundef -Wall -Wextra -Wunreachable-code
# Optimizazions
GCFLAGS += -fsingle-precision-constant -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -fno-builtin -ffunction-sections -fno-common -fdata-sections
# Debug stuff
GCFLAGS += -Wa,-adhlns=$(<:.c=.lst),-gstabs -g
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
GCFLAGS += -DF_CPU=$(F_CPU) -DQUARZ=$(QUARZ)
2012-09-20 20:55:19 +02:00
LDFLAGS = -mmcu=$(MCU) $(OPTIMIZATION) -gc-sections
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
# Paths
GCC = avr-gcc
2012-09-20 20:55:19 +02:00
OBJCOPY = avr-objcopy
2012-10-01 05:15:13 +02:00
REMOVE = rm -f
2012-09-20 20:55:19 +02:00
SIZE = avr-size
AVRDUDE = avrdude
2012-10-01 05:15:13 +02:00
#########################################################################
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
all: $(PROJECT).hex Makefile
@$(SIZE) --mcu=$(MCU) --format=avr $(PROJECT).elf
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
$(PROJECT).hex: $(PROJECT).elf Makefile
@echo " \033[1;34mOBJCOPY\033[0m $(PROJECT).elf -> $(PROJECT).hex"
@$(OBJCOPY) -O ihex -R .eeprom $(PROJECT).elf $(PROJECT).hex
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
$(PROJECT).elf: $(OBJECTS) Makefile
@echo " \033[1;34mLink \033[0m (\033[1;33m $(OBJECTS)\033[0m) -> $(PROJECT).elf"
@$(GCC) $(OBJECTS) $(LDFLAGS) -o $(PROJECT).elf
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
clean:
$(REMOVE) $(OBJECTS)
$(REMOVE) $(LSTFILES)
$(REMOVE) $(PROJECT).hex
$(REMOVE) $(PROJECT).elf
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
#########################################################################
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
%.o: %.c Makefile $(HEADERS)
@echo " \033[1;34mCompile\033[0m $<"
@$(GCC) $(GCFLAGS) -o $@ -c $<
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
#########################################################################
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
fuse:
$(AVRDUDE) -p m88 -F -c usbtiny -v -v -U $(FUSES)
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
flash: $(PROJECT).hex Makefile
$(AVRDUDE) -p m88 -F -c usbtiny -v -v -U flash:w:$(PROJECT).hex
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
fljohn: $(PROJECT).hex Makefile
$(AVRDUDE) -p m88 -F -P /dev/serial/by-id/usb-FTDI_USB__-__Serial-if00-port0 -c stk500v2 -v -v -U flash:w:$(PROJECT).hex
2012-09-20 20:55:19 +02:00
2012-10-01 05:15:13 +02:00
.PHONY : clean all fuse flash fljohn
2012-09-20 20:55:19 +02:00