Teensy 4.1 core updated for C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.3KB

  1. # set your MCU type here, or make command line `make MCU=MK20DX256`
  2. MCU=MK20DX256
  3. # make it lower case
  4. LOWER_MCU := $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$(MCU)))))))))))))))))))))))))))
  5. MCU_LD = $(LOWER_MCU).ld
  6. # The name of your project (used to name the compiled .hex file)
  7. TARGET = main
  8. # Path to your arduino installation
  9. ARDUINOPATH ?= ../../../../..
  10. #ARDUINOPATH ?= ../../../..
  11. # configurable options
  12. OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE
  13. # options needed by many Arduino libraries to configure for Teensy 3.0
  14. OPTIONS += -D__$(MCU)__ -DARDUINO=10600 -DTEENSYDUINO=121
  15. # Other Makefiles and project templates for Teensy 3.x:
  16. #
  17. # https://github.com/apmorton/teensy-template
  18. # https://github.com/xxxajk/Arduino_Makefile_master
  19. # https://github.com/JonHylands/uCee
  20. #************************************************************************
  21. # Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
  22. # To use this makefile without Arduino, copy the resources from these
  23. # locations and edit the pathnames. The rest of Arduino is not needed.
  24. #************************************************************************
  25. # path location for Teensy Loader, teensy_post_compile and teensy_reboot
  26. TOOLSPATH = $(ARDUINOPATH)/hardware/tools # on Linux
  27. # path location for Arduino libraries (currently not used)
  28. LIBRARYPATH = $(ARDUINOPATH)/libraries
  29. # path location for the arm-none-eabi compiler
  30. COMPILERPATH = $(ARDUINOPATH)/hardware/tools/arm/bin
  31. #************************************************************************
  32. # Settings below this point usually do not need to be edited
  33. #************************************************************************
  34. # CPPFLAGS = compiler options for C and C++
  35. CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -MMD $(OPTIONS) -I.
  36. # compiler options for C++ only
  37. CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
  38. # compiler options for C only
  39. CFLAGS =
  40. # linker options
  41. LDFLAGS = -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(MCU_LD)
  42. # additional libraries to link
  43. LIBS = -lm
  44. # names for the compiler programs
  45. CC = $(abspath $(COMPILERPATH))/arm-none-eabi-gcc
  46. CXX = $(abspath $(COMPILERPATH))/arm-none-eabi-g++
  47. OBJCOPY = $(abspath $(COMPILERPATH))/arm-none-eabi-objcopy
  48. SIZE = $(abspath $(COMPILERPATH))/arm-none-eabi-size
  49. # automatically create lists of the sources and objects
  50. # TODO: this does not handle Arduino libraries yet...
  51. C_FILES := $(wildcard *.c)
  52. CPP_FILES := $(wildcard *.cpp)
  53. OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
  54. # the actual makefile rules (all .o files built by GNU make's default implicit rules)
  55. all: $(TARGET).hex
  56. $(TARGET).elf: $(OBJS) $(MCU_LD)
  57. $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  58. %.hex: %.elf
  59. $(SIZE) $<
  60. $(OBJCOPY) -O ihex -R .eeprom $< $@
  61. $(abspath $(TOOLSPATH))/teensy_post_compile -file=$(basename $@) -path=$(shell pwd) -tools=$(abspath $(TOOLSPATH))
  62. -$(abspath $(TOOLSPATH))/teensy_reboot
  63. # compiler generated dependency info
  64. -include $(OBJS:.o=.d)
  65. clean:
  66. rm -f *.o *.d $(TARGET).elf $(TARGET).hex