Simple single-color 8x8x8 LED Cube with AVRs
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

makefile 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. # Makefile
  2. #
  3. # On command line:
  4. #
  5. # make all = Make software.
  6. #
  7. # make clean = Clean out built project files.
  8. #
  9. # make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
  10. #
  11. # make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
  12. # 4.07 or greater).
  13. #
  14. # make program = Download the hex file to the device, using avrdude. Please
  15. # customize the avrdude settings below first!
  16. #
  17. # make filename.s = Just compile filename.c into the assembler code only
  18. #
  19. # To rebuild project do "make clean" then "make all".
  20. #
  21. # MCU name
  22. MCU = atmega8
  23. # Main Oscillator Frequency
  24. # This is only used to define F_OSC in all assembler and c-sources.
  25. F_CPU = 16000000
  26. # Output format. (can be srec, ihex, binary)
  27. FORMAT = ihex
  28. # Target file name (without extension).
  29. TARGET = main
  30. # List C source files here. (C dependencies are automatically generated.)
  31. SRC = $(TARGET).c
  32. SRC += adc.c # Additional Source-File
  33. SRC += eq.c
  34. SRC += twislave.c
  35. # List Assembler source files here.
  36. # Make them always end in a capital .S. Files ending in a lowercase .s
  37. # will not be considered source files but generated files (assembler
  38. # output from the compiler), and will be deleted upon "make clean"!
  39. # Even though the DOS/Win* filesystem matches both .s and .S the same,
  40. # it will preserve the spelling of the filenames, and gcc itself does
  41. # care about how the name is spelled on its command-line.
  42. ASRC =
  43. # Optimization level, can be [0, 1, 2, 3, s].
  44. # 0 = turn off optimization. s = optimize for size.
  45. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
  46. OPT = s
  47. # Debugging format.
  48. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
  49. # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
  50. #DEBUG = stabs
  51. DEBUG = dwarf-2
  52. # List any extra directories to look for include files here.
  53. # Each directory must be seperated by a space.
  54. EXTRAINCDIRS =
  55. # Compiler flag to set the C Standard level.
  56. # c89 - "ANSI" C
  57. # gnu89 - c89 plus GCC extensions
  58. # c99 - ISO C99 standard (not yet fully implemented)
  59. # gnu99 - c99 plus GCC extensions
  60. CSTANDARD = -std=gnu99
  61. # Place -D or -U options here
  62. CDEFS =
  63. # Place -I options here
  64. CINCS =
  65. # Compiler flags.
  66. # -g*: generate debugging information
  67. # -O*: optimization level
  68. # -f...: tuning, see GCC manual and avr-libc documentation
  69. # -Wall...: warning level
  70. # -Wa,...: tell GCC to pass this to the assembler.
  71. # -adhlns...: create assembler listing
  72. #CFLAGS = -g$(DEBUG)
  73. CFLAGS = $(CDEFS) $(CINCS)
  74. CFLAGS += -O$(OPT)
  75. CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
  76. CFLAGS += -Wall -Wstrict-prototypes
  77. CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
  78. CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
  79. CFLAGS += $(CSTANDARD)
  80. CFLAGS += -DF_CPU=$(F_CPU)
  81. # Assembler flags.
  82. # -Wa,...: tell GCC to pass this to the assembler.
  83. # -ahlms: create listing
  84. # -gstabs: have the assembler create line number information; note that
  85. # for use in COFF files, additional information about filenames
  86. # and function names needs to be present in the assembler source
  87. # files -- see avr-libc docs [FIXME: not yet described there]
  88. ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
  89. ASFLAGS += -DF_CPU=$(F_CPU)
  90. #Additional libraries.
  91. # Minimalistic printf version
  92. PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
  93. # Floating point printf version (requires MATH_LIB = -lm below)
  94. PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
  95. PRINTF_LIB =
  96. # Minimalistic scanf version
  97. SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
  98. # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
  99. SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
  100. SCANF_LIB =
  101. MATH_LIB = -lm
  102. # External memory options
  103. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  104. # used for variables (.data/.bss) and heap (malloc()).
  105. #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
  106. # 64 KB of external RAM, starting after internal RAM (ATmega128!),
  107. # only used for heap (malloc()).
  108. #EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
  109. EXTMEMOPTS =
  110. # Linker flags.
  111. # -Wl,...: tell GCC to pass this to linker.
  112. # -Map: create map file
  113. # --cref: add cross reference to map file
  114. LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
  115. LDFLAGS += $(EXTMEMOPTS)
  116. LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
  117. # Programming support using avrdude. Settings and variables.
  118. # Programming hardware: alf avr910 avrisp bascom bsd
  119. # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
  120. #
  121. # Type: avrdude -c ?
  122. # to get a full listing.
  123. #
  124. AVRDUDE_PROGRAMMER = stk500
  125. # com1 = serial port. Use lpt1 to connect to parallel port.
  126. AVRDUDE_PORT = com1 # programmer connected to serial device
  127. AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
  128. #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
  129. # Uncomment the following if you want avrdude's erase cycle counter.
  130. # Note that this counter needs to be initialized first using -Yn,
  131. # see avrdude manual.
  132. #AVRDUDE_ERASE_COUNTER = -y
  133. # Uncomment the following if you do /not/ wish a verification to be
  134. # performed after programming the device.
  135. #AVRDUDE_NO_VERIFY = -V
  136. # Increase verbosity level. Please use this when submitting bug
  137. # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
  138. # to submit bug reports.
  139. #AVRDUDE_VERBOSE = -v -v
  140. AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
  141. AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
  142. AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
  143. AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
  144. # ---------------------------------------------------------------------------
  145. # Define directories, if needed.
  146. DIRAVR = /usr/local/CrossPack-AVR
  147. DIRAVRBIN = $(DIRAVR)/bin
  148. DIRAVRUTILS = $(DIRAVR)/bin
  149. DIRINC = .
  150. DIRLIB = $(DIRAVR)/lib
  151. # Define programs and commands.
  152. SHELL = bash
  153. CC = avr-gcc
  154. OBJCOPY = avr-objcopy
  155. OBJDUMP = avr-objdump
  156. SIZE = avr-size
  157. NM = avr-nm
  158. AVRDUDE = avrdude
  159. REMOVE = rm -f
  160. COPY = cp
  161. # Define Messages
  162. # English
  163. MSG_ERRORS_NONE = Errors: none
  164. MSG_BEGIN = -------- begin --------
  165. MSG_END = -------- end --------
  166. MSG_SIZE_BEFORE = Size before:
  167. MSG_SIZE_AFTER = Size after:
  168. MSG_COFF = Converting to AVR COFF:
  169. MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
  170. MSG_FLASH = Creating load file for Flash:
  171. MSG_EEPROM = Creating load file for EEPROM:
  172. MSG_EXTENDED_LISTING = Creating Extended Listing:
  173. MSG_SYMBOL_TABLE = Creating Symbol Table:
  174. MSG_LINKING = Linking:
  175. MSG_COMPILING = Compiling:
  176. MSG_ASSEMBLING = Assembling:
  177. MSG_CLEANING = Cleaning project:
  178. # Define all object files.
  179. OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
  180. # Define all listing files.
  181. LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
  182. # Compiler flags to generate dependency files.
  183. ### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
  184. GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
  185. # Combine all necessary flags and optional flags.
  186. # Add target processor to flags.
  187. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
  188. ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
  189. # Default target.
  190. all: begin gccversion sizebefore build sizeafter finished end clean_list
  191. build: elf hex eep lss sym
  192. elf: $(TARGET).elf
  193. hex: $(TARGET).hex
  194. eep: $(TARGET).eep
  195. lss: $(TARGET).lss
  196. sym: $(TARGET).sym
  197. # Eye candy.
  198. # AVR Studio 3.x does not check make's exit code but relies on
  199. # the following magic strings to be generated by the compile job.
  200. begin:
  201. @echo
  202. @echo $(MSG_BEGIN)
  203. finished:
  204. @echo $(MSG_ERRORS_NONE)
  205. end:
  206. @echo $(MSG_END)
  207. @echo
  208. # Display size of file.
  209. HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
  210. ELFSIZE = $(SIZE) -A $(TARGET).elf
  211. sizebefore:
  212. @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
  213. sizeafter:
  214. @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
  215. # Display compiler version information.
  216. gccversion :
  217. @$(CC) --version
  218. # Program the device.
  219. program: $(TARGET).hex $(TARGET).eep
  220. $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
  221. # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
  222. COFFCONVERT=$(OBJCOPY) --debugging \
  223. --change-section-address .data-0x800000 \
  224. --change-section-address .bss-0x800000 \
  225. --change-section-address .noinit-0x800000 \
  226. --change-section-address .eeprom-0x810000
  227. coff: $(TARGET).elf
  228. @echo
  229. @echo $(MSG_COFF) $(TARGET).cof
  230. $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
  231. extcoff: $(TARGET).elf
  232. @echo
  233. @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
  234. $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
  235. # Create final output files (.hex, .eep) from ELF output file.
  236. %.hex: %.elf
  237. @echo
  238. @echo $(MSG_FLASH) $@
  239. $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
  240. %.eep: %.elf
  241. @echo
  242. @echo $(MSG_EEPROM) $@
  243. -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
  244. --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
  245. # Create extended listing file from ELF output file.
  246. %.lss: %.elf
  247. @echo
  248. @echo $(MSG_EXTENDED_LISTING) $@
  249. $(OBJDUMP) -h -S $< > $@
  250. # Create a symbol table from ELF output file.
  251. %.sym: %.elf
  252. @echo
  253. @echo $(MSG_SYMBOL_TABLE) $@
  254. $(NM) -n $< > $@
  255. # Link: create ELF output file from object files.
  256. .SECONDARY : $(TARGET).elf
  257. .PRECIOUS : $(OBJ)
  258. %.elf: $(OBJ)
  259. @echo
  260. @echo $(MSG_LINKING) $@
  261. $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
  262. # Compile: create object files from C source files.
  263. %.o : %.c
  264. @echo
  265. @echo $(MSG_COMPILING) $<
  266. $(CC) -c $(ALL_CFLAGS) $< -o $@
  267. # Compile: create assembler files from C source files.
  268. %.s : %.c
  269. $(CC) -S $(ALL_CFLAGS) $< -o $@
  270. # Assemble: create object files from assembler source files.
  271. %.o : %.S
  272. @echo
  273. @echo $(MSG_ASSEMBLING) $<
  274. $(CC) -c $(ALL_ASFLAGS) $< -o $@
  275. # Target: clean project.
  276. clean: begin clean_2 finished end
  277. clean_2: clean_list
  278. $(REMOVE) $(TARGET).hex
  279. clean_list :
  280. @echo
  281. @echo $(MSG_CLEANING)
  282. $(REMOVE) $(TARGET).eep
  283. $(REMOVE) $(TARGET).obj
  284. $(REMOVE) $(TARGET).cof
  285. $(REMOVE) $(TARGET).elf
  286. $(REMOVE) $(TARGET).map
  287. $(REMOVE) $(TARGET).obj
  288. $(REMOVE) $(TARGET).a90
  289. $(REMOVE) $(TARGET).sym
  290. $(REMOVE) $(TARGET).lnk
  291. $(REMOVE) $(TARGET).lss
  292. $(REMOVE) $(OBJ)
  293. $(REMOVE) $(LST)
  294. $(REMOVE) $(SRC:.c=.s)
  295. $(REMOVE) $(SRC:.c=.d)
  296. $(REMOVE) .dep/*
  297. # Include the dependency files.
  298. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  299. # Listing of phony targets.
  300. .PHONY : all begin finish end sizebefore sizeafter gccversion \
  301. build elf hex eep lss sym coff extcoff \
  302. clean clean_list program