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.

Makefile 5.2KB

9 vuotta sitten
9 vuotta sitten
6 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #MCU=MKL26Z64
  32. #MCU=MK64FX512
  33. #MCU=MK66FX1M0
  34. # make it lower case
  35. 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)))))))))))))))))))))))))))
  36. MCU_LD = $(LOWER_MCU).ld
  37. # The name of your project (used to name the compiled .hex file)
  38. TARGET = main
  39. # Those that specify a NO_ARDUINO environment variable will
  40. # be able to use this Makefile with no Arduino dependency.
  41. # Please note that if ARDUINOPATH was set, it will override
  42. # the NO_ARDUINO behaviour.
  43. ifndef NO_ARDUINO
  44. # Path to your arduino installation
  45. ARDUINOPATH ?= ../../../../..
  46. endif
  47. # configurable options
  48. OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE
  49. # options needed by many Arduino libraries to configure for Teensy 3.x
  50. OPTIONS += -D__$(MCU)__ -DARDUINO=10805 -DTEENSYDUINO=144
  51. # use "cortex-m4" for Teensy 3.x
  52. # use "cortex-m0plus" for Teensy LC
  53. CPUARCH = cortex-m4
  54. #CPUARCH = cortex-m0plus
  55. # Other Makefiles and project templates for Teensy 3.x:
  56. #
  57. # https://github.com/apmorton/teensy-template
  58. # https://github.com/xxxajk/Arduino_Makefile_master
  59. # https://github.com/JonHylands/uCee
  60. #************************************************************************
  61. # Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
  62. # To use this makefile without Arduino, copy the resources from these
  63. # locations and edit the pathnames. The rest of Arduino is not needed.
  64. #************************************************************************
  65. ifdef ARDUINOPATH
  66. # path location for Teensy Loader, teensy_post_compile and teensy_reboot (on Linux)
  67. TOOLSPATH = $(abspath $(ARDUINOPATH)/hardware/tools)
  68. # path location for Arduino libraries (currently not used)
  69. LIBRARYPATH = $(abspath $(ARDUINOPATH)/libraries)
  70. # path location for the arm-none-eabi compiler
  71. COMPILERPATH = $(abspath $(ARDUINOPATH)/hardware/tools/arm/bin)
  72. else
  73. # Default to the normal GNU/Linux compiler path if NO_ARDUINO
  74. # and ARDUINOPATH was not set.
  75. COMPILERPATH ?= /usr/bin
  76. endif
  77. #************************************************************************
  78. # Settings below this point usually do not need to be edited
  79. #************************************************************************
  80. # CPPFLAGS = compiler options for C and C++
  81. CPPFLAGS = -Wall -g -Os -mcpu=$(CPUARCH) -mthumb -MMD $(OPTIONS) -I.
  82. # compiler options for C++ only
  83. CXXFLAGS = -std=gnu++14 -felide-constructors -fno-exceptions -fno-rtti
  84. # compiler options for C only
  85. CFLAGS =
  86. # linker options
  87. LDFLAGS = -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=$(CPUARCH) -mthumb -T$(MCU_LD)
  88. # additional libraries to link
  89. LIBS = -lm
  90. # names for the compiler programs
  91. CC = $(COMPILERPATH)/arm-none-eabi-gcc
  92. CXX = $(COMPILERPATH)/arm-none-eabi-g++
  93. OBJCOPY = $(COMPILERPATH)/arm-none-eabi-objcopy
  94. SIZE = $(COMPILERPATH)/arm-none-eabi-size
  95. # automatically create lists of the sources and objects
  96. # TODO: this does not handle Arduino libraries yet...
  97. C_FILES := $(wildcard *.c)
  98. CPP_FILES := $(wildcard *.cpp)
  99. OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
  100. # the actual makefile rules (all .o files built by GNU make's default implicit rules)
  101. all: $(TARGET).hex
  102. $(TARGET).elf: $(OBJS) $(MCU_LD)
  103. $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  104. %.hex: %.elf
  105. $(SIZE) $<
  106. $(OBJCOPY) -O ihex -R .eeprom $< $@
  107. ifneq (,$(wildcard $(TOOLSPATH)))
  108. $(TOOLSPATH)/teensy_post_compile -file=$(basename $@) -path=$(shell pwd) -tools=$(TOOLSPATH)
  109. -$(TOOLSPATH)/teensy_reboot
  110. endif
  111. # compiler generated dependency info
  112. -include $(OBJS:.o=.d)
  113. clean:
  114. rm -f *.o *.d $(TARGET).elf $(TARGET).hex