-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·50 lines (40 loc) · 1.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CC = avr-gcc
OBJCOPY = avr-objcopy
CFLAGS += -std=gnu99 -O2 -Wall -Werror
BUILD_DEPS = src/uart.o \
src/gsm.o \
src/io.o \
src/morse.o \
src/timer.o \
src/ringbuf.o \
src/power.o \
src/main.o
ifeq ($(filter debug,$(MAKECMDGOALS)),debug)
CFLAGS += -DDEBUG -g
# Add 'd' to .o files in case of debug build
DEBUGEXT = d
BUILD_DEPS := $(subst .o,$(DEBUGEXT).o,$(BUILD_DEPS))
endif
all: src/steep_beta$(DEBUGEXT).hex
debug: all
.INTERMEDIATE: src/version.h
src/version.h:
echo "#define STEEP_BETA_COMMIT \"$(shell git rev-parse --short HEAD || echo unknown commit)\"" > $@
echo "#define STEEP_BETA_VERSION \"1.1.0\"" >> $@
echo "#define STEEP_BETA_BUILDDATE \"$(shell date -I || echo unknown build date)\"" >> $@
src/%$(DEBUGEXT).o: src/%.c src/version.h
$(CC) -mmcu=atmega2560 $(CFLAGS) -c $< -o $@
src/steep_beta$(DEBUGEXT).a: $(BUILD_DEPS)
$(CC) -Wall -Werror -Wl,-u,vfprintf -lprintf_flt -lm -mmcu=atmega2560 -o $@ $^
src/steep_beta$(DEBUGEXT).hex: src/steep_beta$(DEBUGEXT).a
$(OBJCOPY) -O ihex -R .eeprom $< $@
.PHONY: flash
flash: src/steep_beta$(DEBUGEXT).hex
ifndef DEVNAME
$(warning DEVNAME is not set. Assuming target on /dev/ttyUSB0.)
$(eval DEVNAME=/dev/ttyUSB0)
endif
avrdude -q -q -F -V -patmega2560 -cwiring -P$(DEVNAME) -b115200 -D -Uflash:w:$<
.PHONY: clean
clean:
rm -rf src/*.a src/*.hex src/*.o src/version.h