My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. MCU ?= atmega328p
  87. #Gen6
  88. else ifeq ($(HARDWARE_MOTHERBOARD),5)
  89. HARDWARE_VARIANT ?= Gen6
  90. MCU ?= atmega664p
  91. else ifeq ($(HARDWARE_MOTHERBOARD),51)
  92. HARDWARE_VARIANT ?= Gen6
  93. MCU ?= atmega664p
  94. #Sanguinololu
  95. else ifeq ($(HARDWARE_MOTHERBOARD),6)
  96. HARDWARE_VARIANT ?= Sanguino
  97. MCU ?= atmega1284p
  98. else ifeq ($(HARDWARE_MOTHERBOARD),62)
  99. HARDWARE_VARIANT ?= Sanguino
  100. MCU ?= atmega1284p
  101. else ifeq ($(HARDWARE_MOTHERBOARD),63)
  102. HARDWARE_VARIANT ?= Sanguino
  103. MCU ?= atmega1284p
  104. #Ultimaker
  105. else ifeq ($(HARDWARE_MOTHERBOARD),7)
  106. HARDWARE_VARIANT ?= arduino
  107. MCU ?= atmega2560
  108. else ifeq ($(HARDWARE_MOTHERBOARD),71)
  109. HARDWARE_VARIANT ?= arduino
  110. MCU ?= atmega1280
  111. #Teensylu
  112. else ifeq ($(HARDWARE_MOTHERBOARD),8)
  113. HARDWARE_VARIANT ?= Teensyduino
  114. MCU ?= at90usb1286
  115. #Gen3+
  116. else ifeq ($(HARDWARE_MOTHERBOARD),9)
  117. HARDWARE_VARIANT ?= Sanguino
  118. MCU ?= atmega644p
  119. #Megatronics
  120. else ifeq ($(HARDWARE_MOTHERBOARD),70)
  121. HARDWARE_VARIANT ?= arduino
  122. MCU ?= atmega2560
  123. #Alpha OMCA board
  124. else ifeq ($(HARDWARE_MOTHERBOARD),90)
  125. HARDWARE_VARIANT ?= SanguinoA
  126. MCU ?= atmega644
  127. #Final OMCA board
  128. else ifeq ($(HARDWARE_MOTHERBOARD),91)
  129. HARDWARE_VARIANT ?= Sanguino
  130. MCU ?= atmega644p
  131. endif
  132. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  133. # if you are setting this to something other than 16MHz
  134. # Set to 16Mhz if not yet set.
  135. F_CPU ?= 16000000
  136. # Arduino containd the main source code for the Arduino
  137. # Libraries, the "hardware variant" are for boards
  138. # that derives from that, and their source are present in
  139. # the main Marlin source directory
  140. ARDUINO = $(ARDUINO_INSTALL_DIR)/hardware/arduino/cores/arduino
  141. ifeq (${HARDWARE_VARIANT}, arduino)
  142. HARDWARE_SRC = $(ARDUINO)
  143. else
  144. HARDWARE_SRC = $(HARDWARE_VARIANT)/cores/arduino
  145. endif
  146. TARGET = $(notdir $(CURDIR))
  147. # VPATH tells make to look into these directory for source files,
  148. # there is no need to specify explicit pathnames as long as the
  149. # directory is added here
  150. VPATH = .
  151. VPATH += $(BUILD_DIR)
  152. VPATH += $(HARDWARE_SRC)
  153. VPATH += $(ARDUINO)
  154. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal
  155. #TODO: Add the path to the hardware variant when using Arduino >= 100, and adjust the files required for compilation.
  156. #VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/variants/mega
  157. SRC = pins_arduino.c main.c wiring.c \
  158. wiring_analog.c wiring_digital.c \
  159. wiring_pulse.c \
  160. wiring_shift.c WInterrupts.c
  161. CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
  162. MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \
  163. SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \
  164. stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp
  165. #CXXSRC += LiquidCrystal.cpp ultralcd.cpp
  166. #CXXSRC += ultralcd.cpp
  167. FORMAT = ihex
  168. # Name of this Makefile (used for "make depend").
  169. MAKEFILE = Makefile
  170. # Debugging format.
  171. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  172. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  173. DEBUG = stabs
  174. OPT = s
  175. # Place -D or -U options here
  176. CDEFS = -DF_CPU=$(F_CPU)
  177. CXXDEFS = -DF_CPU=$(F_CPU)
  178. # Add all the source directories as include directories too
  179. CINCS = ${addprefix -I ,${VPATH}}
  180. CXXINCS = ${addprefix -I ,${VPATH}}
  181. # Compiler flag to set the C Standard level.
  182. # c89 - "ANSI" C
  183. # gnu89 - c89 plus GCC extensions
  184. # c99 - ISO C99 standard (not yet fully implemented)
  185. # gnu99 - c99 plus GCC extensions
  186. #CSTANDARD = -std=gnu99
  187. CDEBUG = -g$(DEBUG)
  188. CWARN = -Wall -Wstrict-prototypes
  189. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  190. -fshort-enums -w -ffunction-sections -fdata-sections \
  191. -DARDUINO=$(ARDUINO_VERSION)
  192. ifneq ($(HARDWARE_MOTHERBOARD),)
  193. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  194. endif
  195. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  196. CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
  197. CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
  198. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  199. LDFLAGS = -lm
  200. # Programming support using avrdude. Settings and variables.
  201. AVRDUDE_PORT = $(UPLOAD_PORT)
  202. AVRDUDE_WRITE_FLASH = -U flash:w:$(BUILD_DIR)/$(TARGET).hex:i
  203. AVRDUDE_FLAGS = -D -C $(ARDUINO_INSTALL_DIR)/hardware/tools/avrdude.conf \
  204. -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
  205. -b $(UPLOAD_RATE)
  206. # Program settings
  207. CC = $(AVR_TOOLS_PATH)avr-gcc
  208. CXX = $(AVR_TOOLS_PATH)avr-g++
  209. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  210. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  211. AR = $(AVR_TOOLS_PATH)avr-ar
  212. SIZE = $(AVR_TOOLS_PATH)avr-size
  213. NM = $(AVR_TOOLS_PATH)avr-nm
  214. AVRDUDE = avrdude
  215. REMOVE = rm -f
  216. MV = mv -f
  217. # Define all object files.
  218. OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  219. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  220. OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}
  221. # Define all listing files.
  222. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  223. # Combine all necessary flags and optional flags.
  224. # Add target processor to flags.
  225. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  226. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  227. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  228. # set V=1 (eg, "make V=1") to print the full commands etc.
  229. ifneq ($V,1)
  230. Pecho=@echo
  231. P=@
  232. else
  233. Pecho=@:
  234. P=
  235. endif
  236. # Default target.
  237. all: sizeafter
  238. build: $(BUILD_DIR) elf hex
  239. # Creates the object directory
  240. $(BUILD_DIR):
  241. $P mkdir -p $(BUILD_DIR)
  242. elf: $(BUILD_DIR)/$(TARGET).elf
  243. hex: $(BUILD_DIR)/$(TARGET).hex
  244. eep: $(BUILD_DIR)/$(TARGET).eep
  245. lss: $(BUILD_DIR)/$(TARGET).lss
  246. sym: $(BUILD_DIR)/$(TARGET).sym
  247. # Program the device.
  248. # Do not try to reset an arduino if it's not one
  249. upload: $(BUILD_DIR)/$(TARGET).hex
  250. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  251. stty hup < $(UPLOAD_PORT); true
  252. endif
  253. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  254. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  255. stty -hup < $(UPLOAD_PORT); true
  256. endif
  257. # Display size of file.
  258. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  259. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  260. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  261. sizebefore:
  262. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  263. sizeafter: build
  264. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  265. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  266. COFFCONVERT=$(OBJCOPY) --debugging \
  267. --change-section-address .data-0x800000 \
  268. --change-section-address .bss-0x800000 \
  269. --change-section-address .noinit-0x800000 \
  270. --change-section-address .eeprom-0x810000
  271. coff: $(BUILD_DIR)/$(TARGET).elf
  272. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  273. extcoff: $(TARGET).elf
  274. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  275. .SUFFIXES: .elf .hex .eep .lss .sym
  276. .PRECIOUS: .o
  277. .elf.hex:
  278. $(Pecho) " COPY $@"
  279. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  280. .elf.eep:
  281. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  282. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  283. # Create extended listing file from ELF output file.
  284. .elf.lss:
  285. $(OBJDUMP) -h -S $< > $@
  286. # Create a symbol table from ELF output file.
  287. .elf.sym:
  288. $(NM) -n $< > $@
  289. # Link: create ELF output file from library.
  290. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  291. $(Pecho) " CXX $@"
  292. $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS)
  293. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  294. $(Pecho) " CC $@"
  295. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  296. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  297. $(Pecho) " CXX $@"
  298. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  299. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  300. $(Pecho) " CXX $@"
  301. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  302. # Target: clean project.
  303. clean:
  304. $(Pecho) " RM $(BUILD_DIR)/*"
  305. $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
  306. $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
  307. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  308. $(Pecho) " RMDIR $(BUILD_DIR)/"
  309. $P rm -rf $(BUILD_DIR)
  310. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  311. # Automaticaly include the dependency files created by gcc
  312. -include ${wildcard $(BUILD_DIR)/*.d}