My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Makefile 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. # Sprinter Arduino Project Makefile
  2. #
  3. # Makefile Based on:
  4. # Arduino 0011 Makefile
  5. # Arduino adaptation by mellis, eighthave, oli.keller
  6. # Marlin adaption by Daid
  7. #
  8. # This has been tested with Arduino 0022.
  9. #
  10. # This makefile allows you to build sketches from the command line
  11. # without the Arduino environment (or Java).
  12. #
  13. # Detailed instructions for using the makefile:
  14. #
  15. # 1. Modify the line containg "ARDUINO_INSTALL_DIR" to point to the directory that
  16. # contains the Arduino installation (for example, under Mac OS X, this
  17. # might be /Applications/arduino-0012).
  18. #
  19. # 2. Modify the line containing "UPLOAD_PORT" to refer to the filename
  20. # representing the USB or serial connection to your Arduino board
  21. # (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
  22. # changes, you can use * as a wildcard (e.g. UPLOAD_PORT = /dev/tty.usb*).
  23. #
  24. # 3. Set the line containing "MCU" to match your board's processor.
  25. # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
  26. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  27. # change F_CPU to 8000000. If you are using Gen7 electronics, you
  28. # probably need to use 20000000. Either way, you must regenerate
  29. # the speed lookup table with create_speed_lookuptable.py.
  30. #
  31. # 4. Type "make" and press enter to compile/verify your program.
  32. #
  33. # 5. Type "make upload", reset your Arduino board, and press enter to
  34. # upload your program to the Arduino board.
  35. #
  36. # Note that all settings are set with ?=, this means you can override them
  37. # from the commandline with "make HARDWARE_MOTHERBOARD=71" for example
  38. # This defined the board you are compiling for (see Configuration.h for the options)
  39. HARDWARE_MOTHERBOARD ?= 11
  40. # Arduino source install directory, and version number
  41. ARDUINO_INSTALL_DIR ?= ../../arduino-0022
  42. ARDUINO_VERSION ?= 22
  43. # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
  44. AVR_TOOLS_PATH ?=
  45. #Programmer configuration
  46. UPLOAD_RATE ?= 115200
  47. AVRDUDE_PROGRAMMER ?= arduino
  48. UPLOAD_PORT ?= /dev/arduino
  49. #Directory used to build files in, contains all the build files, from object files to the final hex file.
  50. BUILD_DIR ?= applet
  51. ############################################################################
  52. # Below here nothing should be changed...
  53. # Here the Arduino variant is selected by the board type
  54. # HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
  55. # MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
  56. #Gen7
  57. ifeq ($(HARDWARE_MOTHERBOARD),10)
  58. HARDWARE_VARIANT ?= Gen7
  59. MCU ?= atmega644
  60. F_CPU ?= 20000000
  61. else ifeq ($(HARDWARE_MOTHERBOARD),11)
  62. HARDWARE_VARIANT ?= Gen7
  63. MCU ?= atmega644p
  64. F_CPU ?= 20000000
  65. else ifeq ($(HARDWARE_MOTHERBOARD),12)
  66. HARDWARE_VARIANT ?= Gen7
  67. MCU ?= atmega644p
  68. F_CPU ?= 20000000
  69. else ifeq ($(HARDWARE_MOTHERBOARD),13)
  70. HARDWARE_VARIANT ?= Gen7
  71. MCU ?= atmega1284p
  72. F_CPU ?= 20000000
  73. #RAMPS
  74. else ifeq ($(HARDWARE_MOTHERBOARD),3)
  75. HARDWARE_VARIANT ?= arduino
  76. MCU ?= atmega2560
  77. else ifeq ($(HARDWARE_MOTHERBOARD),33)
  78. HARDWARE_VARIANT ?= arduino
  79. MCU ?= atmega2560
  80. else ifeq ($(HARDWARE_MOTHERBOARD),34)
  81. HARDWARE_VARIANT ?= arduino
  82. MCU ?= atmega2560
  83. #Duemilanove w/ ATMega328P pin assignment
  84. else ifeq ($(HARDWARE_MOTHERBOARD),4)
  85. HARDWARE_VARIANT ?= arduino
  86. HARDWARE_SUB_VARIANT ?= standard
  87. MCU ?= atmega328p
  88. #Gen6
  89. else ifeq ($(HARDWARE_MOTHERBOARD),5)
  90. HARDWARE_VARIANT ?= Gen6
  91. MCU ?= atmega644p
  92. else ifeq ($(HARDWARE_MOTHERBOARD),51)
  93. HARDWARE_VARIANT ?= Gen6
  94. MCU ?= atmega644p
  95. #Sanguinololu
  96. else ifeq ($(HARDWARE_MOTHERBOARD),6)
  97. HARDWARE_VARIANT ?= Sanguino
  98. MCU ?= atmega644p
  99. else ifeq ($(HARDWARE_MOTHERBOARD),62)
  100. HARDWARE_VARIANT ?= Sanguino
  101. MCU ?= atmega644p
  102. else ifeq ($(HARDWARE_MOTHERBOARD),63)
  103. HARDWARE_VARIANT ?= Sanguino
  104. MCU ?= atmega644p
  105. else ifeq ($(HARDWARE_MOTHERBOARD),65)
  106. HARDWARE_VARIANT ?= Sanguino
  107. MCU ?= atmega1284p
  108. else ifeq ($(HARDWARE_MOTHERBOARD),66)
  109. HARDWARE_VARIANT ?= Sanguino
  110. MCU ?= atmega1284p
  111. #Ultimaker
  112. else ifeq ($(HARDWARE_MOTHERBOARD),7)
  113. HARDWARE_VARIANT ?= arduino
  114. MCU ?= atmega2560
  115. else ifeq ($(HARDWARE_MOTHERBOARD),71)
  116. HARDWARE_VARIANT ?= arduino
  117. MCU ?= atmega1280
  118. #Teensylu
  119. else ifeq ($(HARDWARE_MOTHERBOARD),8)
  120. HARDWARE_VARIANT ?= Teensy
  121. MCU ?= at90usb1286
  122. else ifeq ($(HARDWARE_MOTHERBOARD),81)
  123. HARDWARE_VARIANT ?= Teensy
  124. MCU ?= at90usb1286
  125. else ifeq ($(HARDWARE_MOTHERBOARD),82)
  126. HARDWARE_VARIANT ?= Teensy
  127. MCU ?= at90usb646
  128. #Gen3+
  129. else ifeq ($(HARDWARE_MOTHERBOARD),9)
  130. HARDWARE_VARIANT ?= Sanguino
  131. MCU ?= atmega644p
  132. #Megatronics
  133. else ifeq ($(HARDWARE_MOTHERBOARD),70)
  134. HARDWARE_VARIANT ?= arduino
  135. MCU ?= atmega2560
  136. #Alpha OMCA board
  137. else ifeq ($(HARDWARE_MOTHERBOARD),90)
  138. HARDWARE_VARIANT ?= SanguinoA
  139. MCU ?= atmega644
  140. #Final OMCA board
  141. else ifeq ($(HARDWARE_MOTHERBOARD),91)
  142. HARDWARE_VARIANT ?= Sanguino
  143. MCU ?= atmega644p
  144. #Rambo
  145. else ifeq ($(HARDWARE_MOTHERBOARD),301)
  146. HARDWARE_VARIANT ?= arduino
  147. MCU ?= atmega2560
  148. endif
  149. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  150. # if you are setting this to something other than 16MHz
  151. # Set to 16Mhz if not yet set.
  152. F_CPU ?= 16000000
  153. # Arduino containd the main source code for the Arduino
  154. # Libraries, the "hardware variant" are for boards
  155. # that derives from that, and their source are present in
  156. # the main Marlin source directory
  157. ifeq ($(HARDWARE_VARIANT), arduino)
  158. HARDWARE_DIR = $(ARDUINO_INSTALL_DIR)/hardware
  159. else
  160. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  161. HARDWARE_DIR = ../ArduinoAddons/Arduino_1.x.x
  162. else
  163. HARDWARE_DIR = ../ArduinoAddons/Arduino_0.xx
  164. endif
  165. endif
  166. HARDWARE_SRC = $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/cores/arduino
  167. TARGET = $(notdir $(CURDIR))
  168. # VPATH tells make to look into these directory for source files,
  169. # there is no need to specify explicit pathnames as long as the
  170. # directory is added here
  171. VPATH = .
  172. VPATH += $(BUILD_DIR)
  173. VPATH += $(HARDWARE_SRC)
  174. ifeq ($(HARDWARE_VARIANT), arduino)
  175. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal
  176. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/SPI
  177. else
  178. VPATH += $(HARDWARE_DIR)/libraries/LiquidCrystal
  179. VPATH += $(HARDWARE_DIR)/libraries/SPI
  180. endif
  181. ifeq ($(HARDWARE_VARIANT), arduino)
  182. HARDWARE_SUB_VARIANT ?= mega
  183. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/variants/$(HARDWARE_SUB_VARIANT)
  184. else
  185. HARDWARE_SUB_VARIANT ?= standard
  186. VPATH += $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  187. endif
  188. SRC = wiring.c \
  189. wiring_analog.c wiring_digital.c \
  190. wiring_pulse.c \
  191. wiring_shift.c WInterrupts.c
  192. CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
  193. MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \
  194. SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \
  195. stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \
  196. watchdog.cpp
  197. CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp Servo.cpp Tone.cpp
  198. #Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
  199. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  200. CXXSRC += main.cpp
  201. else
  202. SRC += pins_arduino.c main.c
  203. endif
  204. FORMAT = ihex
  205. # Name of this Makefile (used for "make depend").
  206. MAKEFILE = Makefile
  207. # Debugging format.
  208. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  209. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  210. DEBUG = stabs
  211. OPT = s
  212. DEFINES ?=
  213. # Program settings
  214. CC = $(AVR_TOOLS_PATH)avr-gcc
  215. CXX = $(AVR_TOOLS_PATH)avr-g++
  216. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  217. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  218. AR = $(AVR_TOOLS_PATH)avr-ar
  219. SIZE = $(AVR_TOOLS_PATH)avr-size
  220. NM = $(AVR_TOOLS_PATH)avr-nm
  221. AVRDUDE = avrdude
  222. REMOVE = rm -f
  223. MV = mv -f
  224. # Place -D or -U options here
  225. CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
  226. CXXDEFS = $(CDEFS)
  227. ifeq ($(HARDWARE_VARIANT), Teensy)
  228. CDEFS += -DUSB_SERIAL
  229. SRC += usb.c pins_teensy.c
  230. CXXSRC += usb_api.cpp
  231. endif
  232. # Add all the source directories as include directories too
  233. CINCS = ${addprefix -I ,${VPATH}}
  234. CXXINCS = ${addprefix -I ,${VPATH}}
  235. # Compiler flag to set the C Standard level.
  236. # c89 - "ANSI" C
  237. # gnu89 - c89 plus GCC extensions
  238. # c99 - ISO C99 standard (not yet fully implemented)
  239. # gnu99 - c99 plus GCC extensions
  240. #CSTANDARD = -std=gnu99
  241. CDEBUG = -g$(DEBUG)
  242. CWARN = -Wall -Wstrict-prototypes
  243. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  244. -fshort-enums -w -ffunction-sections -fdata-sections \
  245. -DARDUINO=$(ARDUINO_VERSION)
  246. ifneq ($(HARDWARE_MOTHERBOARD),)
  247. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  248. endif
  249. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  250. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
  251. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
  252. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  253. LDFLAGS = -lm
  254. # Programming support using avrdude. Settings and variables.
  255. AVRDUDE_PORT = $(UPLOAD_PORT)
  256. AVRDUDE_WRITE_FLASH = -U flash:w:$(BUILD_DIR)/$(TARGET).hex:i
  257. AVRDUDE_FLAGS = -D -C $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf \
  258. -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
  259. -b $(UPLOAD_RATE)
  260. # Define all object files.
  261. OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  262. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  263. OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}
  264. # Define all listing files.
  265. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  266. # Combine all necessary flags and optional flags.
  267. # Add target processor to flags.
  268. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  269. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  270. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  271. # set V=1 (eg, "make V=1") to print the full commands etc.
  272. ifneq ($V,1)
  273. Pecho=@echo
  274. P=@
  275. else
  276. Pecho=@:
  277. P=
  278. endif
  279. # Default target.
  280. all: sizeafter
  281. build: $(BUILD_DIR) elf hex
  282. # Creates the object directory
  283. $(BUILD_DIR):
  284. $P mkdir -p $(BUILD_DIR)
  285. elf: $(BUILD_DIR)/$(TARGET).elf
  286. hex: $(BUILD_DIR)/$(TARGET).hex
  287. eep: $(BUILD_DIR)/$(TARGET).eep
  288. lss: $(BUILD_DIR)/$(TARGET).lss
  289. sym: $(BUILD_DIR)/$(TARGET).sym
  290. # Program the device.
  291. # Do not try to reset an arduino if it's not one
  292. upload: $(BUILD_DIR)/$(TARGET).hex
  293. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  294. stty hup < $(UPLOAD_PORT); true
  295. endif
  296. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  297. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  298. stty -hup < $(UPLOAD_PORT); true
  299. endif
  300. # Display size of file.
  301. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  302. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  303. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  304. sizebefore:
  305. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  306. sizeafter: build
  307. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  308. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  309. COFFCONVERT=$(OBJCOPY) --debugging \
  310. --change-section-address .data-0x800000 \
  311. --change-section-address .bss-0x800000 \
  312. --change-section-address .noinit-0x800000 \
  313. --change-section-address .eeprom-0x810000
  314. coff: $(BUILD_DIR)/$(TARGET).elf
  315. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  316. extcoff: $(TARGET).elf
  317. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  318. .SUFFIXES: .elf .hex .eep .lss .sym
  319. .PRECIOUS: .o
  320. .elf.hex:
  321. $(Pecho) " COPY $@"
  322. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  323. .elf.eep:
  324. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  325. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  326. # Create extended listing file from ELF output file.
  327. .elf.lss:
  328. $(OBJDUMP) -h -S $< > $@
  329. # Create a symbol table from ELF output file.
  330. .elf.sym:
  331. $(NM) -n $< > $@
  332. # Link: create ELF output file from library.
  333. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  334. $(Pecho) " CXX $@"
  335. $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS)
  336. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  337. $(Pecho) " CC $<"
  338. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  339. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  340. $(Pecho) " CXX $<"
  341. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  342. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  343. $(Pecho) " CXX $<"
  344. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  345. # Target: clean project.
  346. clean:
  347. $(Pecho) " RM $(BUILD_DIR)/*"
  348. $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
  349. $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
  350. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  351. $(Pecho) " RMDIR $(BUILD_DIR)/"
  352. $P rm -rf $(BUILD_DIR)
  353. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  354. # Automaticaly include the dependency files created by gcc
  355. -include ${wildcard $(BUILD_DIR)/*.d}