Added experimental makepkg-update-checksums.sh
[mirrors/Programs.git] / c / tv-b-gone / Makefile
1 # MCU name
2 MCU = attiny85
3 F_CPU = 8000000
4
5 # Output format. (can be srec, ihex, binary)
6 FORMAT = ihex
7
8 # Target file name (without extension).
9 TARGET = tvbgone
10
11 # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
12 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
13 OPT = s
14
15 # List C source files here. (C dependencies are automatically generated.)
16 SRC = main.c NAcodes.c #util.c
17
18 # List Assembler source files here.
19 # Make them always end in a capital .S. Files ending in a lowercase .s
20 # will not be considered source files but generated files (assembler
21 # output from the compiler), and will be deleted upon "make clean"!
22 # Even though the DOS/Win filesystem matches both .s and .S the same,
23 # it will preserve the spelling of the filenames, and gcc itself does
24 # care about how the name is spelled on its command-line.
25 # Optional compiler flags.
26 # -g: generate debugging information (for GDB, or for COFF conversion)
27 # -O*: optimization level
28 # -f...: tuning, see gcc manual and avr-libc documentation
29 # -Wall...: warning level
30 # -Wa,...: tell GCC to pass this to the assembler.
31 # -ahlms: create assembler listing
32 CFLAGS = -g -O$(OPT) \
33 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
34 -Wall -Wstrict-prototypes \
35 -DF_CPU=$(F_CPU) \
36 -Wa,-adhlns=$(<:.c=.lst) \
37 $(patsubst %,-I%,$(EXTRAINCDIRS))
38
39
40 # Set a "language standard" compiler flag.
41 # Unremark just one line below to set the language standard to use.
42 # gnu99 = C99 + GNU extensions. See GCC manual for more information.
43 #CFLAGS += -std=c89
44 #CFLAGS += -std=gnu89
45 #CFLAGS += -std=c99
46 CFLAGS += -std=gnu99
47
48
49
50 # Optional assembler flags.
51 # -Wa,...: tell GCC to pass this to the assembler.
52 # -ahlms: create listing
53 # -gstabs: have the assembler create line number information; note that
54 # for use in COFF files, additional information about filenames
55 # and function names needs to be present in the assembler source
56 # files -- see avr-libc docs [FIXME: not yet described there]
57 ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
58
59
60
61 # Optional linker flags.
62 # -Wl,...: tell GCC to pass this to linker.
63 # -Map: create map file
64 # --cref: add cross reference to map file
65 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
66
67
68
69 # Additional libraries
70
71 # Minimalistic printf version
72 #LDFLAGS += -Wl,-u,vfprintf -lprintf_min
73
74 # Floating point printf version (requires -lm below)
75 #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
76
77 # -lm = math library
78 LDFLAGS += -lm
79
80
81
82 # Programming support using avrdude. Settings and variables.
83
84 # Programming hardware: alf avr910 avrisp bascom bsd
85 # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
86 #
87 # Type: avrdude -c ?
88 # to get a full listing.
89 #
90 #
91
92 AVRDUDE_PROGRAMMER = usbtiny
93 AVRDUDE_PROGRAMMER = dt006
94
95 #AVRDUDE_PORT = usb # programmer connected to serial device
96 AVRDUDE_PORT = lpt1
97
98 AVRDUDE_WRITE_FLASH = -B 1 -U flash:w:$(TARGET).hex
99 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
100
101 AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
102
103 # Uncomment the following if you want avrdude's erase cycle counter.
104 # Note that this counter needs to be initialized first using -Yn,
105 # see avrdude manual.
106 #AVRDUDE_ERASE += -y
107
108 # Uncomment the following if you do /not/ wish a verification to be
109 # performed after programming the device.
110 #AVRDUDE_FLAGS += -V
111
112 # Increase verbosity level. Please use this when submitting bug
113 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
114 # to submit bug reports.
115 #AVRDUDE_FLAGS += -v -v
116
117
118
119
120 # ---------------------------------------------------------------------------
121
122 # Define directories, if needed.
123 DIRAVR = c:/winavr
124 DIRAVRBIN = $(DIRAVR)/bin
125 DIRAVRUTILS = $(DIRAVR)/utils/bin
126 DIRINC = .
127 DIRLIB = $(DIRAVR)/avr/lib
128
129
130 # Define programs and commands.
131 SHELL = sh
132
133 CC = avr-gcc
134
135 OBJCOPY = avr-objcopy
136 OBJDUMP = avr-objdump
137 SIZE = avr-size
138
139
140 # Programming support using avrdude.
141 AVRDUDE = avrdude
142
143
144 REMOVE = rm -f
145 COPY = cp
146
147 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
148 ELFSIZE = $(SIZE) -A $(TARGET).elf
149
150
151
152 # Define Messages
153 # English
154 MSG_ERRORS_NONE = Errors: none
155 MSG_BEGIN = -------- begin --------
156 MSG_END = -------- end --------
157 MSG_SIZE_BEFORE = Size before:
158 MSG_SIZE_AFTER = Size after:
159 MSG_COFF = Converting to AVR COFF:
160 MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
161 MSG_FLASH = Creating load file for Flash:
162 MSG_EEPROM = Creating load file for EEPROM:
163 MSG_EXTENDED_LISTING = Creating Extended Listing:
164 MSG_SYMBOL_TABLE = Creating Symbol Table:
165 MSG_LINKING = Linking:
166 MSG_COMPILING = Compiling:
167 MSG_ASSEMBLING = Assembling:
168 MSG_CLEANING = Cleaning project:
169
170
171
172
173 # Define all object files.
174 OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
175
176 # Define all listing files.
177 LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
178
179 # Combine all necessary flags and optional flags.
180 # Add target processor to flags.
181 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
182 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
183
184
185
186 # Default target.
187 all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
188 $(TARGET).lss $(TARGET).sym sizeafter finished end
189
190
191 # Eye candy.
192 # AVR Studio 3.x does not check make's exit code but relies on
193 # the following magic strings to be generated by the compile job.
194 begin:
195 @echo
196 @echo $(MSG_BEGIN)
197
198 finished:
199 @echo $(MSG_ERRORS_NONE)
200
201 end:
202 @echo $(MSG_END)
203 @echo
204
205
206 # Display size of file.
207 sizebefore:
208 @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
209
210 sizeafter:
211 @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
212
213
214
215 # Display compiler version information.
216 gccversion :
217 @$(CC) --version
218
219
220
221
222 # Convert ELF to COFF for use in debugging / simulating in
223 # AVR Studio or VMLAB.
224 COFFCONVERT=$(OBJCOPY) --debugging \
225 --change-section-address .data-0x800000 \
226 --change-section-address .bss-0x800000 \
227 --change-section-address .noinit-0x800000 \
228 --change-section-address .eeprom-0x810000
229
230
231 coff: $(TARGET).elf
232 @echo
233 @echo $(MSG_COFF) $(TARGET).cof
234 $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
235
236
237 extcoff: $(TARGET).elf
238 @echo
239 @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
240 $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
241
242
243
244 reset:
245 $(AVRDUDE) $(AVRDUDE_FLAGS)
246
247 # Program the device.
248 program: $(TARGET).hex $(TARGET).eep
249 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
250
251 full: $(TARGET).hex
252 make burn-fuse
253 make program
254
255 burn-fuse:
256 $(AVRDUDE) $(AVRDUDE_FLAGS) -B 250 -u -U lfuse:w:0xfd:m -U hfuse:w:0xde:m
257
258 read-fuse:
259 $(AVRDUDE) $(AVRDUDE_FLAGS) -u -U lfuse:r:l.txt:r
260 $(AVRDUDE) $(AVRDUDE_FLAGS) -u -U hfuse:r:h.txt:r
261 $(AVRDUDE) $(AVRDUDE_FLAGS) -u -U efuse:r:e.txt:r
262 # Create final output files (.hex, .eep) from ELF output file.
263 %.hex: %.elf
264 @echo
265 @echo $(MSG_FLASH) $@
266 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
267
268 %.eep: %.elf
269 @echo
270 @echo $(MSG_EEPROM) $@
271 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
272 --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
273
274 # Create extended listing file from ELF output file.
275 %.lss: %.elf
276 @echo
277 @echo $(MSG_EXTENDED_LISTING) $@
278 $(OBJDUMP) -h -S $< > $@
279
280 # Create a symbol table from ELF output file.
281 %.sym: %.elf
282 @echo
283 @echo $(MSG_SYMBOL_TABLE) $@
284 avr-nm -n $< > $@
285
286
287
288 # Link: create ELF output file from object files.
289 .SECONDARY : $(TARGET).elf
290 .PRECIOUS : $(OBJ)
291 %.elf: $(OBJ)
292 @echo
293 @echo $(MSG_LINKING) $@
294 $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
295
296
297 # Compile: create object files from C source files.
298 %.o : %.c
299 @echo
300 @echo $(MSG_COMPILING) $<
301 $(CC) -c $(ALL_CFLAGS) $< -o $@
302
303
304 # Compile: create assembler files from C source files.
305 %.s : %.c
306 $(CC) -S $(ALL_CFLAGS) $< -o $@
307
308
309 # Assemble: create object files from assembler source files.
310 %.o : %.S
311 @echo
312 @echo $(MSG_ASSEMBLING) $<
313 $(CC) -c $(ALL_ASFLAGS) $< -o $@
314
315
316
317
318
319
320 # Target: clean project.
321 clean: begin clean_list finished end
322
323 clean_list :
324 @echo
325 @echo $(MSG_CLEANING)
326 $(REMOVE) $(TARGET).hex
327 $(REMOVE) $(TARGET).eep
328 $(REMOVE) $(TARGET).obj
329 $(REMOVE) $(TARGET).cof
330 $(REMOVE) $(TARGET).elf
331 $(REMOVE) $(TARGET).map
332 $(REMOVE) $(TARGET).obj
333 $(REMOVE) $(TARGET).a90
334 $(REMOVE) $(TARGET).sym
335 $(REMOVE) $(TARGET).lnk
336 $(REMOVE) $(TARGET).lss
337 $(REMOVE) $(OBJ)
338 $(REMOVE) $(LST)
339 $(REMOVE) $(SRC:.c=.s)
340 $(REMOVE) $(SRC:.c=.d)
341
342
343 # Automatically generate C source code dependencies.
344 # (Code originally taken from the GNU make user manual and modified
345 # (See README.txt Credits).)
346 #
347 # Note that this will work with sh (bash) and sed that is shipped with WinAVR
348 # (see the SHELL variable defined above).
349 # This may not work with other shells or other seds.
350 #
351 %.d: %.c
352 set -e; $(CC) -MM $(ALL_CFLAGS) $< \
353 | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
354 [ -s $@ ] || rm -f $@
355
356
357 # Remove the '-' if you want to see the dependency files generated.
358 -include $(SRC:.c=.d)
359
360
361
362 # Listing of phony targets.
363 .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
364 clean clean_list program
This page took 2.333437 seconds and 4 git commands to generate.