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 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. # Sprinter Arduino Project Makefile
  2. #
  3. # Makefile Based on:
  4. # Arduino 0011 Makefile
  5. # Arduino adaptation by mellis, eighthave, oli.keller
  6. #
  7. # This has been tested with Arduino 0022.
  8. #
  9. # This makefile allows you to build sketches from the command line
  10. # without the Arduino environment (or Java).
  11. #
  12. # Detailed instructions for using the makefile:
  13. #
  14. # 1. Modify the line containg "INSTALL_DIR" to point to the directory that
  15. # contains the Arduino installation (for example, under Mac OS X, this
  16. # might be /Applications/arduino-0012).
  17. #
  18. # 2. Modify the line containing "PORT" to refer to the filename
  19. # representing the USB or serial connection to your Arduino board
  20. # (e.g. PORT = /dev/tty.USB0). If the exact name of this file
  21. # changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
  22. #
  23. # 3. Set the line containing "MCU" to match your board's processor.
  24. # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
  25. # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
  26. # change F_CPU to 8000000. If you are using Gen7 electronics, you
  27. # probably need to use 20000000. Either way, you must regenerate
  28. # the speed lookup table with create_speed_lookuptable.py.
  29. #
  30. # 4. Type "make" and press enter to compile/verify your program.
  31. #
  32. # 5. Type "make upload", reset your Arduino board, and press enter to
  33. # upload your program to the Arduino board.
  34. #
  35. # $Id$
  36. #For "old" Arduino Mega
  37. #MCU = atmega1280
  38. #For Arduino Mega2560
  39. #MCU = atmega2560
  40. #For Sanguinololu
  41. MCU = atmega644p
  42. # Here you select "arduino", "Sanguino", "Gen7", ...
  43. HARDWARE_VARIANT = Sanguino
  44. # This defined the board you are compiling for
  45. HARDWARE_MOTHERBOARD = 91
  46. # Arduino source install directory
  47. INSTALL_DIR = ../../arduino-0022
  48. # Arduino containd the main source code for the Arduino
  49. # Libraries, the "hardware variant" are for boards
  50. # that derives from that, and their source are present in
  51. # the main Marlin source directory
  52. ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
  53. ifeq (${HARDWARE_VARIANT}, arduino)
  54. HARDWARE_SRC= $(ARDUINO)
  55. else
  56. HARDWARE_SRC= $(HARDWARE_VARIANT)/cores/arduino
  57. endif
  58. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  59. # if you are setting this to something other than 16MHz
  60. F_CPU = 16000000
  61. UPLOAD_RATE = 115200
  62. AVRDUDE_PROGRAMMER = arduino
  63. PORT = /dev/arduino
  64. TARGET = $(notdir $(CURDIR))
  65. # VPATH tells make to look into these directory for source files,
  66. # there is no need to specify explicit pathnames as long as the
  67. # directory is added here
  68. VPATH = .
  69. VPATH += applet
  70. VPATH += $(HARDWARE_SRC)
  71. VPATH += $(ARDUINO)
  72. VPATH += $(INSTALL_DIR)/libraries/LiquidCrystal
  73. ############################################################################
  74. # Below here nothing should be changed...
  75. AVR_TOOLS_PATH =
  76. SRC = pins_arduino.c wiring.c \
  77. wiring_analog.c wiring_digital.c \
  78. wiring_pulse.c \
  79. wiring_shift.c WInterrupts.c
  80. CXXSRC = WMath.cpp WString.cpp Print.cpp \
  81. Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp \
  82. SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp \
  83. planner.cpp stepper.cpp temperature.cpp cardreader.cpp
  84. #CXXSRC += LiquidCrystal.cpp ultralcd.cpp
  85. #CXXSRC += ultralcd.cpp
  86. FORMAT = ihex
  87. # Name of this Makefile (used for "make depend").
  88. MAKEFILE = Makefile
  89. # Debugging format.
  90. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  91. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  92. DEBUG = stabs
  93. OPT = s
  94. # Place -D or -U options here
  95. CDEFS = -DF_CPU=$(F_CPU)
  96. CXXDEFS = -DF_CPU=$(F_CPU)
  97. # Add all the source directories as include directories too
  98. CINCS = ${addprefix -I ,${VPATH}}
  99. CXXINCS = ${addprefix -I ,${VPATH}}
  100. # Compiler flag to set the C Standard level.
  101. # c89 - "ANSI" C
  102. # gnu89 - c89 plus GCC extensions
  103. # c99 - ISO C99 standard (not yet fully implemented)
  104. # gnu99 - c99 plus GCC extensions
  105. #CSTANDARD = -std=gnu99
  106. CDEBUG = -g$(DEBUG)
  107. CWARN = -Wall -Wstrict-prototypes
  108. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  109. -fshort-enums -w -ffunction-sections -fdata-sections \
  110. -DARDUINO=22
  111. ifneq (${HARDWARE_MOTHERBOARD},)
  112. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  113. endif
  114. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  115. CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
  116. CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
  117. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  118. LDFLAGS = -lm
  119. # Programming support using avrdude. Settings and variables.
  120. AVRDUDE_PORT = $(PORT)
  121. AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
  122. AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
  123. -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
  124. -b $(UPLOAD_RATE)
  125. # Program settings
  126. CC = $(AVR_TOOLS_PATH)avr-gcc
  127. CXX = $(AVR_TOOLS_PATH)avr-g++
  128. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  129. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  130. AR = $(AVR_TOOLS_PATH)avr-ar
  131. SIZE = $(AVR_TOOLS_PATH)avr-size
  132. NM = $(AVR_TOOLS_PATH)avr-nm
  133. AVRDUDE = avrdude
  134. REMOVE = rm -f
  135. MV = mv -f
  136. # Define all object files.
  137. OBJ = ${patsubst %.c, applet/%.o, ${SRC}}
  138. OBJ += ${patsubst %.cpp, applet/%.o, ${CXXSRC}}
  139. OBJ += ${patsubst %.S, applet/%.o, ${ASRC}}
  140. # Define all listing files.
  141. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  142. # Combine all necessary flags and optional flags.
  143. # Add target processor to flags.
  144. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  145. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  146. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  147. # set V=1 (eg, "make V=1") to print the full commands etc.
  148. ifneq ($V,1)
  149. Pecho=@echo
  150. P=@
  151. else
  152. Pecho=@:
  153. P=
  154. endif
  155. # Default target.
  156. all: sizeafter
  157. build: applet elf hex
  158. # Creates the object directory
  159. applet:
  160. $P mkdir -p applet
  161. # the .cpp for Marlin depends on the .pde
  162. #applet/$(TARGET).cpp: $(TARGET).pde
  163. # ..and the .o depends from the .cpp
  164. #applet/%.o: applet/%.cpp
  165. applet/%.cpp: %.pde $(MAKEFILE)
  166. # Here is the "preprocessing".
  167. # It creates a .cpp file based with the same name as the .pde file.
  168. # On top of the new .cpp file comes the WProgram.h header.
  169. $(Pecho) " WR $@"
  170. $P echo '#include "WProgram.h"' > $@
  171. $P echo '#include "$<"' >>$@
  172. $P echo '#include "$(ARDUINO)/main.cpp"' >> $@
  173. elf: applet/$(TARGET).elf
  174. hex: applet/$(TARGET).hex
  175. eep: applet/$(TARGET).eep
  176. lss: applet/$(TARGET).lss
  177. sym: applet/$(TARGET).sym
  178. # Program the device.
  179. # Do not try to reset an arduino if it's not one
  180. upload: applet/$(TARGET).hex
  181. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  182. stty hup < $(PORT); true
  183. endif
  184. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  185. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  186. stty -hup < $(PORT); true
  187. endif
  188. # Display size of file.
  189. HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
  190. ELFSIZE = $(SIZE) --mcu=$(MCU) -C applet/$(TARGET).elf; \
  191. $(SIZE) applet/$(TARGET).elf
  192. sizebefore:
  193. $P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  194. sizeafter: build
  195. $P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  196. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  197. COFFCONVERT=$(OBJCOPY) --debugging \
  198. --change-section-address .data-0x800000 \
  199. --change-section-address .bss-0x800000 \
  200. --change-section-address .noinit-0x800000 \
  201. --change-section-address .eeprom-0x810000
  202. coff: applet/$(TARGET).elf
  203. $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
  204. extcoff: $(TARGET).elf
  205. $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
  206. .SUFFIXES: .elf .hex .eep .lss .sym
  207. .PRECIOUS: .o
  208. .elf.hex:
  209. $(Pecho) " COPY $@"
  210. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  211. .elf.eep:
  212. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  213. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  214. # Create extended listing file from ELF output file.
  215. .elf.lss:
  216. $(OBJDUMP) -h -S $< > $@
  217. # Create a symbol table from ELF output file.
  218. .elf.sym:
  219. $(NM) -n $< > $@
  220. # Link: create ELF output file from library.
  221. applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
  222. $(Pecho) " CXX $@"
  223. $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
  224. applet/core.a: $(OBJ)
  225. $P for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
  226. applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  227. $(Pecho) " CC $@"
  228. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  229. applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  230. $(Pecho) " CXX $@"
  231. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  232. # Target: clean project.
  233. clean:
  234. $(Pecho) " RM applet/*"
  235. $P $(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
  236. applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
  237. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  238. $(Pecho) " RMDIR applet/"
  239. $P rm -rf applet
  240. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
  241. # Automaticaly include the dependency files created by gcc
  242. -include ${wildcard applet/*.d}