Skip to content

Instantly share code, notes, and snippets.

@zeroflow
Created September 7, 2018 22:12
Show Gist options
  • Save zeroflow/6219e619460c91be71e2d7d9a9a46e53 to your computer and use it in GitHub Desktop.
Save zeroflow/6219e619460c91be71e2d7d9a9a46e53 to your computer and use it in GitHub Desktop.
Anduril Makefile
TARGETS = BLF_GT_MINI \
BLF_GT \
BLF_Q8 \
EMISAR_D1 \
EMISAR_D1S \
EMISAR_D4 \
EMISAR_D4S \
EMISAR_D4S_219c \
FF_ROT66 \
FW3A \
H03_TA
ATTINY = 85
PROJECT = anduril
HW = EMISAR_D4S
CC = avr-gcc
CFLAGS = -Wall -g -Os -mmcu=attiny$(ATTINY) -c -std=gnu99 -DATTINY=$(ATTINY) -I.. -I../.. -fshort-enums
OFLAGS = -Wall -g -Os -mmcu=attiny$(ATTINY)
OBJCOPY = avr-objcopy
OBJCOPYFLAGS = --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex
# cfg-*.h in own folder
DEPS = $(wildcard *.c) $(wildcard *.h)
# files in spaghetti-monster folder (fsm-*)
DEPS += $(wildcard ../*.c) $(wildcard ../*.h)
# files in ToyKeeper folder (hwdef-*.h, tk-attiny.h, ...)
DEPS += $(wildcard ../../*.c) $(wildcard ../../*.h)
.PHONY: all clean binaries release flash
all : binaries
clean :
rm -f $(patsubst %, $(PROJECT).latest.%.hex, $(TARGETS))
binaries : $(patsubst %, $(PROJECT).latest.%.hex, $(TARGETS))
release : $(patsubst %, $(PROJECT).$(shell date "+%y-%m-%d").%.hex, $(TARGETS))
@mkdir -p releases
@mv $^ releases
flash : $(PROJECT).latest.$(HW).hex
avrdude avrdude.exe -p attiny$(ATTINY) -c arduino -P /dev/ttyS6 -Uflash:w:$^:a
%.o :
$(CC) $(CFLAGS) -DFSM_$(word 3, $(subst ., ,$@) )_DRIVER -o $@ -c $(PROJECT).c
%.elf : %.o
$(CC) $(OFLAGS) $(LDFLAGS) -o $@ $<
%.hex : %.elf $(DEPS) Makefile
$(OBJCOPY) $(OBJCOPYFLAGS) $< $@
@avr-size -C --mcu=attiny$(ATTINY) $< | grep Full
@rm $(patsubst %.hex, %.elf, $@) $(patsubst %.hex, %.o, $@)
@echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment