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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. #Arduino install directory
  43. INSTALL_DIR = ../../arduino-0022/
  44. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  45. # if you are setting this to something other than 16MHz
  46. F_CPU = 16000000
  47. UPLOAD_RATE = 115200
  48. AVRDUDE_PROGRAMMER = arduino
  49. PORT = /dev/arduino
  50. TARGET = $(notdir $(CURDIR))
  51. ############################################################################
  52. # Below here nothing should be changed...
  53. ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
  54. AVR_TOOLS_PATH =
  55. SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
  56. $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
  57. $(ARDUINO)/wiring_pulse.c \
  58. $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
  59. CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
  60. $(ARDUINO)/Print.cpp applet/Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
  61. FORMAT = ihex
  62. # Name of this Makefile (used for "make depend").
  63. MAKEFILE = Makefile
  64. # Debugging format.
  65. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  66. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  67. DEBUG = stabs
  68. OPT = s
  69. # Place -D or -U options here
  70. CDEFS = -DF_CPU=$(F_CPU)
  71. CXXDEFS = -DF_CPU=$(F_CPU)
  72. # Place -I options here
  73. CINCS = -I$(ARDUINO)
  74. CXXINCS = -I$(ARDUINO)
  75. # Compiler flag to set the C Standard level.
  76. # c89 - "ANSI" C
  77. # gnu89 - c89 plus GCC extensions
  78. # c99 - ISO C99 standard (not yet fully implemented)
  79. # gnu99 - c99 plus GCC extensions
  80. #CSTANDARD = -std=gnu99
  81. CDEBUG = -g$(DEBUG)
  82. CWARN = -Wall -Wstrict-prototypes
  83. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
  84. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  85. CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
  86. CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
  87. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  88. LDFLAGS = -lm
  89. # Programming support using avrdude. Settings and variables.
  90. AVRDUDE_PORT = $(PORT)
  91. AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
  92. AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
  93. -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
  94. -b $(UPLOAD_RATE)
  95. # Program settings
  96. CC = $(AVR_TOOLS_PATH)avr-gcc
  97. CXX = $(AVR_TOOLS_PATH)avr-g++
  98. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  99. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  100. AR = $(AVR_TOOLS_PATH)avr-ar
  101. SIZE = $(AVR_TOOLS_PATH)avr-size
  102. NM = $(AVR_TOOLS_PATH)avr-nm
  103. AVRDUDE = avrdude
  104. REMOVE = rm -f
  105. MV = mv -f
  106. # Define all object files.
  107. OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
  108. # Define all listing files.
  109. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  110. # Combine all necessary flags and optional flags.
  111. # Add target processor to flags.
  112. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  113. ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
  114. ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
  115. # Default target.
  116. all: build sizeafter
  117. build: elf hex
  118. applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
  119. applet/%.cpp: %.pde
  120. # Here is the "preprocessing".
  121. # It creates a .cpp file based with the same name as the .pde file.
  122. # On top of the new .cpp file comes the WProgram.h header.
  123. # At the end there is a generic main() function attached.
  124. # Then the .cpp file will be compiled. Errors during compile will
  125. # refer to this new, automatically generated, file.
  126. # Not the original .pde file you actually edit...
  127. @echo " WR $@"
  128. @test -d $(dir $@) || mkdir $(dir $@)
  129. @echo '#include "WProgram.h"' > $@
  130. @cat $< >> $@
  131. @cat $(ARDUINO)/main.cpp >> $@
  132. elf: applet/$(TARGET).elf
  133. hex: applet/$(TARGET).hex
  134. eep: applet/$(TARGET).eep
  135. lss: applet/$(TARGET).lss
  136. sym: applet/$(TARGET).sym
  137. # Program the device.
  138. upload: applet/$(TARGET).hex
  139. stty hup < $(PORT); true
  140. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  141. stty -hup < $(PORT); true
  142. # Display size of file.
  143. HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
  144. ELFSIZE = $(SIZE) applet/$(TARGET).elf
  145. sizebefore:
  146. @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  147. sizeafter:
  148. @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  149. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  150. COFFCONVERT=$(OBJCOPY) --debugging \
  151. --change-section-address .data-0x800000 \
  152. --change-section-address .bss-0x800000 \
  153. --change-section-address .noinit-0x800000 \
  154. --change-section-address .eeprom-0x810000
  155. coff: applet/$(TARGET).elf
  156. $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
  157. extcoff: $(TARGET).elf
  158. $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
  159. .SUFFIXES: .elf .hex .eep .lss .sym
  160. .PRECIOUS: .o
  161. .elf.hex:
  162. @echo " COPY $@"
  163. @$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  164. .elf.eep:
  165. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  166. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  167. # Create extended listing file from ELF output file.
  168. .elf.lss:
  169. $(OBJDUMP) -h -S $< > $@
  170. # Create a symbol table from ELF output file.
  171. .elf.sym:
  172. $(NM) -n $< > $@
  173. # Link: create ELF output file from library.
  174. applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
  175. @echo " CXX $@"
  176. @$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
  177. applet/core.a: $(OBJ) Configuration.h
  178. @for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
  179. %.o: %.c Configuration.h $(MAKEFILE)
  180. @echo " CC $@"
  181. @$(CC) -c $(ALL_CFLAGS) $< -o $@
  182. %.o: %.cpp Configuration.h $(MAKEFILE)
  183. @echo " CXX $@"
  184. @$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
  185. # Target: clean project.
  186. clean:
  187. @echo " RM applet/*"
  188. @$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
  189. applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
  190. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  191. @echo " RMDIR applet/"
  192. @rmdir applet
  193. depend:
  194. if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
  195. then \
  196. sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
  197. $(MAKEFILE).$$$$ && \
  198. $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
  199. fi
  200. echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
  201. >> $(MAKEFILE); \
  202. $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
  203. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter