My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Makefile 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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 containing "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.app/Contents/Resources/Java).
  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 wild card (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 at the top of this file can be overriden from
  37. # the command line with, for example, "make HARDWARE_MOTHERBOARD=71"
  38. #
  39. # To compile for RAMPS (atmega2560) with Arduino 1.6.9 at root/arduino you would use...
  40. #
  41. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  42. # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino
  43. #
  44. # To compile and upload simply add "upload" to the end of the line...
  45. #
  46. # make ARDUINO_VERSION=10609 AVR_TOOLS_PATH=/root/arduino/hardware/tools/avr/bin/ \
  47. # HARDWARE_MOTHERBOARD=33 ARDUINO_INSTALL_DIR=/root/arduino upload
  48. #
  49. # If uploading doesn't work try adding the parameter "AVRDUDE_PROGRAMMER=wiring" or
  50. # start upload manually (using stk500) like so:
  51. #
  52. # avrdude -C /root/arduino/hardware/tools/avr/etc/avrdude.conf -v -p m2560 -c stk500 \
  53. # -U flash:w:applet/Marlin.hex:i -P /dev/ttyUSB0
  54. #
  55. # Or, try disconnecting USB to power down and then reconnecting before running avrdude.
  56. #
  57. # This defines the board to compile for (see boards.h for your board's ID)
  58. HARDWARE_MOTHERBOARD ?= 11
  59. # Arduino source install directory, and version number
  60. # On most linuxes this will be /usr/share/arduino
  61. ARDUINO_INSTALL_DIR ?= ${HOME}/Arduino
  62. ARDUINO_VERSION ?= 106
  63. # You can optionally set a path to the avr-gcc tools. Requires a trailing slash. (ex: /usr/local/avr-gcc/bin)
  64. AVR_TOOLS_PATH ?=
  65. #Programmer configuration
  66. UPLOAD_RATE ?= 57600
  67. AVRDUDE_PROGRAMMER ?= arduino
  68. # on most linuxes this will be /dev/ttyACM0 or /dev/ttyACM1
  69. UPLOAD_PORT ?= /dev/ttyUSB0
  70. #Directory used to build files in, contains all the build files, from object files to the final hex file
  71. #on linux it is best to put an absolute path like /home/username/tmp .
  72. BUILD_DIR ?= applet
  73. # This defines whether Liquid_TWI2 support will be built
  74. LIQUID_TWI2 ?= 0
  75. # this defines if Wire is needed
  76. WIRE ?= 0
  77. ############################################################################
  78. # Below here nothing should be changed...
  79. # Here the Arduino variant is selected by the board type
  80. # HARDWARE_VARIANT = "arduino", "Sanguino", "Gen7", ...
  81. # MCU = "atmega1280", "Mega2560", "atmega2560", "atmega644p", ...
  82. #Gen7
  83. ifeq ($(HARDWARE_MOTHERBOARD),10)
  84. HARDWARE_VARIANT ?= Gen7
  85. MCU ?= atmega644
  86. F_CPU ?= 20000000
  87. else ifeq ($(HARDWARE_MOTHERBOARD),11)
  88. HARDWARE_VARIANT ?= Gen7
  89. MCU ?= atmega644p
  90. F_CPU ?= 20000000
  91. else ifeq ($(HARDWARE_MOTHERBOARD),12)
  92. HARDWARE_VARIANT ?= Gen7
  93. MCU ?= atmega644p
  94. F_CPU ?= 20000000
  95. else ifeq ($(HARDWARE_MOTHERBOARD),13)
  96. HARDWARE_VARIANT ?= Gen7
  97. MCU ?= atmega1284p
  98. F_CPU ?= 20000000
  99. #RAMPS
  100. else ifeq ($(HARDWARE_MOTHERBOARD),3)
  101. HARDWARE_VARIANT ?= arduino
  102. MCU ?= atmega2560
  103. else ifeq ($(HARDWARE_MOTHERBOARD),33)
  104. HARDWARE_VARIANT ?= arduino
  105. MCU ?= atmega2560
  106. else ifeq ($(HARDWARE_MOTHERBOARD),34)
  107. HARDWARE_VARIANT ?= arduino
  108. MCU ?= atmega2560
  109. else ifeq ($(HARDWARE_MOTHERBOARD),35)
  110. HARDWARE_VARIANT ?= arduino
  111. MCU ?= atmega2560
  112. else ifeq ($(HARDWARE_MOTHERBOARD),36)
  113. HARDWARE_VARIANT ?= arduino
  114. MCU ?= atmega2560
  115. else ifeq ($(HARDWARE_MOTHERBOARD),38)
  116. HARDWARE_VARIANT ?= arduino
  117. MCU ?= atmega2560
  118. else ifeq ($(HARDWARE_MOTHERBOARD),43)
  119. HARDWARE_VARIANT ?= arduino
  120. MCU ?= atmega2560
  121. else ifeq ($(HARDWARE_MOTHERBOARD),44)
  122. HARDWARE_VARIANT ?= arduino
  123. MCU ?= atmega2560
  124. else ifeq ($(HARDWARE_MOTHERBOARD),45)
  125. HARDWARE_VARIANT ?= arduino
  126. MCU ?= atmega2560
  127. else ifeq ($(HARDWARE_MOTHERBOARD),46)
  128. HARDWARE_VARIANT ?= arduino
  129. MCU ?= atmega2560
  130. else ifeq ($(HARDWARE_MOTHERBOARD),48)
  131. HARDWARE_VARIANT ?= arduino
  132. MCU ?= atmega2560
  133. #Gen6
  134. else ifeq ($(HARDWARE_MOTHERBOARD),5)
  135. HARDWARE_VARIANT ?= Gen6
  136. MCU ?= atmega644p
  137. else ifeq ($(HARDWARE_MOTHERBOARD),51)
  138. HARDWARE_VARIANT ?= Gen6
  139. MCU ?= atmega644p
  140. #Sanguinololu
  141. else ifeq ($(HARDWARE_MOTHERBOARD),6)
  142. HARDWARE_VARIANT ?= Sanguino
  143. MCU ?= atmega644p
  144. else ifeq ($(HARDWARE_MOTHERBOARD),62)
  145. HARDWARE_VARIANT ?= Sanguino
  146. MCU ?= atmega644p
  147. else ifeq ($(HARDWARE_MOTHERBOARD),63)
  148. HARDWARE_VARIANT ?= Sanguino
  149. MCU ?= atmega644p
  150. else ifeq ($(HARDWARE_MOTHERBOARD),65)
  151. HARDWARE_VARIANT ?= Sanguino
  152. MCU ?= atmega1284p
  153. else ifeq ($(HARDWARE_MOTHERBOARD),66)
  154. HARDWARE_VARIANT ?= Sanguino
  155. MCU ?= atmega1284p
  156. else ifeq ($(HARDWARE_MOTHERBOARD),69)
  157. HARDWARE_VARIANT ?= Sanguino
  158. MCU ?= atmega1284p
  159. #Ultimaker
  160. else ifeq ($(HARDWARE_MOTHERBOARD),7)
  161. HARDWARE_VARIANT ?= arduino
  162. MCU ?= atmega2560
  163. else ifeq ($(HARDWARE_MOTHERBOARD),71)
  164. HARDWARE_VARIANT ?= arduino
  165. MCU ?= atmega1280
  166. #Teensylu
  167. else ifeq ($(HARDWARE_MOTHERBOARD),8)
  168. HARDWARE_VARIANT ?= Teensy
  169. MCU ?= at90usb1286
  170. else ifeq ($(HARDWARE_MOTHERBOARD),81)
  171. HARDWARE_VARIANT ?= Teensy
  172. MCU ?= at90usb1286
  173. else ifeq ($(HARDWARE_MOTHERBOARD),811)
  174. HARDWARE_VARIANT ?= Teensy
  175. MCU ?= at90usb1286
  176. else ifeq ($(HARDWARE_MOTHERBOARD),82)
  177. HARDWARE_VARIANT ?= Teensy
  178. MCU ?= at90usb646
  179. else ifeq ($(HARDWARE_MOTHERBOARD),83)
  180. HARDWARE_VARIANT ?= Teensy
  181. MCU ?= at90usb1286
  182. else ifeq ($(HARDWARE_MOTHERBOARD),84)
  183. HARDWARE_VARIANT ?= Teensy
  184. MCU ?= at90usb1286
  185. #Gen3+
  186. else ifeq ($(HARDWARE_MOTHERBOARD),9)
  187. HARDWARE_VARIANT ?= Sanguino
  188. MCU ?= atmega644p
  189. #Gen3 Monolithic Electronics
  190. else ifeq ($(HARDWARE_MOTHERBOARD),22)
  191. HARDWARE_VARIANT ?= Sanguino
  192. MCU ?= atmega644p
  193. #Megatronics
  194. else ifeq ($(HARDWARE_MOTHERBOARD),70)
  195. HARDWARE_VARIANT ?= arduino
  196. MCU ?= atmega2560
  197. #Alpha OMCA board
  198. else ifeq ($(HARDWARE_MOTHERBOARD),90)
  199. HARDWARE_VARIANT ?= SanguinoA
  200. MCU ?= atmega644
  201. #Final OMCA board
  202. else ifeq ($(HARDWARE_MOTHERBOARD),91)
  203. HARDWARE_VARIANT ?= Sanguino
  204. MCU ?= atmega644p
  205. #Rambo
  206. else ifeq ($(HARDWARE_MOTHERBOARD),301)
  207. HARDWARE_VARIANT ?= arduino
  208. MCU ?= atmega2560
  209. # Azteeg
  210. else ifeq ($(HARDWARE_MOTHERBOARD),67)
  211. HARDWARE_VARIANT ?= arduino
  212. MCU ?= atmega2560
  213. else ifeq ($(HARDWARE_MOTHERBOARD),68)
  214. HARDWARE_VARIANT ?= arduino
  215. MCU ?= atmega2560
  216. endif
  217. # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
  218. # if you are setting this to something other than 16MHz
  219. # Set to 16Mhz if not yet set.
  220. F_CPU ?= 16000000
  221. # Arduino contained the main source code for the Arduino
  222. # Libraries, the "hardware variant" are for boards
  223. # that derives from that, and their source are present in
  224. # the main Marlin source directory
  225. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Sanguino))
  226. HARDWARE_DIR = $(ARDUINO_INSTALL_DIR)/hardware
  227. else
  228. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  229. HARDWARE_DIR = ../ArduinoAddons/Arduino_1.x.x
  230. else
  231. HARDWARE_DIR = ../ArduinoAddons/Arduino_0.xx
  232. endif
  233. endif
  234. HARDWARE_SRC= $(HARDWARE_DIR)/arduino/avr/cores/arduino
  235. TARGET = $(notdir $(CURDIR))
  236. # VPATH tells make to look into these directory for source files,
  237. # there is no need to specify explicit pathnames as long as the
  238. # directory is added here
  239. VPATH = .
  240. VPATH += $(BUILD_DIR)
  241. VPATH += $(HARDWARE_SRC)
  242. ifeq ($(HARDWARE_VARIANT), $(filter $(HARDWARE_VARIANT),arduino Teensy Sanguino))
  243. VPATH += $(HARDWARE_DIR)/marlin/avr/libraries/LiquidCrystal/src
  244. VPATH += $(HARDWARE_DIR)/marlin/avr/libraries/SPI
  245. VPATH += $(HARDWARE_DIR)/arduino/avr/libraries/SPI
  246. VPATH += $(HARDWARE_DIR)/arduino/avr/libraries/SPI/src
  247. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  248. ifeq ($(LIQUID_TWI2), 1)
  249. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  250. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  251. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  252. endif
  253. ifeq ($(WIRE), 1)
  254. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  255. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  256. endif
  257. else
  258. VPATH += $(HARDWARE_DIR)/libraries/LiquidCrystal
  259. VPATH += $(HARDWARE_DIR)/libraries/SPI
  260. ifeq ($(LIQUID_TWI2), 1)
  261. VPATH += $(HARDWARE_DIR)/libraries/Wire
  262. VPATH += $(HARDWARE_DIR)/libraries/Wire/utility
  263. VPATH += $(HARDWARE_DIR)/libraries/LiquidTWI2
  264. endif
  265. ifeq ($(WIRE), 1)
  266. VPATH += $(HARDWARE_DIR)/libraries/Wire
  267. VPATH += $(HARDWARE_DIR)/libraries/Wire/utility
  268. endif
  269. endif
  270. ifeq ($(HARDWARE_VARIANT), arduino)
  271. HARDWARE_SUB_VARIANT ?= mega
  272. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/variants/$(HARDWARE_SUB_VARIANT)
  273. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
  274. else
  275. ifeq ($(HARDWARE_VARIANT), Sanguino)
  276. VPATH += $(HARDWARE_DIR)/marlin/avr/variants/sanguino
  277. else
  278. HARDWARE_SUB_VARIANT ?= standard
  279. VPATH += $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  280. endif
  281. endif
  282. SRC = wiring.c \
  283. wiring_analog.c wiring_digital.c \
  284. wiring_pulse.c \
  285. wiring_shift.c WInterrupts.c hooks.c
  286. ifeq ($(HARDWARE_VARIANT), Teensy)
  287. SRC = wiring.c
  288. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
  289. endif
  290. CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
  291. MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \
  292. SdFile.cpp SdVolume.cpp planner.cpp stepper.cpp \
  293. temperature.cpp cardreader.cpp configuration_store.cpp \
  294. watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \
  295. dac_mcp4728.cpp vector_3.cpp qr_solve.cpp endstops.cpp stopwatch.cpp utility.cpp
  296. ifeq ($(LIQUID_TWI2), 0)
  297. CXXSRC += LiquidCrystal.cpp
  298. else
  299. SRC += twi.c
  300. CXXSRC += Wire.cpp LiquidTWI2.cpp
  301. endif
  302. ifeq ($(WIRE), 1)
  303. SRC += twi.c
  304. CXXSRC += Wire.cpp
  305. endif
  306. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  307. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  308. CXXSRC += main.cpp
  309. else
  310. SRC += pins_arduino.c main.c
  311. endif
  312. FORMAT = ihex
  313. # Name of this Makefile (used for "make depend").
  314. MAKEFILE = Makefile
  315. # Debugging format.
  316. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  317. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  318. DEBUG = stabs
  319. OPT = s
  320. DEFINES ?=
  321. # Program settings
  322. CC = $(AVR_TOOLS_PATH)avr-gcc
  323. CXX = $(AVR_TOOLS_PATH)avr-g++
  324. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  325. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  326. AR = $(AVR_TOOLS_PATH)avr-ar
  327. SIZE = $(AVR_TOOLS_PATH)avr-size
  328. NM = $(AVR_TOOLS_PATH)avr-nm
  329. AVRDUDE = avrdude
  330. REMOVE = rm -f
  331. MV = mv -f
  332. # Place -D or -U options here
  333. CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
  334. CXXDEFS = $(CDEFS)
  335. ifeq ($(HARDWARE_VARIANT), Teensy)
  336. CDEFS += -DUSB_SERIAL
  337. SRC += usb.c pins_teensy.c
  338. CXXSRC += usb_api.cpp
  339. endif
  340. # Add all the source directories as include directories too
  341. CINCS = ${addprefix -I ,${VPATH}}
  342. CXXINCS = ${addprefix -I ,${VPATH}}
  343. # Compiler flag to set the C/CPP Standard level.
  344. CSTANDARD = -std=gnu99
  345. CXXSTANDARD = -std=gnu++11
  346. CDEBUG = -g$(DEBUG)
  347. CWARN = -Wall -Wstrict-prototypes
  348. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  349. -fshort-enums -w -ffunction-sections -fdata-sections \
  350. -flto \
  351. -DARDUINO=$(ARDUINO_VERSION)
  352. ifneq ($(HARDWARE_MOTHERBOARD),)
  353. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  354. endif
  355. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  356. CEXTRA = -fno-use-cxa-atexit
  357. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  358. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(CXXSTANDARD)
  359. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  360. LDFLAGS = -lm
  361. # Programming support using avrdude. Settings and variables.
  362. AVRDUDE_PORT = $(UPLOAD_PORT)
  363. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  364. ifeq ($(shell uname -s), Linux)
  365. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  366. else
  367. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  368. endif
  369. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  370. -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  371. -b$(UPLOAD_RATE)
  372. # Define all object files.
  373. OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  374. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  375. OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}
  376. # Define all listing files.
  377. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  378. # Combine all necessary flags and optional flags.
  379. # Add target processor to flags.
  380. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  381. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  382. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  383. # set V=1 (eg, "make V=1") to print the full commands etc.
  384. ifneq ($V,1)
  385. Pecho=@echo
  386. P=@
  387. else
  388. Pecho=@:
  389. P=
  390. endif
  391. # Default target.
  392. all: sizeafter
  393. build: $(BUILD_DIR) elf hex
  394. # Creates the object directory
  395. $(BUILD_DIR):
  396. $P mkdir -p $(BUILD_DIR)
  397. elf: $(BUILD_DIR)/$(TARGET).elf
  398. hex: $(BUILD_DIR)/$(TARGET).hex
  399. eep: $(BUILD_DIR)/$(TARGET).eep
  400. lss: $(BUILD_DIR)/$(TARGET).lss
  401. sym: $(BUILD_DIR)/$(TARGET).sym
  402. # Program the device.
  403. # Do not try to reset an Arduino if it's not one
  404. upload: $(BUILD_DIR)/$(TARGET).hex
  405. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  406. stty hup < $(UPLOAD_PORT); true
  407. endif
  408. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  409. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  410. stty -hup < $(UPLOAD_PORT); true
  411. endif
  412. # Display size of file.
  413. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  414. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  415. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  416. sizebefore:
  417. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  418. sizeafter: build
  419. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  420. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  421. COFFCONVERT=$(OBJCOPY) --debugging \
  422. --change-section-address .data-0x800000 \
  423. --change-section-address .bss-0x800000 \
  424. --change-section-address .noinit-0x800000 \
  425. --change-section-address .eeprom-0x810000
  426. coff: $(BUILD_DIR)/$(TARGET).elf
  427. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  428. extcoff: $(TARGET).elf
  429. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  430. .SUFFIXES: .elf .hex .eep .lss .sym
  431. .PRECIOUS: .o
  432. .elf.hex:
  433. $(Pecho) " COPY $@"
  434. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  435. .elf.eep:
  436. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  437. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  438. # Create extended listing file from ELF output file.
  439. .elf.lss:
  440. $(OBJDUMP) -h -S $< > $@
  441. # Create a symbol table from ELF output file.
  442. .elf.sym:
  443. $(NM) -n $< > $@
  444. # Link: create ELF output file from library.
  445. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  446. $(Pecho) " CXX $@"
  447. $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections,--relax -o $@ -L. $(OBJ) $(LDFLAGS)
  448. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  449. $(Pecho) " CC $<"
  450. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  451. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  452. $(Pecho) " CXX $<"
  453. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  454. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  455. $(Pecho) " CXX $<"
  456. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  457. # Target: clean project.
  458. clean:
  459. $(Pecho) " RM $(BUILD_DIR)/*"
  460. $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
  461. $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
  462. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  463. $(Pecho) " RMDIR $(BUILD_DIR)/"
  464. $P rm -rf $(BUILD_DIR)
  465. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  466. # Automaticaly include the dependency files created by gcc
  467. -include ${wildcard $(BUILD_DIR)/*.d}