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

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