Advertisement
Guest User

Untitled

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