diff options
Diffstat (limited to 'src/Makefile')
-rwxr-xr-x | src/Makefile | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100755 index 0000000..ca05759 --- /dev/null +++ b/src/Makefile | |||
@@ -0,0 +1,75 @@ | |||
1 | AVRPATH = /usr/bin/ | ||
2 | # AVRPATH = C:/WinAVR-20100110/bin/ | ||
3 | |||
4 | CC = $(AVRPATH)avr-gcc | ||
5 | OBJCOPY = $(AVRPATH)avr-objcopy | ||
6 | AVRSTRIP = $(AVRPATH)avr-strip | ||
7 | AVRDUDE = $(AVRPATH)avrdude | ||
8 | AVRSIZE = $(AVRPATH)avr-size | ||
9 | AVRNM = $(AVRPATH)avr-nm | ||
10 | |||
11 | PRG = main | ||
12 | PATH = output/ | ||
13 | |||
14 | |||
15 | MCU_TARGET = atmega16 | ||
16 | # F_CPU = 7372800UL | ||
17 | #F_CPU = 4000000UL | ||
18 | # F_CPU = 8000000UL | ||
19 | F_CPU = 12000000UL | ||
20 | # F_CPU = 12288000UL | ||
21 | #F_CPU = 20000000UL | ||
22 | |||
23 | # | ||
24 | override CFLAGS = -Wall -gstabs+ -Os -mcall-prologues -fshort-enums -msize -fno-jump-tables -std=c99 -Wunsafe-loop-optimizations -mmcu=$(MCU_TARGET) | ||
25 | #override PENIBL = -Wunused-parameter -Wunsafe-loop-optimizations -funsafe-loop-optimizations -Wextra -Wpadded -Wredundant-decls -Winline -Werror -nodefaultlibs -nostdlib | ||
26 | override PREPRO = -DF_CPU=$(F_CPU) -DBAUD=19200 | ||
27 | override LDFLAGS = -Wl,-Map,$(PATH)$(PRG).map | ||
28 | override STDOUT = -DSTDOUT_put_string -DSTDOUT_put_uint inc/stdout.c | ||
29 | # override STDALG = -DSTDALGO_CRC7 inc/stdalg.c | ||
30 | # -DSTDOUT_putf | ||
31 | |||
32 | |||
33 | #/ FATFS_PATH = inc/spi/dev/petit_fatfs/avr/ | ||
34 | #/ ASRC = $(FATFS_PATH)xitoa.S $(FATFS_PATH)usi.S | ||
35 | #/ OBJ = $(CSRC:.c=.o) $(ASRC:.S=.o) | ||
36 | |||
37 | #/ ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs | ||
38 | #/ ALL_ASFLAGS = -mmcu=$(MCU_TARGET) -I. -x assembler-with-cpp $(ASFLAGS) | ||
39 | |||
40 | |||
41 | # inc/spi/dev/petit_fatfs/avr/pff.c inc/spi/dev/memory_sdcard.c | ||
42 | # inc/uart/uart.c \ | ||
43 | #/ inc/spi/dev/petit/pff.c \ | ||
44 | #/ inc/spi/dev/petit/diskio.c | ||
45 | #/ inc/spi/dev/audio_vs1011.c | ||
46 | |||
47 | $(PATH)$(PRG).elf: clean | ||
48 | $(CC) -o$(PATH)$(PRG).elf $(PREPRO) $(CFLAGS) $(LDFLAGS) $(DEBUG) $(STDOUT) $(STDALG) \ | ||
49 | $(PRG).c \ | ||
50 | inc/spi/spi.c \ | ||
51 | inc/int/dcf77/clock.c \ | ||
52 | inc/spi/dev/display_dogm.c | ||
53 | @$(AVRNM) --size-sort -l ./output/$(PRG).elf | ||
54 | @$(AVRSIZE) -d ./output/$(PRG).elf | ||
55 | #@$(AVRSIZE) -C --mcu=$(MCU_TARGET) ./output/$(TARGET).elf | ||
56 | |||
57 | %.hex: $(PATH)%.elf | ||
58 | $(OBJCOPY) -S -j.text -j.data -Oihex $< $(PATH)$@ | ||
59 | |||
60 | #/ %.o : %.S | ||
61 | #/ $(CC) -c $(ALL_ASFLAGS) $< -o $@ | ||
62 | |||
63 | upload: clean $(PRG).hex | ||
64 | # skip: -e (erase, because ATMega doesn't need it and avrdude checks this automatically) | ||
65 | $(AVRDUDE) -cavrispv2 -b115200 -pm16 -Pusb -e -V -U ./output/$(PRG).hex | ||
66 | |||
67 | upload_mp3: | ||
68 | $(AVRDUDE) -cavrispv2 -pm16 -Pusb -V -F -Ueeprom:w:accessdenied.mp3 | ||
69 | |||
70 | clean: | ||
71 | $(shell rm -f $(PATH)$(PRG).elf) | ||
72 | $(shell rm -f $(PATH)$(PRG).hex) | ||
73 | $(shell rm -f $(PATH)$(PRG).map) | ||
74 | |||
75 | #avr-gcc -o./output/main.elf -DF_CPU=7372800UL -DBAUD=9600 -DSTDOUT_reverse_bits -DSTDOUT_put_int -DSTDOUT_put_string -g -Wall -std=c99 -Os -mmcu=atmega16 -Wl,-Map,./output/main.map ./inc/display/dog.c main.c ./inc/dcf77/clock.c ./inc/stdout.c | ||