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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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. -DARDUINO=$(ARDUINO_VERSION)
  351. ifneq ($(HARDWARE_MOTHERBOARD),)
  352. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  353. endif
  354. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  355. CEXTRA = -fno-use-cxa-atexit
  356. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  357. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(CXXSTANDARD)
  358. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  359. LDFLAGS = -lm
  360. # Programming support using avrdude. Settings and variables.
  361. AVRDUDE_PORT = $(UPLOAD_PORT)
  362. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  363. ifeq ($(shell uname -s), Linux)
  364. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  365. else
  366. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  367. endif
  368. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  369. -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  370. -b$(UPLOAD_RATE)
  371. # Define all object files.
  372. OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  373. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  374. OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}
  375. # Define all listing files.
  376. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  377. # Combine all necessary flags and optional flags.
  378. # Add target processor to flags.
  379. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  380. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  381. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  382. # set V=1 (eg, "make V=1") to print the full commands etc.
  383. ifneq ($V,1)
  384. Pecho=@echo
  385. P=@
  386. else
  387. Pecho=@:
  388. P=
  389. endif
  390. # Default target.
  391. all: sizeafter
  392. build: $(BUILD_DIR) elf hex
  393. # Creates the object directory
  394. $(BUILD_DIR):
  395. $P mkdir -p $(BUILD_DIR)
  396. elf: $(BUILD_DIR)/$(TARGET).elf
  397. hex: $(BUILD_DIR)/$(TARGET).hex
  398. eep: $(BUILD_DIR)/$(TARGET).eep
  399. lss: $(BUILD_DIR)/$(TARGET).lss
  400. sym: $(BUILD_DIR)/$(TARGET).sym
  401. # Program the device.
  402. # Do not try to reset an Arduino if it's not one
  403. upload: $(BUILD_DIR)/$(TARGET).hex
  404. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  405. stty hup < $(UPLOAD_PORT); true
  406. endif
  407. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  408. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  409. stty -hup < $(UPLOAD_PORT); true
  410. endif
  411. # Display size of file.
  412. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  413. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  414. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  415. sizebefore:
  416. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  417. sizeafter: build
  418. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  419. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  420. COFFCONVERT=$(OBJCOPY) --debugging \
  421. --change-section-address .data-0x800000 \
  422. --change-section-address .bss-0x800000 \
  423. --change-section-address .noinit-0x800000 \
  424. --change-section-address .eeprom-0x810000
  425. coff: $(BUILD_DIR)/$(TARGET).elf
  426. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  427. extcoff: $(TARGET).elf
  428. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  429. .SUFFIXES: .elf .hex .eep .lss .sym
  430. .PRECIOUS: .o
  431. .elf.hex:
  432. $(Pecho) " COPY $@"
  433. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  434. .elf.eep:
  435. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  436. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  437. # Create extended listing file from ELF output file.
  438. .elf.lss:
  439. $(OBJDUMP) -h -S $< > $@
  440. # Create a symbol table from ELF output file.
  441. .elf.sym:
  442. $(NM) -n $< > $@
  443. # Link: create ELF output file from library.
  444. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  445. $(Pecho) " CXX $@"
  446. $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS)
  447. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  448. $(Pecho) " CC $<"
  449. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  450. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  451. $(Pecho) " CXX $<"
  452. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  453. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  454. $(Pecho) " CXX $<"
  455. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  456. # Target: clean project.
  457. clean:
  458. $(Pecho) " RM $(BUILD_DIR)/*"
  459. $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
  460. $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
  461. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  462. $(Pecho) " RMDIR $(BUILD_DIR)/"
  463. $P rm -rf $(BUILD_DIR)
  464. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  465. # Automaticaly include the dependency files created by gcc
  466. -include ${wildcard $(BUILD_DIR)/*.d}