Created
September 21, 2013 21:09
-
-
Save dagon666/6654222 to your computer and use it in GitHub Desktop.
Pure C Arduino generic Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET=blink | |
SOURCES=blink.c | |
DEPS= | |
COBJ=$(SOURCES:.c=.o) | |
CC=avr-gcc | |
OBJC=avr-objcopy | |
MCU=atmega328p | |
CFLAGS=-I. -Wall -Os -DF_CPU=16000000UL | |
LDFLAGS= | |
ISPPORT=/dev/ttyACM0 | |
ISPDIR=/usr/share/arduino/hardware/tools | |
ISP=$(ISPDIR)/avrdude | |
ISPFLAGS=-c arduino -p $(MCU) -P $(ISPPORT) -b 115200 -C $(ISPDIR)/avrdude.conf | |
all: $(TARGET) | |
%.o: %.c $(DEPS) | |
@echo -e "\tCC" $< | |
@$(CC) -mmcu=$(MCU) -c -o $@ $< $(CFLAGS) | |
$(TARGET): $(COBJ) | |
@echo -e "\tLINKING CC" $< | |
@$(CC) -mmcu=$(MCU) -o $(TARGET) $(COBJ) $(LDFLAGS) | |
$(OBJC) -O ihex -R .eeprom $(TARGET) $(TARGET).hex | |
clean: | |
@echo ========== cleanup ========== | |
rm -rf *.o *.hex $(TARGET) | |
read: | |
$(ISP) $(ISPFLAGS) -U flash:r:$(TARGET)_backup.hex:i | |
install: | |
$(ISP) $(ISPFLAGS) -U flash:w:$(TARGET).hex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment