My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Makefile 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. # Marlin Firmware 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. # Marlin 2.0 support and RELOC_WORKAROUND by @marcio-ao
  8. #
  9. # This has been tested with Arduino 0022.
  10. #
  11. # This makefile allows you to build sketches from the command line
  12. # without the Arduino environment (or Java).
  13. #
  14. # Detailed instructions for using the makefile:
  15. #
  16. # 1. Modify the line containing "ARDUINO_INSTALL_DIR" to point to the directory that
  17. # contains the Arduino installation (for example, under Mac OS X, this
  18. # might be /Applications/Arduino.app/Contents/Resources/Java).
  19. #
  20. # 2. Modify the line containing "UPLOAD_PORT" to refer to the filename
  21. # representing the USB or serial connection to your Arduino board
  22. # (e.g. UPLOAD_PORT = /dev/tty.USB0). If the exact name of this file
  23. # changes, you can use * as a wild card (e.g. UPLOAD_PORT = /dev/tty.usb*).
  24. #
  25. # 3. Set the line containing "MCU" to match your board's processor.
  26. # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
  27. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  28. # change F_CPU to 8000000. If you are using Gen7 electronics, you
  29. # probably need to use 20000000. Either way, you must regenerate
  30. # the speed lookup table with create_speed_lookuptable.py.
  31. #
  32. # 4. Type "make" and press enter to compile/verify your program.
  33. #
  34. # 5. Type "make upload", reset your Arduino board, and press enter to
  35. # upload your program to the Arduino board.
  36. #
  37. # Note that all settings at the top of this file can be overriden from
  38. # the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
  39. #
  40. # To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
  41. #
  42. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  43. # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino
  44. #
  45. # To compile and upload simply add "upload" to the end of the line...
  46. #
  47. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  48. # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino upload
  49. #
  50. # If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
  51. # start upload manually (using stk500) like so:
  52. #
  53. # avrdude -C /root/arduino/hardware/tools/avr/etc/avrdude.conf -v -p m2560 -c stk500 \
  54. # -U flash:w:applet/Marlin.hex:i -P /dev/ttyUSB0
  55. #
  56. # Or, try disconnecting USB to power down and then reconnecting before running avrdude.
  57. #
  58. # This defines the board to compile for (see boards.h for your board's ID)
  59. HARDWARE_MOTHERBOARD ?= 11
  60. # Arduino source install directory, and version number
  61. # On most linuxes this will be /usr/share/arduino
  62. ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
  63. ARDUINO_VERSION ?= 106
  64. # The installed Libraries are in the User folder
  65. ARDUINO_USER_DIR ?= ${HOME}/Arduino
  66. # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
  67. AVR_TOOLS_PATH ?=
  68. #Programmer configuration
  69. UPLOAD_RATE ?= 57600
  70. AVRDUDE_PROGRAMMER ?= arduino
  71. # on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
  72. UPLOAD_PORT ?= /dev/ttyUSB0
  73. #Directory used to build files in, contains all the build files, from object files to the final hex file
  74. #on linux it is best to put an absolute path like /home/username/tmp .
  75. BUILD_DIR ?= applet
  76. # This defines whether Liquid_TWI2 support will be built
  77. LIQUID_TWI2 ?= 0
  78. # this defines if Wire is needed
  79. WIRE ?= 0
  80. # this defines if U8GLIB is needed (may require RELOC_WORKAROUND)
  81. U8GLIB ?= 1
  82. # this defines whether to include the Trinamic TMC2630Stepper
  83. TMC2630 ?= 1
  84. ############
  85. # Try to automatically determine whether RELOC_WORKAROUND is needed based
  86. # on GCC versions:
  87. # http://www.avrfreaks.net/comment/1789106#comment-1789106
  88. CC_MAJ:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC__ | cut -f3 -d\ )
  89. CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ )
  90. CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ )
  91. CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
  92. ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
  93. @echo This version of GCC is likely broken. Enabling relocation workaround.
  94. RELOC_WORKAROUND = 1
  95. endif
  96. ############################################################################
  97. # Below here nothing should be changed...
  98. # Here the Arduino variant is selected by the board type
  99. # HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
  100. # MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
  101. #Gen7
  102. ifeq ($(HARDWARE_MOTHERBOARD),10)
  103. HARDWARE_VARIANT ?= Gen7
  104. MCU ?= atmega644
  105. F_CPU ?= 20000000
  106. else ifeq ($(HARDWARE_MOTHERBOARD),11)
  107. HARDWARE_VARIANT ?= Gen7
  108. MCU ?= atmega644p
  109. F_CPU ?= 20000000
  110. else ifeq ($(HARDWARE_MOTHERBOARD),12)
  111. HARDWARE_VARIANT ?= Gen7
  112. MCU ?= atmega644p
  113. F_CPU ?= 20000000
  114. else ifeq ($(HARDWARE_MOTHERBOARD),13)
  115. HARDWARE_VARIANT ?= Gen7
  116. MCU ?= atmega1284p
  117. F_CPU ?= 20000000
  118. #RAMPS
  119. else ifeq ($(HARDWARE_MOTHERBOARD),3)
  120. HARDWARE_VARIANT ?= arduino
  121. MCU ?= atmega2560
  122. else ifeq ($(HARDWARE_MOTHERBOARD),33)
  123. HARDWARE_VARIANT ?= arduino
  124. MCU ?= atmega2560
  125. else ifeq ($(HARDWARE_MOTHERBOARD),34)
  126. HARDWARE_VARIANT ?= arduino
  127. MCU ?= atmega2560
  128. else ifeq ($(HARDWARE_MOTHERBOARD),35)
  129. HARDWARE_VARIANT ?= arduino
  130. MCU ?= atmega2560
  131. else ifeq ($(HARDWARE_MOTHERBOARD),36)
  132. HARDWARE_VARIANT ?= arduino
  133. MCU ?= atmega2560
  134. else ifeq ($(HARDWARE_MOTHERBOARD),38)
  135. HARDWARE_VARIANT ?= arduino
  136. MCU ?= atmega2560
  137. else ifeq ($(HARDWARE_MOTHERBOARD),43)
  138. HARDWARE_VARIANT ?= arduino
  139. MCU ?= atmega2560
  140. else ifeq ($(HARDWARE_MOTHERBOARD),44)
  141. HARDWARE_VARIANT ?= arduino
  142. MCU ?= atmega2560
  143. else ifeq ($(HARDWARE_MOTHERBOARD),45)
  144. HARDWARE_VARIANT ?= arduino
  145. MCU ?= atmega2560
  146. else ifeq ($(HARDWARE_MOTHERBOARD),46)
  147. HARDWARE_VARIANT ?= arduino
  148. MCU ?= atmega2560
  149. else ifeq ($(HARDWARE_MOTHERBOARD),48)
  150. HARDWARE_VARIANT ?= arduino
  151. MCU ?= atmega2560
  152. #RAMPS equivalents
  153. else ifeq ($(HARDWARE_MOTHERBOARD),143)
  154. HARDWARE_VARIANT ?= arduino
  155. MCU ?= atmega2560
  156. else ifeq ($(HARDWARE_MOTHERBOARD),144)
  157. HARDWARE_VARIANT ?= arduino
  158. MCU ?= atmega2560
  159. else ifeq ($(HARDWARE_MOTHERBOARD),145)
  160. HARDWARE_VARIANT ?= arduino
  161. MCU ?= atmega2560
  162. else ifeq ($(HARDWARE_MOTHERBOARD),146)
  163. HARDWARE_VARIANT ?= arduino
  164. MCU ?= atmega2560
  165. else ifeq ($(HARDWARE_MOTHERBOARD),148)
  166. HARDWARE_VARIANT ?= arduino
  167. MCU ?= atmega2560
  168. else ifeq ($(HARDWARE_MOTHERBOARD),77)
  169. HARDWARE_VARIANT ?= arduino
  170. MCU ?= atmega2560
  171. else ifeq ($(HARDWARE_MOTHERBOARD),78)
  172. HARDWARE_VARIANT ?= arduino
  173. MCU ?= atmega2560
  174. else ifeq ($(HARDWARE_MOTHERBOARD),79)
  175. HARDWARE_VARIANT ?= arduino
  176. MCU ?= atmega2560
  177. else ifeq ($(HARDWARE_MOTHERBOARD),401)
  178. HARDWARE_VARIANT ?= arduino
  179. MCU ?= atmega2560
  180. else ifeq ($(HARDWARE_MOTHERBOARD),402)
  181. HARDWARE_VARIANT ?= arduino
  182. MCU ?= atmega2560
  183. else ifeq ($(HARDWARE_MOTHERBOARD),40)
  184. HARDWARE_VARIANT ?= arduino
  185. MCU ?= atmega2560
  186. else ifeq ($(HARDWARE_MOTHERBOARD),41)
  187. HARDWARE_VARIANT ?= arduino
  188. MCU ?= atmega2560
  189. else ifeq ($(HARDWARE_MOTHERBOARD),47)
  190. HARDWARE_VARIANT ?= arduino
  191. MCU ?= atmega2560
  192. else ifeq ($(HARDWARE_MOTHERBOARD),53)
  193. HARDWARE_VARIANT ?= arduino
  194. MCU ?= atmega2560
  195. else ifeq ($(HARDWARE_MOTHERBOARD),504)
  196. HARDWARE_VARIANT ?= arduino
  197. MCU ?= atmega2560
  198. else ifeq ($(HARDWARE_MOTHERBOARD),37)
  199. HARDWARE_VARIANT ?= arduino
  200. MCU ?= atmega2560
  201. else ifeq ($(HARDWARE_MOTHERBOARD),42)
  202. HARDWARE_VARIANT ?= arduino
  203. MCU ?= atmega2560
  204. else ifeq ($(HARDWARE_MOTHERBOARD),52)
  205. HARDWARE_VARIANT ?= arduino
  206. MCU ?= atmega2560
  207. else ifeq ($(HARDWARE_MOTHERBOARD),49)
  208. HARDWARE_VARIANT ?= arduino
  209. MCU ?= atmega2560
  210. else ifeq ($(HARDWARE_MOTHERBOARD),72)
  211. HARDWARE_VARIANT ?= arduino
  212. MCU ?= atmega2560
  213. else ifeq ($(HARDWARE_MOTHERBOARD),80)
  214. HARDWARE_VARIANT ?= arduino
  215. MCU ?= atmega2560
  216. else ifeq ($(HARDWARE_MOTHERBOARD),503)
  217. HARDWARE_VARIANT ?= arduino
  218. MCU ?= atmega2560
  219. else ifeq ($(HARDWARE_MOTHERBOARD),431)
  220. HARDWARE_VARIANT ?= arduino
  221. MCU ?= atmega2560
  222. else ifeq ($(HARDWARE_MOTHERBOARD),343)
  223. HARDWARE_VARIANT ?= arduino
  224. MCU ?= atmega2560
  225. else ifeq ($(HARDWARE_MOTHERBOARD),243)
  226. HARDWARE_VARIANT ?= arduino
  227. MCU ?= atmega2560
  228. #Other ATmega1280, ATmega2560
  229. else ifeq ($(HARDWARE_MOTHERBOARD),111)
  230. HARDWARE_VARIANT ?= arduino
  231. MCU ?= atmega2560
  232. else ifeq ($(HARDWARE_MOTHERBOARD),112)
  233. HARDWARE_VARIANT ?= arduino
  234. MCU ?= atmega2560
  235. else ifeq ($(HARDWARE_MOTHERBOARD),2)
  236. HARDWARE_VARIANT ?= arduino
  237. MCU ?= atmega2560
  238. else ifeq ($(HARDWARE_MOTHERBOARD),21)
  239. HARDWARE_VARIANT ?= arduino
  240. MCU ?= atmega2560
  241. else ifeq ($(HARDWARE_MOTHERBOARD),200)
  242. HARDWARE_VARIANT ?= arduino
  243. MCU ?= atmega2560
  244. else ifeq ($(HARDWARE_MOTHERBOARD),70)
  245. HARDWARE_VARIANT ?= arduino
  246. MCU ?= atmega2560
  247. else ifeq ($(HARDWARE_MOTHERBOARD),701)
  248. HARDWARE_VARIANT ?= arduino
  249. MCU ?= atmega2560
  250. else ifeq ($(HARDWARE_MOTHERBOARD),703)
  251. HARDWARE_VARIANT ?= arduino
  252. MCU ?= atmega2560
  253. else ifeq ($(HARDWARE_MOTHERBOARD),704)
  254. HARDWARE_VARIANT ?= arduino
  255. MCU ?= atmega2560
  256. else ifeq ($(HARDWARE_MOTHERBOARD),302)
  257. HARDWARE_VARIANT ?= arduino
  258. MCU ?= atmega2560
  259. else ifeq ($(HARDWARE_MOTHERBOARD),303)
  260. HARDWARE_VARIANT ?= arduino
  261. MCU ?= atmega2560
  262. else ifeq ($(HARDWARE_MOTHERBOARD),304)
  263. HARDWARE_VARIANT ?= arduino
  264. MCU ?= atmega2560
  265. else ifeq ($(HARDWARE_MOTHERBOARD),305)
  266. HARDWARE_VARIANT ?= arduino
  267. MCU ?= atmega2560
  268. else ifeq ($(HARDWARE_MOTHERBOARD),21)
  269. HARDWARE_VARIANT ?= arduino
  270. MCU ?= atmega2560
  271. else ifeq ($(HARDWARE_MOTHERBOARD),999)
  272. HARDWARE_VARIANT ?= arduino
  273. MCU ?= atmega2560
  274. else ifeq ($(HARDWARE_MOTHERBOARD),310)
  275. HARDWARE_VARIANT ?= arduino
  276. MCU ?= atmega2560
  277. else ifeq ($(HARDWARE_MOTHERBOARD),321)
  278. HARDWARE_VARIANT ?= arduino
  279. MCU ?= atmega2560
  280. else ifeq ($(HARDWARE_MOTHERBOARD),74)
  281. HARDWARE_VARIANT ?= arduino
  282. MCU ?= atmega2560
  283. else ifeq ($(HARDWARE_MOTHERBOARD),75)
  284. HARDWARE_VARIANT ?= arduino
  285. MCU ?= atmega2560
  286. #Gen6
  287. else ifeq ($(HARDWARE_MOTHERBOARD),5)
  288. HARDWARE_VARIANT ?= Gen6
  289. MCU ?= atmega644p
  290. else ifeq ($(HARDWARE_MOTHERBOARD),51)
  291. HARDWARE_VARIANT ?= Gen6
  292. MCU ?= atmega644p
  293. #Sanguinololu
  294. else ifeq ($(HARDWARE_MOTHERBOARD),6)
  295. HARDWARE_VARIANT ?= Sanguino
  296. MCU ?= atmega644p
  297. else ifeq ($(HARDWARE_MOTHERBOARD),62)
  298. HARDWARE_VARIANT ?= Sanguino
  299. MCU ?= atmega644p
  300. else ifeq ($(HARDWARE_MOTHERBOARD),63)
  301. HARDWARE_VARIANT ?= Sanguino
  302. MCU ?= atmega644p
  303. else ifeq ($(HARDWARE_MOTHERBOARD),64)
  304. HARDWARE_VARIANT ?= Sanguino
  305. MCU ?= atmega1284p
  306. else ifeq ($(HARDWARE_MOTHERBOARD),65)
  307. HARDWARE_VARIANT ?= Sanguino
  308. MCU ?= atmega1284p
  309. else ifeq ($(HARDWARE_MOTHERBOARD),66)
  310. HARDWARE_VARIANT ?= Sanguino
  311. MCU ?= atmega1284p
  312. else ifeq ($(HARDWARE_MOTHERBOARD),69)
  313. HARDWARE_VARIANT ?= Sanguino
  314. MCU ?= atmega1284p
  315. else ifeq ($(HARDWARE_MOTHERBOARD),89)
  316. HARDWARE_VARIANT ?= Sanguino
  317. MCU ?= atmega1284p
  318. else ifeq ($(HARDWARE_MOTHERBOARD),92)
  319. HARDWARE_VARIANT ?= Sanguino
  320. MCU ?= atmega1284p
  321. else ifeq ($(HARDWARE_MOTHERBOARD),505)
  322. HARDWARE_VARIANT ?= Sanguino
  323. MCU ?= atmega1284p
  324. else ifeq ($(HARDWARE_MOTHERBOARD),601)
  325. HARDWARE_VARIANT ?= Sanguino
  326. MCU ?= atmega1284p
  327. #Ultimaker
  328. else ifeq ($(HARDWARE_MOTHERBOARD),7)
  329. HARDWARE_VARIANT ?= arduino
  330. MCU ?= atmega2560
  331. else ifeq ($(HARDWARE_MOTHERBOARD),71)
  332. HARDWARE_VARIANT ?= arduino
  333. MCU ?= atmega1280
  334. #ATmega1281, ATmega2561
  335. else ifeq ($(HARDWARE_MOTHERBOARD),702)
  336. HARDWARE_VARIANT ?= arduino
  337. MCU ?= atmega1281
  338. else ifeq ($(HARDWARE_MOTHERBOARD),25)
  339. HARDWARE_VARIANT ?= arduino
  340. MCU ?= atmega1281
  341. #Teensylu
  342. else ifeq ($(HARDWARE_MOTHERBOARD),8)
  343. HARDWARE_VARIANT ?= Teensy
  344. MCU ?= at90usb1286
  345. else ifeq ($(HARDWARE_MOTHERBOARD),81)
  346. HARDWARE_VARIANT ?= Teensy
  347. MCU ?= at90usb1286
  348. else ifeq ($(HARDWARE_MOTHERBOARD),811)
  349. HARDWARE_VARIANT ?= Teensy
  350. MCU ?= at90usb1286
  351. else ifeq ($(HARDWARE_MOTHERBOARD),82)
  352. HARDWARE_VARIANT ?= Teensy
  353. MCU ?= at90usb646
  354. else ifeq ($(HARDWARE_MOTHERBOARD),83)
  355. HARDWARE_VARIANT ?= Teensy
  356. MCU ?= at90usb1286
  357. else ifeq ($(HARDWARE_MOTHERBOARD),84)
  358. HARDWARE_VARIANT ?= Teensy
  359. MCU ?= at90usb1286
  360. else ifeq ($(HARDWARE_MOTHERBOARD),88)
  361. HARDWARE_VARIANT ?= Teensy
  362. MCU ?= at90usb1286
  363. #Gen3+
  364. else ifeq ($(HARDWARE_MOTHERBOARD),9)
  365. HARDWARE_VARIANT ?= Sanguino
  366. MCU ?= atmega644p
  367. #Gen3 Monolithic Electronics
  368. else ifeq ($(HARDWARE_MOTHERBOARD),22)
  369. HARDWARE_VARIANT ?= Sanguino
  370. MCU ?= atmega644p
  371. #Megatronics
  372. else ifeq ($(HARDWARE_MOTHERBOARD),70)
  373. HARDWARE_VARIANT ?= arduino
  374. MCU ?= atmega2560
  375. #Alpha OMCA board
  376. else ifeq ($(HARDWARE_MOTHERBOARD),90)
  377. HARDWARE_VARIANT ?= SanguinoA
  378. MCU ?= atmega644
  379. #Final OMCA board
  380. else ifeq ($(HARDWARE_MOTHERBOARD),91)
  381. HARDWARE_VARIANT ?= Sanguino
  382. MCU ?= atmega644p
  383. #Sethi 3D_1
  384. else ifeq ($(HARDWARE_MOTHERBOARD),20)
  385. HARDWARE_VARIANT ?= Sanguino
  386. MCU ?= atmega644p
  387. #Rambo
  388. else ifeq ($(HARDWARE_MOTHERBOARD),301)
  389. HARDWARE_VARIANT ?= arduino
  390. MCU ?= atmega2560
  391. #Azteeg
  392. else ifeq ($(HARDWARE_MOTHERBOARD),67)
  393. HARDWARE_VARIANT ?= arduino
  394. MCU ?= atmega2560
  395. else ifeq ($(HARDWARE_MOTHERBOARD),68)
  396. HARDWARE_VARIANT ?= arduino
  397. MCU ?= atmega2560
  398. endif
  399. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  400. # if you are setting this to something other than 16MHz
  401. # Set to 16Mhz if not yet set.
  402. F_CPU ?= 16000000
  403. # Arduino contained the main source code for the Arduino
  404. # Libraries, the "hardware variant" are for boards
  405. # that derives from that, and their source are present in
  406. # the main Marlin source directory
  407. TARGET = $(notdir $(CURDIR))
  408. # VPATH tells make to look into these directory for source files,
  409. # there is no need to specify explicit pathnames as long as the
  410. # directory is added here
  411. # The Makefile for previous versions of Marlin used VPATH for all
  412. # source files, but for Marlin 2.0, we use VPATH only for arduino
  413. # library files.
  414. VPATH = .
  415. VPATH += $(BUILD_DIR)
  416. VPATH += $(HARDWARE_SRC)
  417. # U8glib
  418. VPATH += $(ARDUINO_USER_DIR)/libraries/U8glib
  419. VPATH += $(ARDUINO_USER_DIR)/libraries/U8glib/clib
  420. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
  421. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/LiquidCrystal/src
  422. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/libraries/SPI
  423. endif
  424. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
  425. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  426. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  427. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  428. ifeq ($(LIQUID_TWI2), 1)
  429. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  430. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  431. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  432. endif
  433. ifeq ($(WIRE), 1)
  434. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  435. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  436. endif
  437. ifeq ($(NEOPIXEL), 1)
  438. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
  439. endif
  440. ifeq ($(U8GLIB), 1)
  441. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
  442. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/clib
  443. endif
  444. ifeq ($(TMC2630), 1)
  445. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/src
  446. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/src/source
  447. endif
  448. ifeq ($(HARDWARE_VARIANT), arduino)
  449. HARDWARE_SUB_VARIANT ?= mega
  450. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
  451. else
  452. ifeq ($(HARDWARE_VARIANT), Sanguino)
  453. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/marlin/avr/variants/sanguino
  454. else
  455. HARDWARE_SUB_VARIANT ?= standard
  456. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  457. endif
  458. endif
  459. LIB_SRC = wiring.c \
  460. wiring_analog.c wiring_digital.c \
  461. wiring_pulse.c \
  462. wiring_shift.c WInterrupts.c hooks.c
  463. ifeq ($(HARDWARE_VARIANT), Teensy)
  464. LIB_SRC = wiring.c
  465. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
  466. endif
  467. LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp Tone.cpp
  468. ifeq ($(NEOPIXEL), 1)
  469. LIB_CXXSRC += Adafruit_NeoPixel.cpp
  470. endif
  471. ifeq ($(LIQUID_TWI2), 0)
  472. LIB_CXXSRC += LiquidCrystal.cpp
  473. else
  474. LIB_SRC += twi.c
  475. LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
  476. endif
  477. ifeq ($(WIRE), 1)
  478. LIB_SRC += twi.c
  479. LIB_CXXSRC += Wire.cpp
  480. endif
  481. ifeq ($(U8GLIB), 1)
  482. LIB_CXXSRC += U8glib.cpp
  483. LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c u8g_font_data.c
  484. endif
  485. ifeq ($(TMC2630), 1)
  486. LIB_CXXSRC += TMC2130Stepper.cpp TMC2130Stepper_COOLCONF.cpp TMC2130Stepper_DRV_STATUS.cpp TMC2130Stepper_IHOLD_IRUN.cpp TMC2130Stepper_CHOPCONF.cpp TMC2130Stepper_GCONF.cpp TMC2130Stepper_PWMCONF.cpp SW_SPI.cpp
  487. endif
  488. ifeq ($(RELOC_WORKAROUND), 1)
  489. LD_PREFIX=-nodefaultlibs
  490. LD_SUFFIX=-lm -lgcc -lc -lgcc
  491. endif
  492. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  493. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  494. LIB_CXXSRC += main.cpp
  495. else
  496. LIB_SRC += pins_arduino.c main.c
  497. endif
  498. FORMAT = ihex
  499. # Name of this Makefile (used for "make depend").
  500. MAKEFILE = Makefile
  501. # Debugging format.
  502. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  503. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  504. DEBUG = stabs
  505. OPT = s
  506. DEFINES ?=
  507. # Program settings
  508. CC = $(AVR_TOOLS_PATH)avr-gcc
  509. CXX = $(AVR_TOOLS_PATH)avr-g++
  510. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  511. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  512. AR = $(AVR_TOOLS_PATH)avr-ar
  513. SIZE = $(AVR_TOOLS_PATH)avr-size
  514. NM = $(AVR_TOOLS_PATH)avr-nm
  515. AVRDUDE = avrdude
  516. REMOVE = rm -f
  517. MV = mv -f
  518. # Place -D or -U options here
  519. CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
  520. CXXDEFS = $(CDEFS)
  521. ifeq ($(HARDWARE_VARIANT), Teensy)
  522. CDEFS += -DUSB_SERIAL
  523. LIB_SRC += usb.c pins_teensy.c
  524. LIB_CXXSRC += usb_api.cpp
  525. endif
  526. # Add all the source directories as include directories too
  527. CINCS = ${addprefix -I ,${VPATH}}
  528. CXXINCS = ${addprefix -I ,${VPATH}}
  529. # Compiler flag to set the C/CPP Standard level.
  530. CSTANDARD = -std=gnu99
  531. CXXSTANDARD = -std=gnu++11
  532. CDEBUG = -g$(DEBUG)
  533. CWARN = -Wall -Wstrict-prototypes
  534. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  535. -fshort-enums -w -ffunction-sections -fdata-sections \
  536. -flto \
  537. -DARDUINO=$(ARDUINO_VERSION)
  538. ifneq ($(HARDWARE_MOTHERBOARD),)
  539. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  540. endif
  541. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  542. CEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics
  543. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  544. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(CXXSTANDARD)
  545. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  546. LDFLAGS = -lm
  547. # Programming support using avrdude. Settings and variables.
  548. AVRDUDE_PORT = $(UPLOAD_PORT)
  549. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  550. ifeq ($(shell uname -s), Linux)
  551. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  552. else
  553. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  554. endif
  555. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  556. -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  557. -b$(UPLOAD_RATE)
  558. # Since Marlin 2.0, the source files may be distributed into several
  559. # different directories, so it is necessary to find them recursively
  560. SRC = $(shell find src -name '*.c' -type f)
  561. CXXSRC = $(shell find src -name '*.cpp' -type f)
  562. # Define all object files.
  563. OBJ = ${patsubst %.c, $(BUILD_DIR)/arduino/%.o, ${LIB_SRC}}
  564. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/arduino/%.o, ${LIB_CXXSRC}}
  565. OBJ += ${patsubst %.S, $(BUILD_DIR)/arduino/%.o, ${LIB_ASRC}}
  566. OBJ += ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  567. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  568. # Define all listing files.
  569. LST = $(LIB_ASRC:.S=.lst) $(LIB_CXXSRC:.cpp=.lst) $(LIB_SRC:.c=.lst)
  570. # Combine all necessary flags and optional flags.
  571. # Add target processor to flags.
  572. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  573. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  574. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  575. # set V=1 (eg, "make V=1") to print the full commands etc.
  576. ifneq ($V,1)
  577. Pecho=@echo
  578. P=@
  579. else
  580. Pecho=@:
  581. P=
  582. endif
  583. # Create required build hierarchy if it does not exist
  584. $(shell mkdir -p $(dir $(OBJ)))
  585. # Default target.
  586. all: sizeafter
  587. build: elf hex
  588. elf: $(BUILD_DIR)/$(TARGET).elf
  589. hex: $(BUILD_DIR)/$(TARGET).hex
  590. eep: $(BUILD_DIR)/$(TARGET).eep
  591. lss: $(BUILD_DIR)/$(TARGET).lss
  592. sym: $(BUILD_DIR)/$(TARGET).sym
  593. # Program the device.
  594. # Do not try to reset an Arduino if it's not one
  595. upload: $(BUILD_DIR)/$(TARGET).hex
  596. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  597. stty hup < $(UPLOAD_PORT); true
  598. endif
  599. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  600. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  601. stty -hup < $(UPLOAD_PORT); true
  602. endif
  603. # Display size of file.
  604. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  605. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  606. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  607. sizebefore:
  608. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  609. sizeafter: build
  610. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  611. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  612. COFFCONVERT=$(OBJCOPY) --debugging \
  613. --change-section-address .data-0x800000 \
  614. --change-section-address .bss-0x800000 \
  615. --change-section-address .noinit-0x800000 \
  616. --change-section-address .eeprom-0x810000
  617. coff: $(BUILD_DIR)/$(TARGET).elf
  618. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  619. extcoff: $(TARGET).elf
  620. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  621. .SUFFIXES: .elf .hex .eep .lss .sym
  622. .PRECIOUS: .o
  623. .elf.hex:
  624. $(Pecho) " COPY $@"
  625. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  626. .elf.eep:
  627. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  628. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  629. # Create extended listing file from ELF output file.
  630. .elf.lss:
  631. $(OBJDUMP) -h -S $< > $@
  632. # Create a symbol table from ELF output file.
  633. .elf.sym:
  634. $(NM) -n $< > $@
  635. # Link: create ELF output file from library.
  636. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  637. $(Pecho) " CXX $@"
  638. $P $(CC) $(LD_PREFIX) $(ALL_CXXFLAGS) -Wl,--gc-sections,--relax -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
  639. # Object files that were found in "src" will be stored in $(BUILD_DIR)
  640. # in directories that mirror the structure of "src"
  641. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  642. $(Pecho) " CC $<"
  643. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  644. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  645. $(Pecho) " CXX $<"
  646. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  647. # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino
  648. $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  649. $(Pecho) " CC $<"
  650. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  651. $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  652. $(Pecho) " CXX $<"
  653. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  654. # Target: clean project.
  655. clean:
  656. $(Pecho) " RMDIR $(BUILD_DIR)/"
  657. $P rm -rf $(BUILD_DIR)
  658. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  659. # Automaticaly include the dependency files created by gcc
  660. -include ${patsubst %.o, %.d, ${OBJ}}