Skip to content
Snippets Groups Projects
Makefile 1.87 KiB
Newer Older
  • Learn to ignore specific revisions
  • #######################################################
    # Environment setup
    
    # Teensy loader tools (for 'make install')
    TOOLSPATH = /Applications/Arduino.app/Contents/Resources/Java/hardware/tools
    
    # toolchain
    CC = arm-none-eabi-gcc
    CXX = arm-none-eabi-g++
    OBJCOPY = arm-none-eabi-objcopy
    OBJDUMP = arm-none-eabi-objdump
    SIZE = arm-none-eabi-size
    
    #######################################################
    
    
    # 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
    
    OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
    
    all: $(TARGET).hex
    
    $(TARGET).elf: $(OBJS) $(LDSCRIPT)
    
    	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
    
    
    %.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
    
    
    install: $(TARGET).hex
    	$(abspath $(TOOLSPATH))/teensy_post_compile -file=$(TARGET) -path=$(shell pwd) -tools=$(abspath $(TOOLSPATH))
    	$(abspath $(TOOLSPATH))/teensy_reboot
    
    objdump: $(TARGET).elf
    	$(OBJDUMP) -d $<
    
    .PHONY: clean install objdump