Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Makefile 17KB

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