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

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