Skip to content

Instantly share code, notes, and snippets.

@TRManderson TRManderson/Makefile
Created Feb 20, 2016

Embed
What would you like to do?
My AVR makefile for a uni course last year
# Name: Makefile
# Author: Tom Manderson
# Based on https://github.com/obdev/CrossPack-AVR/
DEVICE = atmega324a
CLOCK = 8000000
PROGRAMMER = -c avrispmkii
OBJECTS = project.o buttons.o game.o ledmatrix.o score.o scrolling_char_display.o serialio.o spi.o terminalio.o timer0.o
AVRDUDE = avrdude $(PROGRAMMER) -p m324pa -F
COMPILE = avr-gcc -Wall -Os -std=c99 -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
# symbolic targets:
all: project.hex
.c.o:
$(COMPILE) -c $< -o $@
.c.s:
$(COMPILE) -S $< -o $@
flash: all
$(AVRDUDE) -U flash:w:project.hex:i
clean:
rm -f project.hex project.elf $(OBJECTS)
# file targets:
project.elf: $(OBJECTS)
$(COMPILE) -o project.elf $(OBJECTS)
project.hex: project.elf
rm -f project.hex
avr-objcopy -j .text -j .data -O ihex project.elf project.hex
avr-size --format=avr --mcu=$(DEVICE) project.elf
disasm: project.elf
avr-objdump -d project.elf
cpp:
$(COMPILE) -E project.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.