Cores, decoder, uart, ioports - lots of changes
[simavr] / simavr / Makefile
1 #
2 #       Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
3 #
4 #       This file is part of simavr.
5 #
6 #       simavr is free software: you can redistribute it and/or modify
7 #       it under the terms of the GNU General Public License as published by
8 #       the Free Software Foundation, either version 3 of the License, or
9 #       (at your option) any later version.
10 #
11 #       simavr is distributed in the hope that it will be useful,
12 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #       GNU General Public License for more details.
15 #
16 #       You should have received a copy of the GNU General Public License
17 #       along with simavr.  If not, see <http://www.gnu.org/licenses/>.
18
19 target  = simavr
20
21 CFLAGS  =  -g -std=gnu99 -Wall
22 CFLAGS  += -O3  -mfpmath=sse -msse2
23
24 cores   = ${wildcard cores/*.c}
25 cores_o = ${patsubst cores/%.c, obj/%.o, ${cores}}
26 sim             = ${wildcard sim/*.c}
27 sim_o   = ${patsubst sim/%.c, obj/%.o, ${sim}}
28
29 VPATH   = .
30 VPATH   += cores
31 VPATH   += sim
32
33 IPATH   = .
34 IPATH   += sim
35 IPATH   += ../../shared
36 IPATH   += ../include
37 IPATH   += /opt/local/include
38
39 CFLAGS  += ${patsubst %,-I%,${subst :, ,${IPATH}}}
40 LFLAGS  = -L/opt/local/lib/
41 LDFLAGS += -lelf
42
43 all:    obj ${target}
44
45 obj:
46         @mkdir -p obj
47
48 obj/sim_%.o : cores/sim_%.h ${wildcard cores/*.h} ${wildcard sim/*.h}
49 obj/sim_%.o : cores/sim_%.c
50         @gcc $(CFLAGS) \
51                 -I/usr/lib/avr/include/ \
52                 $<  -c -o $@
53         @echo CORE $<
54
55 obj/%.o: %.h sim/*.h
56 obj/%.o: %.c
57         @gcc $(CFLAGS) \
58                 $<  -c -o $@
59         @echo CC $<
60         
61 ${target}       :       ${cores_o}
62 ${target}       :       ${sim_o}
63         @gcc $(CFLAGS) $(LFLAGS) \
64                 ${^} -o $@ \
65                  $(LDFLAGS)
66         @echo LD $@
67
68 clean:
69         rm -rf ${target} obj
70