Keyboard firmwares for Atmel AVR and Cortex-M
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.

пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 11 година
пре 13 година
пре 13 година
пре 11 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 9 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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 += -fno-inline-small-functions
  107. CFLAGS += -fpack-struct
  108. CFLAGS += -fshort-enums
  109. CFLAGS += -fno-strict-aliasing
  110. CFLAGS += -Wall
  111. CFLAGS += -Wstrict-prototypes
  112. #CFLAGS += -mshort-calls
  113. #CFLAGS += -fno-unit-at-a-time
  114. #CFLAGS += -Wundef
  115. #CFLAGS += -Wunreachable-code
  116. #CFLAGS += -Wsign-compare
  117. CFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
  118. CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  119. CFLAGS += $(CSTANDARD)
  120. ifdef CONFIG_H
  121. CFLAGS += -include $(CONFIG_H)
  122. endif
  123. #---------------- Compiler Options C++ ----------------
  124. # -g*: generate debugging information
  125. # -O*: optimization level
  126. # -f...: tuning, see GCC manual and avr-libc documentation
  127. # -Wall...: warning level
  128. # -Wa,...: tell GCC to pass this to the assembler.
  129. # -adhlns...: create assembler listing
  130. CPPFLAGS = -g$(DEBUG)
  131. CPPFLAGS += $(CPPDEFS)
  132. CPPFLAGS += -O$(OPT)
  133. CPPFLAGS += -funsigned-char
  134. CPPFLAGS += -funsigned-bitfields
  135. CPPFLAGS += -fpack-struct
  136. CPPFLAGS += -fshort-enums
  137. CPPFLAGS += -fno-exceptions
  138. CPPFLAGS += -ffunction-sections
  139. CPPFLAGS += -fdata-sections
  140. # to supress "warning: only initialized variables can be placed into program memory area"
  141. CPPFLAGS += -w
  142. CPPFLAGS += -Wall
  143. CPPFLAGS += -Wundef
  144. #CPPFLAGS += -mshort-calls
  145. #CPPFLAGS += -fno-unit-at-a-time
  146. #CPPFLAGS += -Wstrict-prototypes
  147. #CPPFLAGS += -Wunreachable-code
  148. #CPPFLAGS += -Wsign-compare
  149. CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
  150. CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  151. #CPPFLAGS += $(CSTANDARD)
  152. ifdef CONFIG_H
  153. CPPFLAGS += -include $(CONFIG_H)
  154. endif
  155. #---------------- Assembler Options ----------------
  156. # -Wa,...: tell GCC to pass this to the assembler.
  157. # -adhlns: create listing
  158. # -gstabs: have the assembler create line number information; note that
  159. # for use in COFF files, additional information about filenames
  160. # and function names needs to be present in the assembler source
  161. # files -- see avr-libc docs [FIXME: not yet described there]
  162. # -listing-cont-lines: Sets the maximum number of continuation lines of hex
  163. # dump that will be displayed for a given single line of source input.
  164. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100
  165. ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  166. ifdef CONFIG_H
  167. ASFLAGS += -include $(CONFIG_H)
  168. endif
  169. #---------------- Library Options ----------------
  170. # Minimalistic printf version
  171. PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
  172. # Floating point printf version (requires MATH_LIB = -lm below)
  173. PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
  174. # If this is left blank, then it will use the Standard printf version.
  175. PRINTF_LIB =
  176. #PRINTF_LIB = $(PRINTF_LIB_MIN)
  177. #PRINTF_LIB = $(PRINTF_LIB_FLOAT)
  178. # Minimalistic scanf version
  179. SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
  180. # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
  181. SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
  182. # If this is left blank, then it will use the Standard scanf version.
  183. SCANF_LIB =
  184. #SCANF_LIB = $(SCANF_LIB_MIN)
  185. #SCANF_LIB = $(SCANF_LIB_FLOAT)
  186. MATH_LIB = -lm
  187. # List any extra directories to look for libraries here.
  188. # Each directory must be seperated by a space.
  189. # Use forward slashes for directory separators.
  190. # For a directory that has spaces, enclose it in quotes.
  191. EXTRALIBDIRS =
  192. #---------------- External Memory Options ----------------
  193. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  194. # used for variables (.data/.bss) and heap (malloc()).
  195. #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
  196. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  197. # only used for heap (malloc()).
  198. #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff
  199. EXTMEMOPTS =
  200. #---------------- Linker Options ----------------
  201. # -Wl,...: tell GCC to pass this to linker.
  202. # -Map: create map file
  203. # --cref: add cross reference to map file
  204. #
  205. # Comennt out "--relax" option to avoid a error such:
  206. # (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12'
  207. #
  208. LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
  209. #LDFLAGS += -Wl,--relax
  210. LDFLAGS += -Wl,--gc-sections
  211. LDFLAGS += $(EXTMEMOPTS)
  212. LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
  213. LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
  214. #LDFLAGS += -T linker_script.x
  215. # You can give EXTRALDFLAGS at 'make' command line.
  216. LDFLAGS += $(EXTRALDFLAGS)
  217. #---------------- Debugging Options ----------------
  218. # For simulavr only - target MCU frequency.
  219. DEBUG_MFREQ = $(F_CPU)
  220. # Set the DEBUG_UI to either gdb or insight.
  221. # DEBUG_UI = gdb
  222. DEBUG_UI = insight
  223. # Set the debugging back-end to either avarice, simulavr.
  224. DEBUG_BACKEND = avarice
  225. #DEBUG_BACKEND = simulavr
  226. # GDB Init Filename.
  227. GDBINIT_FILE = __avr_gdbinit
  228. # When using avarice settings for the JTAG
  229. JTAG_DEV = /dev/com1
  230. # Debugging port used to communicate between GDB / avarice / simulavr.
  231. DEBUG_PORT = 4242
  232. # Debugging host used to communicate between GDB / avarice / simulavr, normally
  233. # just set to localhost unless doing some sort of crazy debugging when
  234. # avarice is running on a different computer.
  235. DEBUG_HOST = localhost
  236. #============================================================================
  237. # Define programs and commands.
  238. SHELL = sh
  239. CC = avr-gcc
  240. OBJCOPY = avr-objcopy
  241. OBJDUMP = avr-objdump
  242. SIZE = avr-size
  243. AR = avr-ar rcs
  244. NM = avr-nm
  245. REMOVE = rm -f
  246. REMOVEDIR = rmdir
  247. COPY = cp
  248. WINSHELL = cmd
  249. # Define Messages
  250. # English
  251. MSG_ERRORS_NONE = Errors: none
  252. MSG_BEGIN = -------- begin --------
  253. MSG_END = -------- end --------
  254. MSG_SIZE_BEFORE = Size before:
  255. MSG_SIZE_AFTER = Size after:
  256. MSG_COFF = Converting to AVR COFF:
  257. MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
  258. MSG_FLASH = Creating load file for Flash:
  259. MSG_EEPROM = Creating load file for EEPROM:
  260. MSG_EXTENDED_LISTING = Creating Extended Listing:
  261. MSG_SYMBOL_TABLE = Creating Symbol Table:
  262. MSG_LINKING = Linking:
  263. MSG_COMPILING = Compiling C:
  264. MSG_COMPILING_CPP = Compiling C++:
  265. MSG_ASSEMBLING = Assembling:
  266. MSG_CLEANING = Cleaning project:
  267. MSG_CREATING_LIBRARY = Creating library:
  268. # Define all object files.
  269. OBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(patsubst %.cpp,$(OBJDIR)/%.o,$(patsubst %.S,$(OBJDIR)/%.o,$(SRC))))
  270. # Define all listing files.
  271. LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst %.S,$(OBJDIR)/%.lst,$(SRC))))
  272. # Compiler flags to generate dependency files.
  273. #GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d
  274. GENDEPFLAGS = -MMD -MP -MF .dep/$(subst /,_,$@).d
  275. # Combine all necessary flags and optional flags.
  276. # Add target processor to flags.
  277. # You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar
  278. ALL_CFLAGS = -mmcu=$(MCU) $(CFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
  279. ALL_CPPFLAGS = -mmcu=$(MCU) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS)
  280. ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS)
  281. # Default target.
  282. all: begin gccversion sizebefore build sizeafter end
  283. # Change the build target to build a HEX file or a library.
  284. build: elf hex eep lss sym
  285. #build: lib
  286. elf: $(TARGET).elf
  287. hex: $(TARGET).hex
  288. eep: $(TARGET).eep
  289. lss: $(TARGET).lss
  290. sym: $(TARGET).sym
  291. LIBNAME=lib$(TARGET).a
  292. lib: $(LIBNAME)
  293. # Eye candy.
  294. # AVR Studio 3.x does not check make's exit code but relies on
  295. # the following magic strings to be generated by the compile job.
  296. begin:
  297. @echo
  298. @echo $(MSG_BEGIN)
  299. end:
  300. @echo $(MSG_END)
  301. @echo
  302. # Display size of file.
  303. HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
  304. #ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf
  305. ELFSIZE = $(SIZE) $(TARGET).elf
  306. sizebefore:
  307. @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
  308. 2>/dev/null; echo; fi
  309. sizeafter:
  310. @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
  311. 2>/dev/null; echo; fi
  312. # Display compiler version information.
  313. gccversion :
  314. @$(CC) --version
  315. # Program the device.
  316. program: $(TARGET).hex $(TARGET).eep
  317. $(PROGRAM_CMD)
  318. teensy: $(TARGET).hex
  319. teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
  320. flip: $(TARGET).hex
  321. batchisp -hardware usb -device $(MCU) -operation erase f
  322. batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
  323. batchisp -hardware usb -device $(MCU) -operation start reset 0
  324. dfu: $(TARGET).hex
  325. ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
  326. dfu-programmer $(MCU) erase --force
  327. else
  328. dfu-programmer $(MCU) erase
  329. endif
  330. dfu-programmer $(MCU) erase
  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. dfu-programmer $(MCU) eeprom-flash $(TARGET).eep
  344. dfu-programmer $(MCU) reset
  345. # Generate avr-gdb config/init file which does the following:
  346. # define the reset signal, load the target file, connect to target, and set
  347. # a breakpoint at main().
  348. gdb-config:
  349. @$(REMOVE) $(GDBINIT_FILE)
  350. @echo define reset >> $(GDBINIT_FILE)
  351. @echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
  352. @echo end >> $(GDBINIT_FILE)
  353. @echo file $(TARGET).elf >> $(GDBINIT_FILE)
  354. @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE)
  355. ifeq ($(DEBUG_BACKEND),simulavr)
  356. @echo load >> $(GDBINIT_FILE)
  357. endif
  358. @echo break main >> $(GDBINIT_FILE)
  359. debug: gdb-config $(TARGET).elf
  360. ifeq ($(DEBUG_BACKEND), avarice)
  361. @echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
  362. @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \
  363. $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT)
  364. @$(WINSHELL) /c pause
  365. else
  366. @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \
  367. $(DEBUG_MFREQ) --port $(DEBUG_PORT)
  368. endif
  369. @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE)
  370. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  371. COFFCONVERT = $(OBJCOPY) --debugging
  372. COFFCONVERT += --change-section-address .data-0x800000
  373. COFFCONVERT += --change-section-address .bss-0x800000
  374. COFFCONVERT += --change-section-address .noinit-0x800000
  375. COFFCONVERT += --change-section-address .eeprom-0x810000
  376. coff: $(TARGET).elf
  377. @echo
  378. @echo $(MSG_COFF) $(TARGET).cof
  379. $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
  380. extcoff: $(TARGET).elf
  381. @echo
  382. @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
  383. $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
  384. # Create final output files (.hex, .eep) from ELF output file.
  385. %.hex: %.elf
  386. @echo
  387. @echo $(MSG_FLASH) $@
  388. $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@
  389. %.eep: %.elf
  390. @echo
  391. @echo $(MSG_EEPROM) $@
  392. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  393. --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0
  394. # Create extended listing file from ELF output file.
  395. %.lss: %.elf
  396. @echo
  397. @echo $(MSG_EXTENDED_LISTING) $@
  398. $(OBJDUMP) -h -S -z $< > $@
  399. # Create a symbol table from ELF output file.
  400. %.sym: %.elf
  401. @echo
  402. @echo $(MSG_SYMBOL_TABLE) $@
  403. $(NM) -n $< > $@
  404. # Create library from object files.
  405. .SECONDARY : $(TARGET).a
  406. .PRECIOUS : $(OBJ)
  407. %.a: $(OBJ)
  408. @echo
  409. @echo $(MSG_CREATING_LIBRARY) $@
  410. $(AR) $@ $(OBJ)
  411. # Link: create ELF output file from object files.
  412. .SECONDARY : $(TARGET).elf
  413. .PRECIOUS : $(OBJ)
  414. %.elf: $(OBJ)
  415. @echo
  416. @echo $(MSG_LINKING) $@
  417. $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)
  418. # Compile: create object files from C source files.
  419. $(OBJDIR)/%.o : %.c
  420. @echo
  421. mkdir -p $(@D)
  422. @echo $(MSG_COMPILING) $<
  423. $(CC) -c $(ALL_CFLAGS) $< -o $@
  424. # Compile: create object files from C++ source files.
  425. $(OBJDIR)/%.o : %.cpp
  426. @echo
  427. mkdir -p $(@D)
  428. @echo $(MSG_COMPILING_CPP) $<
  429. $(CC) -c $(ALL_CPPFLAGS) $< -o $@
  430. # Compile: create assembler files from C source files.
  431. %.s : %.c
  432. $(CC) -S $(ALL_CFLAGS) $< -o $@
  433. # Compile: create assembler files from C++ source files.
  434. %.s : %.cpp
  435. $(CC) -S $(ALL_CPPFLAGS) $< -o $@
  436. # Assemble: create object files from assembler source files.
  437. $(OBJDIR)/%.o : %.S
  438. @echo
  439. mkdir -p $(@D)
  440. @echo $(MSG_ASSEMBLING) $<
  441. $(CC) -c $(ALL_ASFLAGS) $< -o $@
  442. # Create preprocessed source for use in sending a bug report.
  443. %.i : %.c
  444. $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@
  445. # Target: clean project.
  446. clean: begin clean_list end
  447. clean_list :
  448. @echo
  449. $(REMOVE) $(TARGET).hex
  450. $(REMOVE) $(TARGET).eep
  451. $(REMOVE) $(TARGET).cof
  452. $(REMOVE) $(TARGET).elf
  453. $(REMOVE) $(TARGET).map
  454. $(REMOVE) $(TARGET).sym
  455. $(REMOVE) $(TARGET).lss
  456. $(REMOVE) $(OBJ)
  457. $(REMOVE) $(LST)
  458. $(REMOVE) $(OBJ:.o=.s)
  459. $(REMOVE) $(OBJ:.o=.i)
  460. $(REMOVE) -r .dep
  461. $(REMOVE) -r $(OBJDIR)
  462. show_path:
  463. @echo VPATH=$(VPATH)
  464. @echo SRC=$(SRC)
  465. # Create object files directory
  466. $(shell mkdir $(OBJDIR) 2>/dev/null)
  467. # Include the dependency files.
  468. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  469. # Listing of phony targets.
  470. .PHONY : all begin finish end sizebefore sizeafter gccversion \
  471. build elf hex eep lss sym coff extcoff \
  472. clean clean_list debug gdb-config show_path \
  473. program teensy dfu flip dfu-ee flip-ee dfu-start