My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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. TARGET = $(notdir $(CURDIR))
  226. # VPATH tells make to look into these directory for source files,
  227. # there is no need to specify explicit pathnames as long as the
  228. # directory is added here
  229. VPATH = .
  230. VPATH += $(BUILD_DIR)
  231. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/cores/arduino
  232. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI
  233. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/libraries/SPI/src
  234. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidCrystal/src
  235. ifeq ($(LIQUID_TWI2), 1)
  236. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  237. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  238. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/LiquidTWI2
  239. endif
  240. ifeq ($(WIRE), 1)
  241. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire
  242. VPATH += $(ARDUINO_INSTALL_DIR)/libraries/Wire/utility
  243. endif
  244. ifeq ($(HARDWARE_VARIANT), arduino)
  245. HARDWARE_SUB_VARIANT ?= mega
  246. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/arduino/avr/variants/$(HARDWARE_SUB_VARIANT)
  247. else
  248. ifeq ($(HARDWARE_VARIANT), Sanguino)
  249. VPATH += $(HARDWARE_DIR)/marlin/avr/variants/sanguino
  250. else
  251. HARDWARE_SUB_VARIANT ?= standard
  252. VPATH += $(HARDWARE_DIR)/$(HARDWARE_VARIANT)/variants/$(HARDWARE_SUB_VARIANT)
  253. endif
  254. endif
  255. SRC = wiring.c \
  256. wiring_analog.c wiring_digital.c \
  257. wiring_pulse.c \
  258. wiring_shift.c WInterrupts.c hooks.c
  259. ifeq ($(HARDWARE_VARIANT), Teensy)
  260. SRC = wiring.c
  261. VPATH += $(ARDUINO_INSTALL_DIR)/hardware/teensy/cores/teensy
  262. endif
  263. CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
  264. MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \
  265. SdFile.cpp SdVolume.cpp planner.cpp stepper.cpp \
  266. temperature.cpp cardreader.cpp configuration_store.cpp \
  267. watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \
  268. dac_mcp4728.cpp vector_3.cpp qr_solve.cpp endstops.cpp stopwatch.cpp utility.cpp \
  269. printcounter.cpp nozzle.cpp serial.cpp
  270. ifeq ($(LIQUID_TWI2), 0)
  271. CXXSRC += LiquidCrystal.cpp
  272. else
  273. SRC += twi.c
  274. CXXSRC += Wire.cpp LiquidTWI2.cpp
  275. endif
  276. ifeq ($(WIRE), 1)
  277. SRC += twi.c
  278. CXXSRC += Wire.cpp
  279. endif
  280. #Check for Arduino 1.0.0 or higher and use the correct source files for that version
  281. ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
  282. CXXSRC += main.cpp
  283. else
  284. SRC += pins_arduino.c main.c
  285. endif
  286. FORMAT = ihex
  287. # Name of this Makefile (used for "make depend").
  288. MAKEFILE = Makefile
  289. # Debugging format.
  290. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  291. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  292. DEBUG = stabs
  293. OPT = s
  294. DEFINES ?=
  295. # Program settings
  296. CC = $(AVR_TOOLS_PATH)avr-gcc
  297. CXX = $(AVR_TOOLS_PATH)avr-g++
  298. OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
  299. OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
  300. AR = $(AVR_TOOLS_PATH)avr-ar
  301. SIZE = $(AVR_TOOLS_PATH)avr-size
  302. NM = $(AVR_TOOLS_PATH)avr-nm
  303. AVRDUDE = avrdude
  304. REMOVE = rm -f
  305. MV = mv -f
  306. # Place -D or -U options here
  307. CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)}
  308. CXXDEFS = $(CDEFS)
  309. ifeq ($(HARDWARE_VARIANT), Teensy)
  310. CDEFS += -DUSB_SERIAL
  311. SRC += usb.c pins_teensy.c
  312. CXXSRC += usb_api.cpp
  313. endif
  314. # Add all the source directories as include directories too
  315. CINCS = ${addprefix -I ,${VPATH}}
  316. CXXINCS = ${addprefix -I ,${VPATH}}
  317. # Compiler flag to set the C/CPP Standard level.
  318. CSTANDARD = -std=gnu99
  319. CXXSTANDARD = -std=gnu++11
  320. CDEBUG = -g$(DEBUG)
  321. CWARN = -Wall -Wstrict-prototypes
  322. CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct \
  323. -fshort-enums -w -ffunction-sections -fdata-sections \
  324. -flto \
  325. -DARDUINO=$(ARDUINO_VERSION)
  326. ifneq ($(HARDWARE_MOTHERBOARD),)
  327. CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD}
  328. endif
  329. #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
  330. CEXTRA = -fno-use-cxa-atexit -fno-threadsafe-statics
  331. CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(CSTANDARD)
  332. CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(CXXSTANDARD)
  333. #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  334. LDFLAGS = -lm
  335. # Programming support using avrdude. Settings and variables.
  336. AVRDUDE_PORT = $(UPLOAD_PORT)
  337. AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
  338. ifeq ($(shell uname -s), Linux)
  339. AVRDUDE_CONF = /etc/avrdude/avrdude.conf
  340. else
  341. AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
  342. endif
  343. AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
  344. -p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
  345. -b$(UPLOAD_RATE)
  346. # Define all object files.
  347. OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}}
  348. OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}}
  349. OBJ += ${patsubst %.S, $(BUILD_DIR)/%.o, ${ASRC}}
  350. # Define all listing files.
  351. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
  352. # Combine all necessary flags and optional flags.
  353. # Add target processor to flags.
  354. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
  355. ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
  356. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
  357. # set V=1 (eg, "make V=1") to print the full commands etc.
  358. ifneq ($V,1)
  359. Pecho=@echo
  360. P=@
  361. else
  362. Pecho=@:
  363. P=
  364. endif
  365. # Default target.
  366. all: sizeafter
  367. build: $(BUILD_DIR) elf hex
  368. # Creates the object directory
  369. $(BUILD_DIR):
  370. $P mkdir -p $(BUILD_DIR)
  371. elf: $(BUILD_DIR)/$(TARGET).elf
  372. hex: $(BUILD_DIR)/$(TARGET).hex
  373. eep: $(BUILD_DIR)/$(TARGET).eep
  374. lss: $(BUILD_DIR)/$(TARGET).lss
  375. sym: $(BUILD_DIR)/$(TARGET).sym
  376. # Program the device.
  377. # Do not try to reset an Arduino if it's not one
  378. upload: $(BUILD_DIR)/$(TARGET).hex
  379. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  380. stty hup < $(UPLOAD_PORT); true
  381. endif
  382. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
  383. ifeq (${AVRDUDE_PROGRAMMER}, arduino)
  384. stty -hup < $(UPLOAD_PORT); true
  385. endif
  386. # Display size of file.
  387. HEXSIZE = $(SIZE) --target=$(FORMAT) $(BUILD_DIR)/$(TARGET).hex
  388. ELFSIZE = $(SIZE) --mcu=$(MCU) -C $(BUILD_DIR)/$(TARGET).elf; \
  389. $(SIZE) $(BUILD_DIR)/$(TARGET).elf
  390. sizebefore:
  391. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
  392. sizeafter: build
  393. $P if [ -f $(BUILD_DIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  394. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  395. COFFCONVERT=$(OBJCOPY) --debugging \
  396. --change-section-address .data-0x800000 \
  397. --change-section-address .bss-0x800000 \
  398. --change-section-address .noinit-0x800000 \
  399. --change-section-address .eeprom-0x810000
  400. coff: $(BUILD_DIR)/$(TARGET).elf
  401. $(COFFCONVERT) -O coff-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  402. extcoff: $(TARGET).elf
  403. $(COFFCONVERT) -O coff-ext-avr $(BUILD_DIR)/$(TARGET).elf $(TARGET).cof
  404. .SUFFIXES: .elf .hex .eep .lss .sym
  405. .PRECIOUS: .o
  406. .elf.hex:
  407. $(Pecho) " COPY $@"
  408. $P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  409. .elf.eep:
  410. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  411. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  412. # Create extended listing file from ELF output file.
  413. .elf.lss:
  414. $(OBJDUMP) -h -S $< > $@
  415. # Create a symbol table from ELF output file.
  416. .elf.sym:
  417. $(NM) -n $< > $@
  418. # Link: create ELF output file from library.
  419. $(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h
  420. $(Pecho) " CXX $@"
  421. $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections,--relax -o $@ -L. $(OBJ) $(LDFLAGS)
  422. $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
  423. $(Pecho) " CC $<"
  424. $P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
  425. $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  426. $(Pecho) " CXX $<"
  427. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  428. $(BUILD_DIR)/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
  429. $(Pecho) " CXX $<"
  430. $P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
  431. # Target: clean project.
  432. clean:
  433. $(Pecho) " RM $(BUILD_DIR)/*"
  434. $P $(REMOVE) $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET).cof $(BUILD_DIR)/$(TARGET).elf \
  435. $(BUILD_DIR)/$(TARGET).map $(BUILD_DIR)/$(TARGET).sym $(BUILD_DIR)/$(TARGET).lss $(BUILD_DIR)/$(TARGET).cpp \
  436. $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
  437. $(Pecho) " RMDIR $(BUILD_DIR)/"
  438. $P rm -rf $(BUILD_DIR)
  439. .PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter
  440. # Automaticaly include the dependency files created by gcc
  441. -include ${wildcard $(BUILD_DIR)/*.d}