Initial Commit
[simavr] / tests / Makefile
1 #
2 # This makefile take each "at*" file, extracts it's part name
3 # And compile it into an ELF binary.
4 # It also disassemble it for debugging purposes.
5
6 # The code is compiled "optimized" to the max.
7
8 # The wierd "-Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000"
9 # is used to tell the linker not to discard the .mmcu section,
10 # otherwise the --gc-sections will delete it.
11
12 #       Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
13 #
14 #       This file is part of simavr.
15 #
16 #       simavr is free software: you can redistribute it and/or modify
17 #       it under the terms of the GNU General Public License as published by
18 #       the Free Software Foundation, either version 3 of the License, or
19 #       (at your option) any later version.
20 #
21 #       simavr is distributed in the hope that it will be useful,
22 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
23 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 #       GNU General Public License for more details.
25 #
26 #       You should have received a copy of the GNU General Public License
27 #       along with simavr.  If not, see <http://www.gnu.org/licenses/>.
28
29 sources         := $(wildcard at*.c)
30
31 all :  ${sources:.c=.axf} ${sources:.c=.hex}  ${sources:.c=.s}  
32
33 %.hex: %.axf
34                 @avr-objcopy -j .text -j .data -O ihex ${<} ${@}
35
36 %.s: %.axf
37                 @avr-objdump -j .text -j .data -j .bss -d  ${<} > ${@}
38
39 %.axf: %.c 
40                 @echo CC ${<}
41                 @part=${<} ; part=$${part/_*}; \
42                 avr-gcc -Wall -g -Os -std=gnu99 \
43                                 -mmcu=$$part \
44                                 -DF_CPU=8000000 \
45                                 -mcall-prologues -fno-inline-small-functions \
46                                 -ffunction-sections -fdata-sections \
47                                 -Wl,--relax,--gc-sections \
48                                 -Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000 \
49                                 -I../include \
50                                 ${<} -o ${@}
51                 @avr-size ${@}|sed '1d'
52
53 clean:
54         rm -f *.hex *.o *.axf *.s