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.6KB

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