Makefile 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068
  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 macOS, 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. Set
  26. # "PROG_MCU" as the AVR part name corresponding to "MCU". You can use the
  27. # following command to get a list of correspondences: `avrdude -c alf -p x`
  28. # Older boards are atmega8 based, newer ones like Arduino Mini, Bluetooth
  29. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  30. # change F_CPU to 8000000. If you are using Gen7 electronics, you
  31. # probably need to use 20000000. Either way, you must regenerate
  32. # the speed lookup table with create_speed_lookuptable.py.
  33. #
  34. # 4. Type "make" and press enter to compile/verify your program.
  35. #
  36. # 5. Type "make upload", reset your Arduino board, and press enter to
  37. # upload your program to the Arduino board.
  38. #
  39. # Note that all settings at the top of this file can be overridden from
  40. # the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
  41. #
  42. # To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
  43. #
  44. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  45. # HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino
  46. #
  47. # To compile and upload simply add "upload" to the end of the line...
  48. #
  49. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  50. # HARDWARE_MOTHERBOARD=1200 ARDUINO_INSTALL_DIR=/root/arduino upload
  51. #
  52. # If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
  53. # start upload manually (using stk500) like so:
  54. #
  55. # avrdude -C /root/arduino/hardware/tools/avr/etc/avrdude.conf -v -p m2560 -c stk500 \
  56. # -U flash:w:applet/Marlin.hex:i -P /dev/ttyUSB0
  57. #
  58. # Or, try disconnecting USB to power down and then reconnecting before running avrdude.
  59. #
  60. # This defines the board to compile for (see boards.h for your board's ID)
  61. HARDWARE_MOTHERBOARD ?= 1020
  62. ifeq ($(OS),Windows_NT)
  63. # Windows
  64. ARDUINO_INSTALL_DIR ?= ${HOME}/AppData/Local/Arduino
  65. ARDUINO_USER_DIR ?= ${HOME}/Documents/Arduino
  66. else
  67. UNAME_S := $(shell uname -s)
  68. ifeq ($(UNAME_S),Linux)
  69. # Linux
  70. ARDUINO_INSTALL_DIR ?= /usr/share/arduino
  71. ARDUINO_USER_DIR ?= ${HOME}/Arduino
  72. endif
  73. ifeq ($(UNAME_S),Darwin)
  74. # Darwin (macOS)
  75. ARDUINO_INSTALL_DIR ?= /Applications/Arduino.app/Contents/Java
  76. ARDUINO_USER_DIR ?= ${HOME}/Documents/Arduino
  77. AVR_TOOLS_PATH ?= /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/
  78. endif
  79. endif
  80. # Arduino source install directory, and version number
  81. # On most linuxes this will be /usr/share/arduino
  82. ARDUINO_INSTALL_DIR ?= ${HOME}/AppData/Local/Arduino # C:/Users/${USERNAME}/AppData/Local/Arduino
  83. ARDUINO_VERSION ?= 10819
  84. # The installed Libraries are in the User folder
  85. ARDUINO_USER_DIR ?= ${HOME}/Documents/Arduino
  86. # You can optionally set a path to the avr-gcc tools.
  87. # Requires a trailing slash. For example, /usr/local/avr-gcc/bin/
  88. AVR_TOOLS_PATH ?=
  89. # Programmer configuration
  90. UPLOAD_RATE ?= 57600
  91. AVRDUDE_PROGRAMMER ?= arduino
  92. # On most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
  93. UPLOAD_PORT ?= /dev/ttyUSB0
  94. # Directory used to build files in, contains all the build files, from object
  95. # files to the final hex file on linux it is best to put an absolute path
  96. # like /home/username/tmp .
  97. BUILD_DIR ?= applet
  98. # This defines whether Liquid_TWI2 support will be built
  99. LIQUID_TWI2 ?= 0
  100. # This defines if Wire is needed
  101. WIRE ?= 0
  102. # This defines if Tone is needed (i.e., SPEAKER is defined in Configuration.h)
  103. # Disabling this (and SPEAKER) saves approximately 350 bytes of memory.
  104. TONE ?= 1
  105. # This defines if U8GLIB is needed (may require RELOC_WORKAROUND)
  106. U8GLIB ?= 0
  107. # This defines whether to include the Trinamic TMCStepper library
  108. TMC ?= 0
  109. # This defines whether to include the AdaFruit NeoPixel library
  110. NEOPIXEL ?= 0
  111. ############
  112. # Try to automatically determine whether RELOC_WORKAROUND is needed based
  113. # on GCC versions:
  114. # https://www.avrfreaks.net/comment/1789106#comment-1789106
  115. CC_MAJ:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC__ | cut -f3 -d\ )
  116. CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ )
  117. CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ )
  118. CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
  119. ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
  120. $(warning This GCC version $(CC_VER) is likely broken. Enabling relocation workaround.)
  121. RELOC_WORKAROUND = 1
  122. endif
  123. ############################################################################
  124. # Below here nothing should be changed...
  125. # Here the Arduino variant is selected by the board type
  126. # HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
  127. # MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
  128. ifeq ($(HARDWARE_MOTHERBOARD),0)
  129. # No motherboard selected
  130. #
  131. # RAMPS 1.3 / 1.4 - ATmega1280, ATmega2560
  132. #
  133. # MEGA/RAMPS up to 1.2
  134. else ifeq ($(HARDWARE_MOTHERBOARD),1000)
  135. # RAMPS 1.3 (Power outputs: Hotend, Fan, Bed)
  136. else ifeq ($(HARDWARE_MOTHERBOARD),1010)
  137. # RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Bed)
  138. else ifeq ($(HARDWARE_MOTHERBOARD),1011)
  139. # RAMPS 1.3 (Power outputs: Hotend, Fan0, Fan1)
  140. else ifeq ($(HARDWARE_MOTHERBOARD),1012)
  141. # RAMPS 1.3 (Power outputs: Hotend0, Hotend1, Fan)
  142. else ifeq ($(HARDWARE_MOTHERBOARD),1013)
  143. # RAMPS 1.3 (Power outputs: Spindle, Controller Fan)
  144. else ifeq ($(HARDWARE_MOTHERBOARD),1014)
  145. # RAMPS 1.4 (Power outputs: Hotend, Fan, Bed)
  146. else ifeq ($(HARDWARE_MOTHERBOARD),1020)
  147. # RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Bed)
  148. else ifeq ($(HARDWARE_MOTHERBOARD),1021)
  149. # RAMPS 1.4 (Power outputs: Hotend, Fan0, Fan1)
  150. else ifeq ($(HARDWARE_MOTHERBOARD),1022)
  151. # RAMPS 1.4 (Power outputs: Hotend0, Hotend1, Fan)
  152. else ifeq ($(HARDWARE_MOTHERBOARD),1023)
  153. # RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
  154. else ifeq ($(HARDWARE_MOTHERBOARD),1024)
  155. # RAMPS Plus 3DYMY (Power outputs: Hotend, Fan, Bed)
  156. else ifeq ($(HARDWARE_MOTHERBOARD),1030)
  157. # RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Bed)
  158. else ifeq ($(HARDWARE_MOTHERBOARD),1031)
  159. # RAMPS Plus 3DYMY (Power outputs: Hotend, Fan0, Fan1)
  160. else ifeq ($(HARDWARE_MOTHERBOARD),1032)
  161. # RAMPS Plus 3DYMY (Power outputs: Hotend0, Hotend1, Fan)
  162. else ifeq ($(HARDWARE_MOTHERBOARD),1033)
  163. # RAMPS Plus 3DYMY (Power outputs: Spindle, Controller Fan)
  164. else ifeq ($(HARDWARE_MOTHERBOARD),1034)
  165. # RAMPS 1.6+ (Power outputs: Hotend, Fan, Bed)
  166. else ifeq ($(HARDWARE_MOTHERBOARD),1035)
  167. # RAMPS 1.6+ (Power outputs: Hotend0, Hotend1, Bed)
  168. else ifeq ($(HARDWARE_MOTHERBOARD),1036)
  169. # RAMPS 1.6+ (Power outputs: Hotend, Fan0, Fan1)
  170. else ifeq ($(HARDWARE_MOTHERBOARD),1037)
  171. # RAMPS 1.6+ (Power outputs: Hotend0, Hotend1, Fan)
  172. else ifeq ($(HARDWARE_MOTHERBOARD),1038)
  173. # RAMPS 1.6+ (Power outputs: Spindle, Controller Fan)
  174. else ifeq ($(HARDWARE_MOTHERBOARD),1039)
  175. #
  176. # RAMPS Derivatives - ATmega1280, ATmega2560
  177. #
  178. # 3Drag Controller
  179. else ifeq ($(HARDWARE_MOTHERBOARD),1100)
  180. # Velleman K8200 Controller (derived from 3Drag Controller)
  181. else ifeq ($(HARDWARE_MOTHERBOARD),1101)
  182. # Velleman K8400 Controller (derived from 3Drag Controller)
  183. else ifeq ($(HARDWARE_MOTHERBOARD),1102)
  184. # Velleman K8600 Controller (Vertex Nano)
  185. else ifeq ($(HARDWARE_MOTHERBOARD),1103)
  186. # Velleman K8800 Controller (Vertex Delta)
  187. else ifeq ($(HARDWARE_MOTHERBOARD),1104)
  188. # 2PrintBeta BAM&DICE with STK drivers
  189. else ifeq ($(HARDWARE_MOTHERBOARD),1105)
  190. # 2PrintBeta BAM&DICE Due with STK drivers
  191. else ifeq ($(HARDWARE_MOTHERBOARD),1106)
  192. # MKS BASE v1.0
  193. else ifeq ($(HARDWARE_MOTHERBOARD),1107)
  194. # MKS BASE v1.4 with Allegro A4982 stepper drivers
  195. else ifeq ($(HARDWARE_MOTHERBOARD),1108)
  196. # MKS BASE v1.5 with Allegro A4982 stepper drivers
  197. else ifeq ($(HARDWARE_MOTHERBOARD),1109)
  198. # MKS BASE v1.6 with Allegro A4982 stepper drivers
  199. else ifeq ($(HARDWARE_MOTHERBOARD),1110)
  200. # MKS BASE 1.0 with Heroic HR4982 stepper drivers
  201. else ifeq ($(HARDWARE_MOTHERBOARD),1111)
  202. # MKS GEN v1.3 or 1.4
  203. else ifeq ($(HARDWARE_MOTHERBOARD),1112)
  204. # MKS GEN L
  205. else ifeq ($(HARDWARE_MOTHERBOARD),1113)
  206. # BigTreeTech or BIQU KFB2.0
  207. else ifeq ($(HARDWARE_MOTHERBOARD),1114)
  208. # Zonestar zrib V2.0 (Chinese RAMPS replica)
  209. else ifeq ($(HARDWARE_MOTHERBOARD),1115)
  210. # Zonestar zrib V5.2 (Chinese RAMPS replica)
  211. else ifeq ($(HARDWARE_MOTHERBOARD),1116)
  212. # Zonestar zrib V5.3 (Chinese RAMPS replica)
  213. else ifeq ($(HARDWARE_MOTHERBOARD),1117)
  214. # Felix 2.0+ Electronics Board (RAMPS like)
  215. else ifeq ($(HARDWARE_MOTHERBOARD),1118)
  216. # Invent-A-Part RigidBoard
  217. else ifeq ($(HARDWARE_MOTHERBOARD),1119)
  218. # Invent-A-Part RigidBoard V2
  219. else ifeq ($(HARDWARE_MOTHERBOARD),1120)
  220. # Sainsmart 2-in-1 board
  221. else ifeq ($(HARDWARE_MOTHERBOARD),1121)
  222. # Ultimaker
  223. else ifeq ($(HARDWARE_MOTHERBOARD),1122)
  224. # Ultimaker (Older electronics. Pre 1.5.4. This is rare)
  225. else ifeq ($(HARDWARE_MOTHERBOARD),1123)
  226. MCU ?= atmega1280
  227. PROG_MCU ?= m1280
  228. # Azteeg X3
  229. else ifeq ($(HARDWARE_MOTHERBOARD),1124)
  230. # Azteeg X3 Pro
  231. else ifeq ($(HARDWARE_MOTHERBOARD),1125)
  232. # Ultimainboard 2.x (Uses TEMP_SENSOR 20)
  233. else ifeq ($(HARDWARE_MOTHERBOARD),1126)
  234. # Rumba
  235. else ifeq ($(HARDWARE_MOTHERBOARD),1127)
  236. # Raise3D N series Rumba derivative
  237. else ifeq ($(HARDWARE_MOTHERBOARD),1128)
  238. # Rapide Lite 200 (v1, low-cost RUMBA clone with drv)
  239. else ifeq ($(HARDWARE_MOTHERBOARD),1129)
  240. # Formbot T-Rex 2 Plus
  241. else ifeq ($(HARDWARE_MOTHERBOARD),1130)
  242. # Formbot T-Rex 3
  243. else ifeq ($(HARDWARE_MOTHERBOARD),1131)
  244. # Formbot Raptor
  245. else ifeq ($(HARDWARE_MOTHERBOARD),1132)
  246. # Formbot Raptor 2
  247. else ifeq ($(HARDWARE_MOTHERBOARD),1133)
  248. # bq ZUM Mega 3D
  249. else ifeq ($(HARDWARE_MOTHERBOARD),1134)
  250. # MakeBoard Mini v2.1.2 by MicroMake
  251. else ifeq ($(HARDWARE_MOTHERBOARD),1135)
  252. # TriGorilla Anycubic version 1.3-based on RAMPS EFB
  253. else ifeq ($(HARDWARE_MOTHERBOARD),1136)
  254. # ... Ver 1.4
  255. else ifeq ($(HARDWARE_MOTHERBOARD),1137)
  256. # ... Rev 1.1 (new servo pin order)
  257. else ifeq ($(HARDWARE_MOTHERBOARD),1138)
  258. # Creality: Ender-4, CR-8
  259. else ifeq ($(HARDWARE_MOTHERBOARD),1139)
  260. # Creality: CR10S, CR20, CR-X
  261. else ifeq ($(HARDWARE_MOTHERBOARD),1140)
  262. # Dagoma F5
  263. else ifeq ($(HARDWARE_MOTHERBOARD),1141)
  264. # Dagoma D6 (as found in the Dagoma DiscoUltimate V2 TMC)
  265. else ifeq ($(HARDWARE_MOTHERBOARD),1142)
  266. # FYSETC F6 1.3
  267. else ifeq ($(HARDWARE_MOTHERBOARD),1143)
  268. # FYSETC F6 1.4
  269. else ifeq ($(HARDWARE_MOTHERBOARD),1144)
  270. # Wanhao Duplicator i3 Plus
  271. else ifeq ($(HARDWARE_MOTHERBOARD),1145)
  272. # VORON Design
  273. else ifeq ($(HARDWARE_MOTHERBOARD),1146)
  274. # Tronxy TRONXY-V3-1.0
  275. else ifeq ($(HARDWARE_MOTHERBOARD),1147)
  276. # Z-Bolt X Series
  277. else ifeq ($(HARDWARE_MOTHERBOARD),1148)
  278. # TT OSCAR
  279. else ifeq ($(HARDWARE_MOTHERBOARD),1149)
  280. # BIQU Tango V1
  281. else ifeq ($(HARDWARE_MOTHERBOARD),1150)
  282. # MKS GEN L V2
  283. else ifeq ($(HARDWARE_MOTHERBOARD),1151)
  284. # MKS GEN L V2.1
  285. else ifeq ($(HARDWARE_MOTHERBOARD),1152)
  286. # Copymaster 3D
  287. else ifeq ($(HARDWARE_MOTHERBOARD),1153)
  288. # Ortur 4
  289. else ifeq ($(HARDWARE_MOTHERBOARD),1154)
  290. # Tenlog D3 Hero IDEX printer
  291. else ifeq ($(HARDWARE_MOTHERBOARD),1155)
  292. # Tenlog D3, D5, D6 IDEX Printer
  293. else ifeq ($(HARDWARE_MOTHERBOARD),1156)
  294. # Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed)
  295. else ifeq ($(HARDWARE_MOTHERBOARD),1157)
  296. # Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed)
  297. else ifeq ($(HARDWARE_MOTHERBOARD),1158)
  298. # Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed)
  299. else ifeq ($(HARDWARE_MOTHERBOARD),1159)
  300. # Longer LK1 PRO / Alfawise U20 Pro (PRO version)
  301. else ifeq ($(HARDWARE_MOTHERBOARD),1160)
  302. # Longer LKx PRO / Alfawise Uxx Pro (PRO version)
  303. else ifeq ($(HARDWARE_MOTHERBOARD),1161)
  304. # Pxmalion Core I3
  305. else ifeq ($(HARDWARE_MOTHERBOARD),1162)
  306. # Panowin Cutlass (as found in the Panowin F1)
  307. else ifeq ($(HARDWARE_MOTHERBOARD),1163)
  308. # Kodama Bardo V1.x (as found in the Kodama Trinus)
  309. else ifeq ($(HARDWARE_MOTHERBOARD),1164)
  310. # XTLW MFF V1.0
  311. else ifeq ($(HARDWARE_MOTHERBOARD),1165)
  312. # XTLW MFF V2.0
  313. else ifeq ($(HARDWARE_MOTHERBOARD),1166)
  314. #
  315. # RAMBo and derivatives
  316. #
  317. # Rambo
  318. else ifeq ($(HARDWARE_MOTHERBOARD),1200)
  319. # Mini-Rambo
  320. else ifeq ($(HARDWARE_MOTHERBOARD),1201)
  321. # Mini-Rambo 1.0a
  322. else ifeq ($(HARDWARE_MOTHERBOARD),1202)
  323. # Einsy Rambo
  324. else ifeq ($(HARDWARE_MOTHERBOARD),1203)
  325. # Einsy Retro
  326. else ifeq ($(HARDWARE_MOTHERBOARD),1204)
  327. # abee Scoovo X9H
  328. else ifeq ($(HARDWARE_MOTHERBOARD),1205)
  329. # ThinkerV2
  330. else ifeq ($(HARDWARE_MOTHERBOARD),1206)
  331. #
  332. # Other ATmega1280, ATmega2560
  333. #
  334. # Cartesio CN Controls V11
  335. else ifeq ($(HARDWARE_MOTHERBOARD),1300)
  336. # Cartesio CN Controls V12
  337. else ifeq ($(HARDWARE_MOTHERBOARD),1301)
  338. # Cartesio CN Controls V15
  339. else ifeq ($(HARDWARE_MOTHERBOARD),1302)
  340. # Cheaptronic v1.0
  341. else ifeq ($(HARDWARE_MOTHERBOARD),1303)
  342. # Cheaptronic v2.0
  343. else ifeq ($(HARDWARE_MOTHERBOARD),1304)
  344. # Makerbot Mightyboard Revision E
  345. else ifeq ($(HARDWARE_MOTHERBOARD),1305)
  346. # Megatronics
  347. else ifeq ($(HARDWARE_MOTHERBOARD),1306)
  348. # Megatronics v2.0
  349. else ifeq ($(HARDWARE_MOTHERBOARD),1307)
  350. # Megatronics v3.0
  351. else ifeq ($(HARDWARE_MOTHERBOARD),1308)
  352. # Megatronics v3.1
  353. else ifeq ($(HARDWARE_MOTHERBOARD),1309)
  354. # Megatronics v3.2
  355. else ifeq ($(HARDWARE_MOTHERBOARD),1310)
  356. # Elefu Ra Board (v3)
  357. else ifeq ($(HARDWARE_MOTHERBOARD),1311)
  358. # Leapfrog
  359. else ifeq ($(HARDWARE_MOTHERBOARD),1312)
  360. # Mega controller
  361. else ifeq ($(HARDWARE_MOTHERBOARD),1313)
  362. # Geeetech GT2560 Rev A
  363. else ifeq ($(HARDWARE_MOTHERBOARD),1314)
  364. # Geeetech GT2560 Rev A+ (with auto level probe)
  365. else ifeq ($(HARDWARE_MOTHERBOARD),1315)
  366. # Geeetech GT2560 Rev B
  367. else ifeq ($(HARDWARE_MOTHERBOARD),1316)
  368. # Geeetech GT2560 Rev B for A10(M/T/D)
  369. else ifeq ($(HARDWARE_MOTHERBOARD),1317)
  370. # Geeetech GT2560 Rev B for Mecreator2
  371. else ifeq ($(HARDWARE_MOTHERBOARD),1318)
  372. # Geeetech GT2560 Rev B for A20(M/T/D)
  373. else ifeq ($(HARDWARE_MOTHERBOARD),1319)
  374. # Geeetech GT2560 Rev B for A10(M/T/D)
  375. else ifeq ($(HARDWARE_MOTHERBOARD),1320)
  376. # Geeetech GT2560 Rev B for A20(M/T/D)
  377. else ifeq ($(HARDWARE_MOTHERBOARD),1321)
  378. # Einstart retrofit
  379. else ifeq ($(HARDWARE_MOTHERBOARD),1322)
  380. # Wanhao 0ne+ i3 Mini
  381. else ifeq ($(HARDWARE_MOTHERBOARD),1323)
  382. # Overlord/Overlord Pro
  383. else ifeq ($(HARDWARE_MOTHERBOARD),1324)
  384. # ADIMLab Gantry v1
  385. else ifeq ($(HARDWARE_MOTHERBOARD),1325)
  386. # ADIMLab Gantry v2
  387. else ifeq ($(HARDWARE_MOTHERBOARD),1326)
  388. # Leapfrog Xeed 2015
  389. else ifeq ($(HARDWARE_MOTHERBOARD),1327)
  390. # PICA Shield (original version)
  391. else ifeq ($(HARDWARE_MOTHERBOARD),1328)
  392. # PICA Shield (rev C or later)
  393. else ifeq ($(HARDWARE_MOTHERBOARD),1329)
  394. # Intamsys 4.0 (Funmat HT)
  395. else ifeq ($(HARDWARE_MOTHERBOARD),1330)
  396. # Malyan M180 Mainboard Version 2 (no display function, direct G-code only)
  397. else ifeq ($(HARDWARE_MOTHERBOARD),1331)
  398. # Mega controller & Protoneer CNC Shield V3.00
  399. else ifeq ($(HARDWARE_MOTHERBOARD),1332)
  400. # WEEDO 62A board (TINA2, Monoprice Cadet, etc.)
  401. else ifeq ($(HARDWARE_MOTHERBOARD),1333)
  402. # Geeetech GT2560 V4.1B for A10(M/T/D)
  403. else ifeq ($(HARDWARE_MOTHERBOARD),1334)
  404. #
  405. # ATmega1281, ATmega2561
  406. #
  407. # Minitronics v1.0/1.1
  408. else ifeq ($(HARDWARE_MOTHERBOARD),1400)
  409. MCU ?= atmega1281
  410. PROG_MCU ?= m1281
  411. # Silvergate v1.0
  412. else ifeq ($(HARDWARE_MOTHERBOARD),1401)
  413. MCU ?= atmega1281
  414. PROG_MCU ?= m1281
  415. #
  416. # Sanguinololu and Derivatives - ATmega644P, ATmega1284P
  417. #
  418. # Sanguinololu < 1.2
  419. else ifeq ($(HARDWARE_MOTHERBOARD),1500)
  420. HARDWARE_VARIANT ?= Sanguino
  421. MCU ?= atmega644p
  422. PROG_MCU ?= m644p
  423. # Sanguinololu 1.2 and above
  424. else ifeq ($(HARDWARE_MOTHERBOARD),1501)
  425. HARDWARE_VARIANT ?= Sanguino
  426. MCU ?= atmega644p
  427. PROG_MCU ?= m644p
  428. # Melzi
  429. else ifeq ($(HARDWARE_MOTHERBOARD),1502)
  430. HARDWARE_VARIANT ?= Sanguino
  431. MCU ?= atmega644p
  432. PROG_MCU ?= m644p
  433. # Melzi V2
  434. else ifeq ($(HARDWARE_MOTHERBOARD),1503)
  435. HARDWARE_VARIANT ?= Sanguino
  436. MCU ?= atmega1284p
  437. PROG_MCU ?= m1284p
  438. # Melzi with ATmega1284 (MaKr3d version)
  439. else ifeq ($(HARDWARE_MOTHERBOARD),1504)
  440. HARDWARE_VARIANT ?= Sanguino
  441. MCU ?= atmega1284p
  442. PROG_MCU ?= m1284p
  443. # Melzi Creality3D (for CR-10 etc)
  444. else ifeq ($(HARDWARE_MOTHERBOARD),1505)
  445. HARDWARE_VARIANT ?= Sanguino
  446. MCU ?= atmega1284p
  447. PROG_MCU ?= m1284p
  448. # Melzi Creality3D (for Ender-2)
  449. else ifeq ($(HARDWARE_MOTHERBOARD),1506)
  450. HARDWARE_VARIANT ?= Sanguino
  451. MCU ?= atmega1284p
  452. PROG_MCU ?= m1284p
  453. # Melzi Malyan M150
  454. else ifeq ($(HARDWARE_MOTHERBOARD),1507)
  455. HARDWARE_VARIANT ?= Sanguino
  456. MCU ?= atmega1284p
  457. PROG_MCU ?= m1284p
  458. # Tronxy X5S
  459. else ifeq ($(HARDWARE_MOTHERBOARD),1508)
  460. HARDWARE_VARIANT ?= Sanguino
  461. MCU ?= atmega1284p
  462. PROG_MCU ?= m1284p
  463. # STB V1.1
  464. else ifeq ($(HARDWARE_MOTHERBOARD),1509)
  465. HARDWARE_VARIANT ?= Sanguino
  466. MCU ?= atmega1284p
  467. PROG_MCU ?= m1284p
  468. # Azteeg X1
  469. else ifeq ($(HARDWARE_MOTHERBOARD),1510)
  470. HARDWARE_VARIANT ?= Sanguino
  471. MCU ?= atmega1284p
  472. PROG_MCU ?= m1284p
  473. # Anet 1.0 (Melzi clone)
  474. else ifeq ($(HARDWARE_MOTHERBOARD),1511)
  475. HARDWARE_VARIANT ?= Sanguino
  476. MCU ?= atmega1284p
  477. PROG_MCU ?= m1284p
  478. # ZoneStar ZMIB V2
  479. else ifeq ($(HARDWARE_MOTHERBOARD),1511)
  480. HARDWARE_VARIANT ?= Sanguino
  481. MCU ?= atmega1284p
  482. PROG_MCU ?= m1284p
  483. #
  484. # Other ATmega644P, ATmega644, ATmega1284P
  485. #
  486. # Gen3 Monolithic Electronics
  487. else ifeq ($(HARDWARE_MOTHERBOARD),1600)
  488. HARDWARE_VARIANT ?= Sanguino
  489. MCU ?= atmega644p
  490. PROG_MCU ?= m644p
  491. # Gen3+
  492. else ifeq ($(HARDWARE_MOTHERBOARD),1601)
  493. HARDWARE_VARIANT ?= Sanguino
  494. MCU ?= atmega644p
  495. PROG_MCU ?= m644p
  496. # Gen6
  497. else ifeq ($(HARDWARE_MOTHERBOARD),1602)
  498. HARDWARE_VARIANT ?= Gen6
  499. MCU ?= atmega644p
  500. PROG_MCU ?= m644p
  501. # Gen6 deluxe
  502. else ifeq ($(HARDWARE_MOTHERBOARD),1603)
  503. HARDWARE_VARIANT ?= Gen6
  504. MCU ?= atmega644p
  505. PROG_MCU ?= m644p
  506. # Gen7 custom (Alfons3 Version)
  507. else ifeq ($(HARDWARE_MOTHERBOARD),1604)
  508. HARDWARE_VARIANT ?= Gen7
  509. MCU ?= atmega644
  510. PROG_MCU ?= m644
  511. F_CPU ?= 20000000
  512. # Gen7 v1.1, v1.2
  513. else ifeq ($(HARDWARE_MOTHERBOARD),1605)
  514. HARDWARE_VARIANT ?= Gen7
  515. MCU ?= atmega644p
  516. PROG_MCU ?= m644p
  517. F_CPU ?= 20000000
  518. # Gen7 v1.3
  519. else ifeq ($(HARDWARE_MOTHERBOARD),1606)
  520. HARDWARE_VARIANT ?= Gen7
  521. MCU ?= atmega644p
  522. PROG_MCU ?= m644p
  523. F_CPU ?= 20000000
  524. # Gen7 v1.4
  525. else ifeq ($(HARDWARE_MOTHERBOARD),1607)
  526. HARDWARE_VARIANT ?= Gen7
  527. MCU ?= atmega1284p
  528. PROG_MCU ?= m1284p
  529. F_CPU ?= 20000000
  530. # Alpha OMCA board
  531. else ifeq ($(HARDWARE_MOTHERBOARD),1608)
  532. HARDWARE_VARIANT ?= SanguinoA
  533. MCU ?= atmega644
  534. PROG_MCU ?= m644
  535. # Final OMCA board
  536. else ifeq ($(HARDWARE_MOTHERBOARD),1609)
  537. HARDWARE_VARIANT ?= Sanguino
  538. MCU ?= atmega644p
  539. PROG_MCU ?= m644p
  540. # Sethi 3D_1
  541. else ifeq ($(HARDWARE_MOTHERBOARD),1610)
  542. HARDWARE_VARIANT ?= Sanguino
  543. MCU ?= atmega644p
  544. PROG_MCU ?= m644p
  545. #
  546. # Teensyduino - AT90USB1286, AT90USB1286P
  547. #
  548. # Teensylu
  549. else ifeq ($(HARDWARE_MOTHERBOARD),1700)
  550. HARDWARE_VARIANT ?= Teensy
  551. MCU ?= at90usb1286
  552. PROG_MCU ?= usb1286
  553. # Printrboard (AT90USB1286)
  554. else ifeq ($(HARDWARE_MOTHERBOARD),1701)
  555. HARDWARE_VARIANT ?= Teensy
  556. MCU ?= at90usb1286
  557. PROG_MCU ?= usb1286
  558. # Printrboard Revision F (AT90USB1286)
  559. else ifeq ($(HARDWARE_MOTHERBOARD),1702)
  560. HARDWARE_VARIANT ?= Teensy
  561. MCU ?= at90usb1286
  562. PROG_MCU ?= usb1286
  563. # Brainwave (AT90USB646)
  564. else ifeq ($(HARDWARE_MOTHERBOARD),1703)
  565. HARDWARE_VARIANT ?= Teensy
  566. MCU ?= at90usb646
  567. PROG_MCU ?= usb646
  568. # Brainwave Pro (AT90USB1286)
  569. else ifeq ($(HARDWARE_MOTHERBOARD),1704)
  570. HARDWARE_VARIANT ?= Teensy
  571. MCU ?= at90usb1286
  572. PROG_MCU ?= usb1286
  573. # SAV Mk-I (AT90USB1286)
  574. else ifeq ($(HARDWARE_MOTHERBOARD),1705)
  575. HARDWARE_VARIANT ?= Teensy
  576. MCU ?= at90usb1286
  577. PROG_MCU ?= usb1286
  578. # Teensy++2.0 (AT90USB1286)
  579. else ifeq ($(HARDWARE_MOTHERBOARD),1706)
  580. HARDWARE_VARIANT ?= Teensy
  581. MCU ?= at90usb1286
  582. PROG_MCU ?= usb1286
  583. # 5DPrint D8 Driver Board
  584. else ifeq ($(HARDWARE_MOTHERBOARD),1707)
  585. HARDWARE_VARIANT ?= Teensy
  586. MCU ?= at90usb1286
  587. PROG_MCU ?= usb1286
  588. # UltiMachine Archim1 (with DRV8825 drivers)
  589. else ifeq ($(HARDWARE_MOTHERBOARD),3023)
  590. HARDWARE_VARIANT ?= archim
  591. MCPU = cortex-m3
  592. F_CPU = 84000000
  593. IS_MCU = 0
  594. # UltiMachine Archim2 (with TMC2130 drivers)
  595. else ifeq ($(HARDWARE_MOTHERBOARD),3024)
  596. HARDWARE_VARIANT ?= archim
  597. MCPU = cortex-m3
  598. F_CPU = 84000000
  599. IS_MCU = 0
  600. endif
  601. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  602. # if you are setting this to something other than 16MHz
  603. # Do not put the UL suffix, it's done later on.
  604. # Set to 16Mhz if not yet set.
  605. F_CPU ?= 16000000
  606. # Set to microcontroller if IS_MCU not yet set
  607. IS_MCU ?= 1
  608. ifeq ($(IS_MCU),1)
  609. # Set to arduino, ATmega2560 if not yet set.
  610. HARDWARE_VARIANT ?= arduino
  611. MCU ?= atmega2560
  612. PROG_MCU ?= m2560
  613. TOOL_PREFIX = avr
  614. MCU_FLAGS = -mmcu=$(MCU)
  615. SIZE_FLAGS = --mcu=$(MCU) -C
  616. else
  617. TOOL_PREFIX = arm-none-eabi
  618. CPU_FLAGS = -mthumb -mcpu=$(MCPU)
  619. SIZE_FLAGS = -A
  620. endif
  621. # Arduino contained the main source code for the Arduino
  622. # Libraries, the "hardware variant" are for boards
  623. # that derives from that, and their source are present in
  624. # the main Marlin source directory
  625. TARGET = $(notdir $(CURDIR))
  626. # VPATH tells make to look into these directory for source files,
  627. # there is no need to specify explicit pathnames as long as the
  628. # directory is added here
  629. # The Makefile for previous versions of Marlin used VPATH for all
  630. # source files, but for Marlin 2.0, we use VPATH only for arduino
  631. # library files.
  632. VPATH = .
  633. VPATH += $(BUILD_DIR)
  634. VPATH += $(HARDWARE_SRC)
  635. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
  636. # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
  637. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  638. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  639. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/arduino/avr/1.8.6/libraries/SPI/src
  640. endif
  641. ifeq ($(IS_MCU),1)
  642. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/arduino/avr/1.8.6/cores/arduino
  643. # Old libraries (avr-core 1.6.21 < / Arduino < 1.6.8)
  644. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  645. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SoftwareSerial
  646. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  647. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/arduino/avr/1.8.6/libraries/SPI/src
  648. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/arduino/avr/1.8.6/libraries/SoftwareSerial/src
  649. endif
  650. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  651. ifeq ($(LIQUID_TWI2), 1)
  652. WIRE = 1
  653. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  654. endif
  655. ifeq ($(WIRE), 1)
  656. # Old libraries (avr-core 1.6.21 / Arduino < 1.6.8)
  657. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire
  658. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/Wire/utility
  659. # New libraries (avr-core >= 1.6.21 / Arduino >= 1.6.8)
  660. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src
  661. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/avr/1.8.6/libraries/Wire/src/utility
  662. endif
  663. ifeq ($(NEOPIXEL), 1)
  664. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Adafruit_NeoPixel
  665. endif
  666. ifeq ($(U8GLIB), 1)
  667. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib-HAL
  668. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib-HAL/src
  669. # VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
  670. # VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/src
  671. endif
  672. ifeq ($(TMC), 1)
  673. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src
  674. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMCStepper/src/source
  675. endif
  676. ifeq ($(HARDWARE_VARIANT), arduino)
  677. HARDWARE_SUB_VARIANT ?= mega
  678. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/avr/1.8.6/variants/$(HARDWARE_SUB_VARIANT)
  679. else ifeq ($(HARDWARE_VARIANT), Sanguino)
  680. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/avr/1.8.6/variants/sanguino
  681. else ifeq ($(HARDWARE_VARIANT), archim)
  682. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/libsam
  683. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/CMSIS/Include/
  684. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/system/CMSIS/Device/ATMEL/
  685. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino
  686. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/avr
  687. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/cores/arduino/USB
  688. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/Wire/src
  689. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/SPI/src
  690. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/libraries/U8glib/src/clib
  691. VPATH += $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim
  692. LDSCRIPT = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/linker_scripts/gcc/flash.ld
  693. LDLIBS = $(ARDUINO_INSTALL_DIR)/packages/ultimachine/hardware/sam/1.6.9-b/variants/archim/libsam_sam3x8e_gcc_rel.a
  694. else
  695. HARDWARE_SUB_VARIANT ?= standard
  696. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/avr/1.8.6/variants/$(HARDWARE_SUB_VARIANT)
  697. endif
  698. LIB_SRC = wiring.c \
  699. wiring_analog.c wiring_digital.c \
  700. wiring_shift.c WInterrupts.c hooks.c
  701. ifeq ($(HARDWARE_VARIANT), archim)
  702. LIB_ASRC += wiring_pulse_asm.S
  703. else
  704. LIB_SRC += wiring_pulse.c
  705. endif
  706. ifeq ($(HARDWARE_VARIANT), Teensy)
  707. LIB_SRC = wiring.c
  708. VPATH += $(ARDUINO_INSTALL_DIR)/packages/arduino/hardware/teensy/cores/teensy
  709. endif
  710. LIB_CXXSRC = WMath.cpp WString.cpp Print.cpp SPI.cpp
  711. ifeq ($(NEOPIXEL), 1)
  712. LIB_CXXSRC += Adafruit_NeoPixel.cpp
  713. endif
  714. ifeq ($(LIQUID_TWI2), 0)
  715. LIB_CXXSRC += LiquidCrystal.cpp
  716. else
  717. LIB_SRC += twi.c
  718. LIB_CXXSRC += Wire.cpp LiquidTWI2.cpp
  719. endif
  720. ifeq ($(WIRE), 1)
  721. LIB_SRC += twi.c
  722. LIB_CXXSRC += Wire.cpp
  723. endif
  724. ifeq ($(TONE), 1)
  725. LIB_CXXSRC += Tone.cpp
  726. endif
  727. ifeq ($(U8GLIB), 1)
  728. LIB_CXXSRC += U8glib.cpp
  729. LIB_SRC += u8g_ll_api.c u8g_bitmap.c u8g_clip.c u8g_com_null.c u8g_delay.c \
  730. u8g_page.c u8g_pb.c u8g_pb16h1.c u8g_rect.c u8g_state.c u8g_font.c \
  731. u8g_font_6x13.c u8g_font_04b_03.c u8g_font_5x8.c
  732. endif
  733. ifeq ($(TMC), 1)
  734. LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp \
  735. CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp \
  736. DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp \
  737. SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp \
  738. TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
  739. endif
  740. ifeq ($(RELOC_WORKAROUND), 1)
  741. LD_PREFIX=-nodefaultlibs
  742. LD_SUFFIX=-lm -lgcc -lc -lgcc
  743. endif
  744. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  745. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  746. LIB_CXXSRC += main.cpp
  747. else
  748. LIB_SRC += pins_arduino.c main.c
  749. endif
  750. FORMAT = ihex
  751. # Name of this Makefile (used for "make depend").
  752. MAKEFILE = Makefile
  753. # Debugging format.
  754. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  755. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  756. DEBUG = stabs
  757. OPT = s
  758. DEFINES ?=
  759. # Program settings
  760. CC = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-gcc
  761. CXX = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-g++
  762. OBJCOPY = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objcopy
  763. OBJDUMP = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-objdump
  764. AR = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-ar
  765. SIZE = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-size
  766. NM = $(AVR_TOOLS_PATH)$(TOOL_PREFIX)-nm
  767. AVRDUDE = avrdude
  768. REMOVE = rm -f
  769. MV = mv -f
  770. # Place -D or -U options here
  771. CDEFS = -DF_CPU=$(F_CPU)UL ${addprefix -D , $(DEFINES)} -DARDUINO=$(ARDUINO_VERSION)
  772. CXXDEFS = $(CDEFS)
  773. ifeq ($(HARDWARE_VARIANT), Teensy)
  774. CDEFS += -DUSB_SERIAL
  775. LIB_SRC += usb.c pins_teensy.c
  776. LIB_CXXSRC += usb_api.cpp
  777. else ifeq ($(HARDWARE_VARIANT), archim)
  778. CDEFS += -DARDUINO_SAM_ARCHIM -DARDUINO_ARCH_SAM -D__SAM3X8E__
  779. CDEFS += -DUSB_VID=0x27B1 -DUSB_PID=0x0001 -DUSBCON
  780. CDEFS += '-DUSB_MANUFACTURER="UltiMachine"' '-DUSB_PRODUCT_STRING="Archim"'
  781. LIB_CXXSRC += variant.cpp IPAddress.cpp Reset.cpp RingBuffer.cpp Stream.cpp \
  782. UARTClass.cpp USARTClass.cpp abi.cpp new.cpp watchdog.cpp CDC.cpp \
  783. PluggableUSB.cpp USBCore.cpp
  784. LIB_SRC += cortex_handlers.c iar_calls_sam3.c syscalls_sam3.c dtostrf.c itoa.c
  785. ifeq ($(U8GLIB), 1)
  786. LIB_SRC += u8g_com_api.c u8g_pb32h1.c
  787. endif
  788. endif
  789. # Add all the source directories as include directories too
  790. CINCS = ${addprefix -I ,${VPATH}}
  791. CXXINCS = ${addprefix -I ,${VPATH}}
  792. # Silence warnings for library code (won't work for .h files, unfortunately)
  793. LIBWARN = -w -Wno-packed-bitfield-compat
  794. # Compiler flag to set the C/CPP Standard level.
  795. CSTANDARD = -std=gnu99
  796. CXXSTANDARD = -std=gnu++11
  797. CDEBUG = -g$(DEBUG)
  798. CWARN = -Wall -Wstrict-prototypes -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
  799. CXXWARN = -Wall -Wno-packed-bitfield-compat -Wno-pragmas -Wunused-parameter
  800. CTUNING = -fsigned-char -funsigned-bitfields -fno-exceptions \
  801. -fshort-enums -ffunction-sections -fdata-sections
  802. ifneq ($(HARDWARE_MOTHERBOARD),)
  803. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  804. endif
  805. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  806. CXXEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics -fno-rtti
  807. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  808. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) $(CXXEXTRA) $(CTUNING) $(CXXSTANDARD)
  809. ASFLAGS := $(CDEFS)
  810. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  811. ifeq ($(HARDWARE_VARIANT), archim)
  812. LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
  813. LD_SUFFIX = $(LDLIBS)
  814. LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty
  815. LDFLAGS += -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
  816. else
  817. LD_PREFIX = -Wl,--gc-sections,--relax
  818. LDFLAGS = -lm
  819. CTUNING += -flto
  820. endif
  821. # Programming support using avrdude. Settings and variables.
  822. AVRDUDE_PORT = $(UPLOAD_PORT)
  823. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  824. ifeq ($(shell uname -s), Linux)
  825. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  826. else
  827. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf
  828. endif
  829. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  830. -p$(PROG_MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  831. -b$(UPLOAD_RATE)
  832. # Since Marlin 2.0, the source files may be distributed into several
  833. # different directories, so it is necessary to find them recursively
  834. SRC = $(shell find src -name '*.c' -type f)
  835. CXXSRC = $(shell find src -name '*.cpp' -type f)
  836. # Define all object files.
  837. OBJ = ${patsubst %.c, $(BUILD_DIR)/arduino/%.o, ${LIB_SRC}}
  838. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/arduino/%.o, ${LIB_CXXSRC}}
  839. OBJ += ${patsubst %.S, $(BUILD_DIR)/arduino/%.o, ${LIB_ASRC}}
  840. OBJ += ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  841. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  842. # Define all listing files.
  843. LST = $(LIB_ASRC:.S=.lst) $(LIB_CXXSRC:.cpp=.lst) $(LIB_SRC:.c=.lst)
  844. # Combine all necessary flags and optional flags.
  845. # Add target processor to flags.
  846. ALL_CFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CFLAGS) -I.
  847. ALL_CXXFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(CXXFLAGS)
  848. ALL_ASFLAGS = $(MCU_FLAGS) $(CPU_FLAGS) $(ASFLAGS) -x assembler-with-cpp
  849. # set V=1 (eg, "make V=1") to print the full commands etc.
  850. ifneq ($V,1)
  851. Pecho=@echo
  852. P=@
  853. else
  854. Pecho=@:
  855. P=
  856. endif
  857. # Create required build hierarchy if it does not exist
  858. $(shell mkdir -p $(dir $(OBJ)))
  859. # Default target.
  860. all: sizeafter
  861. build: elf hex bin
  862. elf: $(BUILD_DIR)/$(TARGET).elf
  863. bin: $(BUILD_DIR)/$(TARGET).bin
  864. hex: $(BUILD_DIR)/$(TARGET).hex
  865. eep: $(BUILD_DIR)/$(TARGET).eep
  866. lss: $(BUILD_DIR)/$(TARGET).lss
  867. sym: $(BUILD_DIR)/$(TARGET).sym
  868. # Program the device.
  869. # Do not try to reset an Arduino if it's not one
  870. upload: $(BUILD_DIR)/$(TARGET).hex
  871. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  872. stty hup < $(UPLOAD_PORT); true
  873. endif
  874. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  875. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  876. stty -hup < $(UPLOAD_PORT); true
  877. endif
  878. # Display size of file.
  879. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  880. ELFSIZE = $(SIZE) $(SIZE_FLAGS) $(BUILD_DIR)/$(TARGET).elf; \
  881. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  882. sizebefore:
  883. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  884. sizeafter: build
  885. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  886. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  887. COFFCONVERT=$(OBJCOPY) --debugging \
  888. --change-section-address .data-0x800000 \
  889. --change-section-address .bss-0x800000 \
  890. --change-section-address .noinit-0x800000 \
  891. --change-section-address .eeprom-0x810000
  892. coff: $(BUILD_DIR)/$(TARGET).elf
  893. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  894. extcoff: $(TARGET).elf
  895. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  896. .SUFFIXES: .elf .hex .eep .lss .sym .bin
  897. .PRECIOUS: .o
  898. .elf.hex:
  899. $(Pecho) " COPY $@"
  900. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  901. .elf.bin:
  902. $(Pecho) " COPY $@"
  903. $P $(OBJCOPY) -O binary -R .eeprom $< $@
  904. .elf.eep:
  905. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  906. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  907. # Create extended listing file from ELF output file.
  908. .elf.lss:
  909. $(OBJDUMP) -h -S $< > $@
  910. # Create a symbol table from ELF output file.
  911. .elf.sym:
  912. $(NM) -n $< > $@
  913. # Link: create ELF output file from library.
  914. LDFLAGS+= -Wl,-V
  915. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  916. $(Pecho) " CXX $@"
  917. $P $(CXX) $(LD_PREFIX) $(ALL_CXXFLAGS) -o $@ -L. $(OBJ) $(LDFLAGS) $(LD_SUFFIX)
  918. # Object files that were found in "src" will be stored in $(BUILD_DIR)
  919. # in directories that mirror the structure of "src"
  920. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  921. $(Pecho) " CC $<"
  922. $P $(CC) -MMD -c $(ALL_CFLAGS) $(CWARN) $< -o $@
  923. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  924. $(Pecho) " CXX $<"
  925. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(CXXWARN) $< -o $@
  926. # Object files for Arduino libs will be created in $(BUILD_DIR)/arduino
  927. $(BUILD_DIR)/arduino/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  928. $(Pecho) " CC $<"
  929. $P $(CC) -MMD -c $(ALL_CFLAGS) $(LIBWARN) $< -o $@
  930. $(BUILD_DIR)/arduino/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  931. $(Pecho) " CXX $<"
  932. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $(LIBWARN) $< -o $@
  933. $(BUILD_DIR)/arduino/%.o: %.S $(MAKEFILE)
  934. $(Pecho) " CXX $<"
  935. $P $(CXX) -MMD -c $(ALL_ASFLAGS) $< -o $@
  936. # Target: clean project.
  937. clean:
  938. $(Pecho) " RMDIR $(BUILD_DIR)/"
  939. $P rm -rf $(BUILD_DIR)
  940. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  941. # Automatically include the dependency files created by gcc
  942. -include ${patsubst %.o, %.d, ${OBJ}}