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.

Makefile.common 17KB

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