Created
February 18, 2019 02:46
-
-
Save MatthaeusHarris/c0da1e572c7053e8562e88ff1233ee64 to your computer and use it in GitHub Desktop.
Working, hack-ish 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
PRG = binaryclock | |
MCU_TARGET = atmega328p | |
PROGRAMMER = usbtiny | |
PFLAGS = #-P /dev/ttyUSB0 | |
OPTIMIZE = -Os | |
DEFS = -DF_CPU=1000000UL | |
LIBS = | |
HEADERS = | |
CC = avr-gcc | |
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) | |
override LDFLAGS = -W1,-Map,$(PRG).map | |
OBJCOPY = avr-objcopy | |
OBJDUMP = avr-objdump | |
FLASH = avrdude | |
all: $(PRG).hex | |
$(PRG).hex: $(PRG).elf | |
$(OBJCOPY) -O ihex -R .eeprom $(PRG).elf $(PRG).hex | |
$(PRG).elf: $(PRG)_linked.o | |
$(CC) $(PRG)_linked.o -o $(PRG).elf | |
$(PRG)_linked.o: $(PRG).o twimaster.o | |
$(CC) $(CFLAGS) $(PRG).o twimaster.o -o $(PRG)_linked.o | |
$(PRG).o: $(PRG).c $(HEADERS) | |
$(CC) $(CFLAGS) -c $(PRG).c -o $(PRG).o | |
twimaster.o: twimaster.c | |
$(CC) $(CFLAGS) -c twimaster.c -o twimaster.o | |
flash: | |
$(FLASH) -c $(PROGRAMMER) $(PFLAGS) -p $(MCU_TARGET) -U flash:w:$(PRG).hex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment