My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Makefile 17KB

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