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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Teensyduino Core Library
  2. # http://www.pjrc.com/teensy/
  3. # Copyright (c) 2017 PJRC.COM, LLC.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining
  6. # a copy of this software and associated documentation files (the
  7. # "Software"), to deal in the Software without restriction, including
  8. # without limitation the rights to use, copy, modify, merge, publish,
  9. # distribute, sublicense, and/or sell copies of the Software, and to
  10. # permit persons to whom the Software is furnished to do so, subject to
  11. # the following conditions:
  12. #
  13. # 1. The above copyright notice and this permission notice shall be
  14. # included in all copies or substantial portions of the Software.
  15. #
  16. # 2. If the Software is incorporated into a build system that allows
  17. # selection among a list of target devices, then similar target
  18. # devices manufactured by PJRC.COM must be included in the list of
  19. # target devices and selectable in the same manner.
  20. #
  21. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  25. # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26. # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. # SOFTWARE.
  29. # set your MCU type here, or make command line `make MCU=MK20DX256`
  30. MCU=MK20DX256
  31. # make it lower case
  32. 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)))))))))))))))))))))))))))
  33. MCU_LD = $(LOWER_MCU).ld
  34. # The name of your project (used to name the compiled .hex file)
  35. TARGET = main
  36. # Those that specify a NO_ARDUINO environment variable will
  37. # be able to use this Makefile with no Arduino dependency.
  38. # Please note that if ARDUINOPATH was set, it will override
  39. # the NO_ARDUINO behaviour.
  40. ifndef NO_ARDUINO
  41. # Path to your arduino installation
  42. ARDUINOPATH ?= ../../../../..
  43. #ARDUINOPATH ?= ../../../..
  44. endif
  45. # configurable options
  46. OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE
  47. # options needed by many Arduino libraries to configure for Teensy 3.0
  48. OPTIONS += -D__$(MCU)__ -DARDUINO=10613 -DTEENSYDUINO=132
  49. # Other Makefiles and project templates for Teensy 3.x:
  50. #
  51. # https://github.com/apmorton/teensy-template
  52. # https://github.com/xxxajk/Arduino_Makefile_master
  53. # https://github.com/JonHylands/uCee
  54. #************************************************************************
  55. # Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
  56. # To use this makefile without Arduino, copy the resources from these
  57. # locations and edit the pathnames. The rest of Arduino is not needed.
  58. #************************************************************************
  59. ifdef ARDUINOPATH
  60. # path location for Teensy Loader, teensy_post_compile and teensy_reboot (on Linux)
  61. TOOLSPATH = $(abspath $(ARDUINOPATH)/hardware/tools)
  62. # path location for Arduino libraries (currently not used)
  63. LIBRARYPATH = $(abspath $(ARDUINOPATH)/libraries)
  64. # path location for the arm-none-eabi compiler
  65. COMPILERPATH = $(abspath $(ARDUINOPATH)/hardware/tools/arm/bin)
  66. else
  67. # Default to the normal GNU/Linux compiler path if NO_ARDUINO
  68. # and ARDUINOPATH was not set.
  69. COMPILERPATH ?= /usr/bin
  70. endif
  71. #************************************************************************
  72. # Settings below this point usually do not need to be edited
  73. #************************************************************************
  74. # CPPFLAGS = compiler options for C and C++
  75. CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -MMD $(OPTIONS) -I.
  76. # compiler options for C++ only
  77. CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
  78. # compiler options for C only
  79. CFLAGS =
  80. # linker options
  81. LDFLAGS = -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(MCU_LD)
  82. # additional libraries to link
  83. LIBS = -lm
  84. # names for the compiler programs
  85. CC = $(COMPILERPATH)/arm-none-eabi-gcc
  86. CXX = $(COMPILERPATH)/arm-none-eabi-g++
  87. OBJCOPY = $(COMPILERPATH)/arm-none-eabi-objcopy
  88. SIZE = $(COMPILERPATH)/arm-none-eabi-size
  89. # automatically create lists of the sources and objects
  90. # TODO: this does not handle Arduino libraries yet...
  91. C_FILES := $(wildcard *.c)
  92. CPP_FILES := $(wildcard *.cpp)
  93. OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
  94. # the actual makefile rules (all .o files built by GNU make's default implicit rules)
  95. all: $(TARGET).hex
  96. $(TARGET).elf: $(OBJS) $(MCU_LD)
  97. $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  98. %.hex: %.elf
  99. $(SIZE) $<
  100. $(OBJCOPY) -O ihex -R .eeprom $< $@
  101. ifneq (,$(wildcard $(TOOLSPATH)))
  102. $(TOOLSPATH)/teensy_post_compile -file=$(basename $@) -path=$(shell pwd) -tools=$(TOOLSPATH)
  103. -$(TOOLSPATH)/teensy_reboot
  104. endif
  105. # compiler generated dependency info
  106. -include $(OBJS:.o=.d)
  107. clean:
  108. rm -f *.o *.d $(TARGET).elf $(TARGET).hex