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

Makefile 14KB

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