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.

112 satır
3.7KB

  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. # Those that specify a NO_ARDUINO environment variable will
  9. # be able to use this Makefile with no Arduino dependency.
  10. # Please note that if ARDUINOPATH was set, it will override
  11. # the NO_ARDUINO behaviour.
  12. ifndef NO_ARDUINO
  13. # Path to your arduino installation
  14. ARDUINOPATH ?= ../../../../..
  15. #ARDUINOPATH ?= ../../../..
  16. endif
  17. # configurable options
  18. OPTIONS = -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE
  19. # options needed by many Arduino libraries to configure for Teensy 3.0
  20. OPTIONS += -D__$(MCU)__ -DARDUINO=10613 -DTEENSYDUINO=132
  21. # Other Makefiles and project templates for Teensy 3.x:
  22. #
  23. # https://github.com/apmorton/teensy-template
  24. # https://github.com/xxxajk/Arduino_Makefile_master
  25. # https://github.com/JonHylands/uCee
  26. #************************************************************************
  27. # Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
  28. # To use this makefile without Arduino, copy the resources from these
  29. # locations and edit the pathnames. The rest of Arduino is not needed.
  30. #************************************************************************
  31. ifdef ARDUINOPATH
  32. # path location for Teensy Loader, teensy_post_compile and teensy_reboot (on Linux)
  33. TOOLSPATH = $(abspath $(ARDUINOPATH)/hardware/tools)
  34. # path location for Arduino libraries (currently not used)
  35. LIBRARYPATH = $(abspath $(ARDUINOPATH)/libraries)
  36. # path location for the arm-none-eabi compiler
  37. COMPILERPATH = $(abspath $(ARDUINOPATH)/hardware/tools/arm/bin)
  38. else
  39. # Default to the normal GNU/Linux compiler path if NO_ARDUINO
  40. # and ARDUINOPATH was not set.
  41. COMPILERPATH ?= /usr/bin
  42. endif
  43. #************************************************************************
  44. # Settings below this point usually do not need to be edited
  45. #************************************************************************
  46. # CPPFLAGS = compiler options for C and C++
  47. CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -MMD $(OPTIONS) -I.
  48. # compiler options for C++ only
  49. CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
  50. # compiler options for C only
  51. CFLAGS =
  52. # linker options
  53. LDFLAGS = -Os -Wl,--gc-sections,--defsym=__rtc_localtime=0 --specs=nano.specs -mcpu=cortex-m4 -mthumb -T$(MCU_LD)
  54. # additional libraries to link
  55. LIBS = -lm
  56. # names for the compiler programs
  57. CC = $(COMPILERPATH)/arm-none-eabi-gcc
  58. CXX = $(COMPILERPATH)/arm-none-eabi-g++
  59. OBJCOPY = $(COMPILERPATH)/arm-none-eabi-objcopy
  60. SIZE = $(COMPILERPATH)/arm-none-eabi-size
  61. # automatically create lists of the sources and objects
  62. # TODO: this does not handle Arduino libraries yet...
  63. C_FILES := $(wildcard *.c)
  64. CPP_FILES := $(wildcard *.cpp)
  65. OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)
  66. # the actual makefile rules (all .o files built by GNU make's default implicit rules)
  67. all: $(TARGET).hex
  68. $(TARGET).elf: $(OBJS) $(MCU_LD)
  69. $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  70. %.hex: %.elf
  71. $(SIZE) $<
  72. $(OBJCOPY) -O ihex -R .eeprom $< $@
  73. ifneq (,$(wildcard $(TOOLSPATH)))
  74. $(TOOLSPATH)/teensy_post_compile -file=$(basename $@) -path=$(shell pwd) -tools=$(TOOLSPATH)
  75. -$(TOOLSPATH)/teensy_reboot
  76. endif
  77. # compiler generated dependency info
  78. -include $(OBJS:.o=.d)
  79. clean:
  80. rm -f *.o *.d $(TARGET).elf $(TARGET).hex