comparison Makefile @ 11:06bedbe8540d

all these optimisations make it 30% smaller
author Matt Johnston <matt@ucc.asn.au>
date Sat, 19 May 2012 17:15:50 +0800
parents 1bfe28c348dd
children 3c27bfbd7f3a
comparison
equal deleted inserted replaced
10:1bfe28c348dd 11:06bedbe8540d
20 DEVICE = atmega328 20 DEVICE = atmega328
21 PROGDEVICE = atmega328p 21 PROGDEVICE = atmega328p
22 CLOCK = 2000000 22 CLOCK = 2000000
23 PROGRAMMER = #-c stk500v2 -P avrdoper 23 PROGRAMMER = #-c stk500v2 -P avrdoper
24 PROGRAMMER = -c stk500 -P ~/dev/stk500 -p $(PROGDEVICE) -B 2 24 PROGRAMMER = -c stk500 -P ~/dev/stk500 -p $(PROGDEVICE) -B 2
25 OBJS_1WIRE = onewire.o ds18x20.o uart_addon.o crc8.o uart.o 25 SOURCE_1WIRE = onewire.c ds18x20.c uart_addon.c crc8.c uart.c
26 OBJS_SD = ff.o mmc.o 26 SOURCE_SD = ff.c mmc.c
27 OBJECTS = main.o 27 SOURCE = main.c
28 OBJECTS += $(OBJS_1WIRE) 28 SOURCE += $(SOURCE_1WIRE)
29 #OBJECTS += OBJS_SD 29 #SOURCE += $(SOURCE_SD)
30 LIBS = -lm 30 LIBS = -lm
31 31
32 # default but 2mhz 32 # default but 2mhz
33 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x62:m 33 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x62:m
34 34
56 56
57 57
58 # Tune the lines below only if you know what you are doing: 58 # Tune the lines below only if you know what you are doing:
59 59
60 AVRDUDE = avrdude $(PROGRAMMER) 60 AVRDUDE = avrdude $(PROGRAMMER)
61 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues -fdata-sections -ffunction-sections -Wl,--print-gc-sections -Wl,--gc-sections -Wl,--relax 61 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--relax --combine -fwhole-program
62 62
63 # symbolic targets: 63 # symbolic targets:
64 all: main.hex 64 all: main.hex
65 65
66 .c.o: 66 .c.o:
91 91
92 clean: 92 clean:
93 rm -f main.hex main.elf $(OBJECTS) 93 rm -f main.hex main.elf $(OBJECTS)
94 94
95 # file targets: 95 # file targets:
96 main.elf: $(OBJECTS) 96 main.elf: $(SOURCE)
97 $(COMPILE) -o main.elf $(OBJECTS) $(LIBS) 97 $(COMPILE) -o main.elf $(SOURCE) $(LIBS)
98 98
99 main.hex: main.elf 99 main.hex: main.elf
100 rm -f main.hex 100 rm -f main.hex
101 avr-objcopy -j .text -j .data -O ihex main.elf main.hex 101 avr-objcopy -j .text -j .data -O ihex main.elf main.hex
102 avr-size --format=avr --mcu=$(DEVICE) main.elf 102 avr-size --format=avr --mcu=$(DEVICE) main.elf