Newer
Older
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
51
52
53
54
55
56
57
58
# The name of your project (used to name the compiled .hex file)
TARGET = fadecandy
# configurable options
OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH
# options needed by many Arduino libraries to configure for Teensy 3.0
OPTIONS += -D__MK20DX128__ -DARDUIO=104 -DARDUINO
# Sources
C_FILES = $(wildcard src/*.c) $(wildcard teensy3/*.c)
CPP_FILES = $(wildcard src/*.cpp) $(wildcard teensy3/*.cpp)
# Headers
INCLUDES = -Isrc -Iteensy3
# CPPFLAGS = compiler options for C and C++
CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD $(OPTIONS) $(INCLUDES)
# compiler options for C++ only
CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
# compiler options for C only
CFLAGS =
# linker script
LDSCRIPT = teensy3/mk20dx128.ld
# linker options
LDFLAGS = -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -T$(LDSCRIPT)
# additional libraries to link
LIBS = -lm
# toolchain
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
all: $(TARGET).hex
$(TARGET).elf: $(OBJS) $(LDSCRIPT)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
%.hex: %.elf
$(SIZE) $<
$(OBJCOPY) -O ihex -R .eeprom $< $@
# compiler generated dependency info
-include $(OBJS:.o=.d)
clean:
rm -f src/*.d src/*.o teensy3/*.o teensy3/*.d $(TARGET).elf $(TARGET).hex
.PHONY: clean install