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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

rules.mk 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. # Hey Emacs, this is a -*- makefile -*-
  2. #----------------------------------------------------------------------------
  3. # WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al.
  4. #
  5. # Released to the Public Domain
  6. #
  7. # Additional material for this makefile was written by:
  8. # Peter Fleury
  9. # Tim Henigan
  10. # Colin O'Flynn
  11. # Reiner Patommel
  12. # Markus Pfaff
  13. # Sander Pool
  14. # Frederik Rouleau
  15. # Carlos Lamas
  16. #
  17. #----------------------------------------------------------------------------
  18. # On command line:
  19. #
  20. # make all = Make software.
  21. #
  22. # make clean = Clean out built project files.
  23. #
  24. # make coff = Convert ELF to AVR COFF.
  25. #
  26. # make extcoff = Convert ELF to AVR Extended COFF.
  27. #
  28. # make program = Download the hex file to the device.
  29. # Please customize your programmer settings(PROGRAM_CMD)
  30. #
  31. # make teensy = Download the hex file to the device, using teensy_loader_cli.
  32. # (must have teensy_loader_cli installed).
  33. #
  34. # make dfu = Download the hex file to the device, using dfu-programmer (must
  35. # have dfu-programmer installed).
  36. #
  37. # make flip = Download the hex file to the device, using Atmel FLIP (must
  38. # have Atmel FLIP installed).
  39. #
  40. # make dfu-ee = Download the eeprom file to the device, using dfu-programmer
  41. # (must have dfu-programmer installed).
  42. #
  43. # make flip-ee = Download the eeprom file to the device, using Atmel FLIP
  44. # (must have Atmel FLIP installed).
  45. #
  46. # make debug = Start either simulavr or avarice as specified for debugging,
  47. # with avr-gdb or avr-insight as the front end for debugging.
  48. #
  49. # make filename.s = Just compile filename.c into the assembler code only.
  50. #
  51. # make filename.i = Create a preprocessed source file for use in submitting
  52. # bug reports to the GCC project.
  53. #
  54. # To rebuild project do "make clean" then "make all".
  55. #----------------------------------------------------------------------------
  56. # Output format. (can be srec, ihex, binary)
  57. FORMAT = ihex
  58. # Object files directory
  59. # To put object files in current directory, use a dot (.), do NOT make
  60. # this an empty or blank macro!
  61. OBJDIR = obj_$(TARGET)
  62. # Optimization level, can be [0, 1, 2, 3, s].
  63. # 0 = turn off optimization. s = optimize for size.
  64. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
  65. OPT = s
  66. # Debugging format.
  67. # Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
  68. # AVR Studio 4.10 requires dwarf-2.
  69. # AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
  70. DEBUG = dwarf-2
  71. # List any extra directories to look for include files here.
  72. # Each directory must be seperated by a space.
  73. # Use forward slashes for directory separators.
  74. # For a directory that has spaces, enclose it in quotes.
  75. EXTRAINCDIRS = $(subst :, ,$(VPATH))
  76. # Compiler flag to set the C Standard level.
  77. # c89 = "ANSI" C
  78. # gnu89 = c89 plus GCC extensions
  79. # c99 = ISO C99 standard (not yet fully implemented)
  80. # gnu99 = c99 plus GCC extensions
  81. CSTANDARD = -std=gnu99
  82. # Place -D or -U options here for C sources
  83. CDEFS = -DF_CPU=$(F_CPU)UL
  84. CDEFS += $(OPT_DEFS)
  85. # Place -D or -U options here for ASM sources
  86. ADEFS = -DF_CPU=$(F_CPU)
  87. ADEFS += $(OPT_DEFS)
  88. # Place -D or -U options here for C++ sources
  89. CPPDEFS = -DF_CPU=$(F_CPU)UL
  90. #CPPDEFS += -D__STDC_LIMIT_MACROS
  91. #CPPDEFS += -D__STDC_CONSTANT_MACROS
  92. CPPDEFS += $(OPT_DEFS)
  93. #---------------- Compiler Options C ----------------
  94. # -g*: generate debugging information
  95. # -O*: optimization level
  96. # -f...: tuning, see GCC manual and avr-libc documentation
  97. # -Wall...: warning level
  98. # -Wa,...: tell GCC to pass this to the assembler.
  99. # -adhlns...: create assembler listing
  100. CFLAGS = -g$(DEBUG)
  101. CFLAGS += $(CDEFS)
  102. CFLAGS += -O$(OPT)
  103. CFLAGS += -funsigned-char
  104. CFLAGS += -funsigned-bitfields
  105. CFLAGS += -ffunction-sections
  106. CFLAGS += -fdata-sections
  107. CFLAGS += -fno-inline-small-functions
  108. CFLAGS += -fpack-struct
  109. CFLAGS += -fshort-enums
  110. CFLAGS += -fno-strict-aliasing
  111. CFLAGS += -Wall
  112. CFLAGS += -Wstrict-prototypes
  113. #CFLAGS += -mshort-calls
  114. #CFLAGS += -fno-unit-at-a-time
  115. #CFLAGS += -Wundef
  116. #CFLAGS += -Wunreachable-code
  117. #CFLAGS += -Wsign-compare
  118. CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
  119. CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  120. CFLAGS += $(CSTANDARD)
  121. ifdef CONFIG_H
  122. CFLAGS += -include $(CONFIG_H)
  123. endif
  124. #---------------- Compiler Options C++ ----------------
  125. # -g*: generate debugging information
  126. # -O*: optimization level
  127. # -f...: tuning, see GCC manual and avr-libc documentation
  128. # -Wall...: warning level
  129. # -Wa,...: tell GCC to pass this to the assembler.
  130. # -adhlns...: create assembler listing
  131. CPPFLAGS = -g$(DEBUG)
  132. CPPFLAGS += $(CPPDEFS)
  133. CPPFLAGS += -O$(OPT)
  134. CPPFLAGS += -funsigned-char
  135. CPPFLAGS += -funsigned-bitfields
  136. CPPFLAGS += -fpack-struct
  137. CPPFLAGS += -fshort-enums
  138. CPPFLAGS += -fno-exceptions
  139. CPPFLAGS += -ffunction-sections
  140. CPPFLAGS += -fdata-sections
  141. # to supress "warning: only initialized variables can be placed into program memory area"
  142. CPPFLAGS += -w
  143. CPPFLAGS += -Wall
  144. CPPFLAGS += -Wundef
  145. #CPPFLAGS += -mshort-calls
  146. #CPPFLAGS += -fno-unit-at-a-time
  147. #CPPFLAGS += -Wstrict-prototypes
  148. #CPPFLAGS += -Wunreachable-code
  149. #CPPFLAGS += -Wsign-compare
  150. CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
  151. CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  152. #CPPFLAGS += $(CSTANDARD)
  153. ifdef CONFIG_H
  154. CPPFLAGS += -include $(CONFIG_H)
  155. endif
  156. #---------------- Assembler Options ----------------
  157. # -Wa,...: tell GCC to pass this to the assembler.
  158. # -adhlns: create listing
  159. # -gstabs: have the assembler create line number information; note that
  160. # for use in COFF files, additional information about filenames
  161. # and function names needs to be present in the assembler source
  162. # files -- see avr-libc docs [FIXME: not yet described there]
  163. # -listing-cont-lines: Sets the maximum number of continuation lines of hex
  164. # dump that will be displayed for a given single line of source input.
  165. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
  166. ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  167. ifdef CONFIG_H
  168. ASFLAGS += -include $(CONFIG_H)
  169. endif
  170. #---------------- Library Options ----------------
  171. # Minimalistic printf version
  172. PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
  173. # Floating point printf version (requires MATH_LIB = -lm below)
  174. PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
  175. # If this is left blank, then it will use the Standard printf version.
  176. PRINTF_LIB =
  177. #PRINTF_LIB = $(PRINTF_LIB_MIN)
  178. #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
  179. # Minimalistic scanf version
  180. SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
  181. # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
  182. SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
  183. # If this is left blank, then it will use the Standard scanf version.
  184. SCANF_LIB =
  185. #SCANF_LIB = $(SCANF_LIB_MIN)
  186. #SCANF_LIB = $(SCANF_LIB_FLOAT)
  187. MATH_LIB = -lm
  188. # List any extra directories to look for libraries here.
  189. # Each directory must be seperated by a space.
  190. # Use forward slashes for directory separators.
  191. # For a directory that has spaces, enclose it in quotes.
  192. EXTRALIBDIRS =
  193. #---------------- External Memory Options ----------------
  194. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  195. # used for variables (.data/.bss) and heap (malloc()).
  196. #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
  197. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  198. # only used for heap (malloc()).
  199. #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
  200. EXTMEMOPTS =
  201. #---------------- Linker Options ----------------
  202. # -Wl,...: tell GCC to pass this to linker.
  203. # -Map: create map file
  204. # --cref: add cross reference to map file
  205. #
  206. # Comennt out "--relax" option to avoid a error such:
  207. # (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12'
  208. #
  209. LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
  210. #LDFLAGS += -Wl,--relax
  211. LDFLAGS += -Wl,--gc-sections
  212. LDFLAGS += $(EXTMEMOPTS)
  213. LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
  214. LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
  215. #LDFLAGS += -T linker_script.x
  216. # You can give EXTRALDFLAGS at 'make' command line.
  217. LDFLAGS += $(EXTRALDFLAGS)
  218. #---------------- Debugging Options ----------------
  219. # For simulavr only - target MCU frequency.
  220. DEBUG_MFREQ = $(F_CPU)
  221. # Set the DEBUG_UI to either gdb or insight.
  222. # DEBUG_UI = gdb
  223. DEBUG_UI = insight
  224. # Set the debugging back-end to either avarice, simulavr.
  225. DEBUG_BACKEND = avarice
  226. #DEBUG_BACKEND = simulavr
  227. # GDB Init Filename.
  228. GDBINIT_FILE = __avr_gdbinit
  229. # When using avarice settings for the JTAG
  230. JTAG_DEV = /dev/com1
  231. # Debugging port used to communicate between GDB / avarice / simulavr.
  232. DEBUG_PORT = 4242
  233. # Debugging host used to communicate between GDB / avarice / simulavr, normally
  234. # just set to localhost unless doing some sort of crazy debugging when
  235. # avarice is running on a different computer.
  236. DEBUG_HOST = localhost
  237. #============================================================================
  238. # Define programs and commands.
  239. SHELL = sh
  240. CC = avr-gcc
  241. OBJCOPY = avr-objcopy
  242. OBJDUMP = avr-objdump
  243. SIZE = avr-size
  244. AR = avr-ar rcs
  245. NM = avr-nm
  246. REMOVE = rm -f
  247. REMOVEDIR = rmdir
  248. COPY = cp
  249. WINSHELL = cmd
  250. # Define Messages
  251. # English
  252. MSG_ERRORS_NONE = Errors: none
  253. MSG_BEGIN = -------- begin --------
  254. MSG_END = -------- end --------
  255. MSG_SIZE_BEFORE = Size before:
  256. MSG_SIZE_AFTER = Size after:
  257. MSG_COFF = Converting to AVR COFF:
  258. MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
  259. MSG_FLASH = Creating load file for Flash:
  260. MSG_EEPROM = Creating load file for EEPROM:
  261. MSG_EXTENDED_LISTING = Creating Extended Listing:
  262. MSG_SYMBOL_TABLE = Creating Symbol Table:
  263. MSG_LINKING = Linking:
  264. MSG_COMPILING = Compiling C:
  265. MSG_COMPILING_CPP = Compiling C++:
  266. MSG_ASSEMBLING = Assembling:
  267. MSG_CLEANING = Cleaning project:
  268. MSG_CREATING_LIBRARY = Creating library:
  269. # Define all object files.
  270. OBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(patsubst %.cpp,$(OBJDIR)/%.o,$(patsubst %.S,$(OBJDIR)/%.o,$(SRC))))
  271. # Define all listing files.
  272. LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst %.S,$(OBJDIR)/%.lst,$(SRC))))
  273. # Compiler flags to generate dependency files.
  274. #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
  275. GENDEPFLAGS = -MMD -MP -MF .dep/$(subst /,_,$@).d
  276. # Combine all necessary flags and optional flags.
  277. # Add target processor to flags.
  278. # You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar
  279. ALL_CFLAGS = -mmcu=$(MCU) $(CFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
  280. ALL_CPPFLAGS = -mmcu=$(MCU) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
  281. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
  282. # Default target.
  283. all: begin gccversion sizebefore build sizeafter end
  284. # Change the build target to build a HEX file or a library.
  285. build: elf hex eep lss sym
  286. #build: lib
  287. elf: $(TARGET).elf
  288. hex: $(TARGET).hex
  289. eep: $(TARGET).eep
  290. lss: $(TARGET).lss
  291. sym: $(TARGET).sym
  292. LIBNAME=lib$(TARGET).a
  293. lib: $(LIBNAME)
  294. # Eye candy.
  295. # AVR Studio 3.x does not check make's exit code but relies on
  296. # the following magic strings to be generated by the compile job.
  297. begin:
  298. @echo
  299. @echo $(MSG_BEGIN)
  300. end:
  301. @echo $(MSG_END)
  302. @echo
  303. # Display size of file.
  304. HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
  305. #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
  306. ELFSIZE = $(SIZE) $(TARGET).elf
  307. sizebefore:
  308. @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
  309. 2>/dev/null; echo; fi
  310. sizeafter:
  311. @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
  312. 2>/dev/null; echo; fi
  313. # Display compiler version information.
  314. gccversion :
  315. @$(CC) --version
  316. # Program the device.
  317. program: $(TARGET).hex $(TARGET).eep
  318. $(PROGRAM_CMD)
  319. teensy: $(TARGET).hex
  320. teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
  321. flip: $(TARGET).hex
  322. batchisp -hardware usb -device $(MCU) -operation erase f
  323. batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
  324. batchisp -hardware usb -device $(MCU) -operation start reset 0
  325. dfu: $(TARGET).hex
  326. ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
  327. dfu-programmer $(MCU) erase --force
  328. else
  329. dfu-programmer $(MCU) erase
  330. endif
  331. dfu-programmer $(MCU) flash $(TARGET).hex
  332. dfu-programmer $(MCU) reset
  333. dfu-start:
  334. dfu-programmer $(MCU) reset
  335. dfu-programmer $(MCU) start
  336. flip-ee: $(TARGET).hex $(TARGET).eep
  337. $(COPY) $(TARGET).eep $(TARGET)eep.hex
  338. batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
  339. batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
  340. batchisp -hardware usb -device $(MCU) -operation start reset 0
  341. $(REMOVE) $(TARGET)eep.hex
  342. dfu-ee: $(TARGET).hex $(TARGET).eep
  343. ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
  344. dfu-programmer $(MCU) flash --eeprom $(TARGET).eep
  345. else
  346. dfu-programmer $(MCU) flash-eeprom $(TARGET).eep
  347. endif
  348. dfu-programmer $(MCU) reset
  349. # Generate avr-gdb config/init file which does the following:
  350. # define the reset signal, load the target file, connect to target, and set
  351. # a breakpoint at main().
  352. gdb-config:
  353. @$(REMOVE) $(GDBINIT_FILE)
  354. @echo define reset >> $(GDBINIT_FILE)
  355. @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
  356. @echo end >> $(GDBINIT_FILE)
  357. @echo file $(TARGET).elf >> $(GDBINIT_FILE)
  358. @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
  359. ifeq ($(DEBUG_BACKEND),simulavr)
  360. @echo load >> $(GDBINIT_FILE)
  361. endif
  362. @echo break main >> $(GDBINIT_FILE)
  363. debug: gdb-config $(TARGET).elf
  364. ifeq ($(DEBUG_BACKEND), avarice)
  365. @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
  366. @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
  367. $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
  368. @$(WINSHELL) /c pause
  369. else
  370. @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
  371. $(DEBUG_MFREQ) --port $(DEBUG_PORT)
  372. endif
  373. @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
  374. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  375. COFFCONVERT = $(OBJCOPY) --debugging
  376. COFFCONVERT += --change-section-address .data-0x800000
  377. COFFCONVERT += --change-section-address .bss-0x800000
  378. COFFCONVERT += --change-section-address .noinit-0x800000
  379. COFFCONVERT += --change-section-address .eeprom-0x810000
  380. coff: $(TARGET).elf
  381. @echo
  382. @echo $(MSG_COFF) $(TARGET).cof
  383. $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
  384. extcoff: $(TARGET).elf
  385. @echo
  386. @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
  387. $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
  388. # Create final output files (.hex, .eep) from ELF output file.
  389. %.hex: %.elf
  390. @echo
  391. @echo $(MSG_FLASH) $@
  392. $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@
  393. %.eep: %.elf
  394. @echo
  395. @echo $(MSG_EEPROM) $@
  396. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  397. --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
  398. # Create extended listing file from ELF output file.
  399. %.lss: %.elf
  400. @echo
  401. @echo $(MSG_EXTENDED_LISTING) $@
  402. $(OBJDUMP) -h -S -z $< > $@
  403. # Create a symbol table from ELF output file.
  404. %.sym: %.elf
  405. @echo
  406. @echo $(MSG_SYMBOL_TABLE) $@
  407. $(NM) -n $< > $@
  408. # Create library from object files.
  409. .SECONDARY : $(TARGET).a
  410. .PRECIOUS : $(OBJ)
  411. %.a: $(OBJ)
  412. @echo
  413. @echo $(MSG_CREATING_LIBRARY) $@
  414. $(AR) $@ $(OBJ)
  415. # Link: create ELF output file from object files.
  416. .SECONDARY : $(TARGET).elf
  417. .PRECIOUS : $(OBJ)
  418. %.elf: $(OBJ)
  419. @echo
  420. @echo $(MSG_LINKING) $@
  421. $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
  422. # Compile: create object files from C source files.
  423. $(OBJDIR)/%.o : %.c
  424. @echo
  425. mkdir -p $(@D)
  426. @echo $(MSG_COMPILING) $<
  427. $(CC) -c $(ALL_CFLAGS) $< -o $@
  428. # Compile: create object files from C++ source files.
  429. $(OBJDIR)/%.o : %.cpp
  430. @echo
  431. mkdir -p $(@D)
  432. @echo $(MSG_COMPILING_CPP) $<
  433. $(CC) -c $(ALL_CPPFLAGS) $< -o $@
  434. # Compile: create assembler files from C source files.
  435. %.s : %.c
  436. $(CC) -S $(ALL_CFLAGS) $< -o $@
  437. # Compile: create assembler files from C++ source files.
  438. %.s : %.cpp
  439. $(CC) -S $(ALL_CPPFLAGS) $< -o $@
  440. # Assemble: create object files from assembler source files.
  441. $(OBJDIR)/%.o : %.S
  442. @echo
  443. mkdir -p $(@D)
  444. @echo $(MSG_ASSEMBLING) $<
  445. $(CC) -c $(ALL_ASFLAGS) $< -o $@
  446. # Create preprocessed source for use in sending a bug report.
  447. %.i : %.c
  448. $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
  449. # Target: clean project.
  450. clean: begin clean_list end
  451. clean_list :
  452. @echo
  453. $(REMOVE) $(TARGET).hex
  454. $(REMOVE) $(TARGET).eep
  455. $(REMOVE) $(TARGET).cof
  456. $(REMOVE) $(TARGET).elf
  457. $(REMOVE) $(TARGET).map
  458. $(REMOVE) $(TARGET).sym
  459. $(REMOVE) $(TARGET).lss
  460. $(REMOVE) $(OBJ)
  461. $(REMOVE) $(LST)
  462. $(REMOVE) $(OBJ:.o=.s)
  463. $(REMOVE) $(OBJ:.o=.i)
  464. $(REMOVE) -r .dep
  465. $(REMOVE) -r $(OBJDIR)
  466. show_path:
  467. @echo VPATH=$(VPATH)
  468. @echo SRC=$(SRC)
  469. # Create object files directory
  470. $(shell mkdir $(OBJDIR) 2>/dev/null)
  471. # Include the dependency files.
  472. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  473. # Listing of phony targets.
  474. .PHONY : all begin finish end sizebefore sizeafter gccversion \
  475. build elf hex eep lss sym coff extcoff \
  476. clean clean_list debug gdb-config show_path \
  477. program teensy dfu flip dfu-ee flip-ee dfu-start