2 # Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
4 # This file is part of simavr.
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.
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.
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/>.
21 CFLAGS += -O3 -Wall -Werror
23 # tracing id useful especialy if you develop simavr core.
24 # it otherwise eat quite a bit of few cycles, even disabled
25 #CFLAGS += -DCONFIG_SIMAVR_TRACE=1
27 all: obj libsimavr ${target}
29 include ../Makefile.common
31 cores = ${wildcard cores/*.c}
32 cores_o = ${patsubst cores/%.c, ${OBJ}/%.o, ${cores}}
33 sim = ${wildcard sim/sim_*.c} ${wildcard sim/avr_*.c}
34 sim_o = ${patsubst sim/%.c, ${OBJ}/%.o, ${sim}}
43 # Thats for MacPorts libelf
44 IPATH += /opt/local/include
45 LFLAGS = -L/opt/local/lib/
47 # shared library won't work that easily on non-linux
48 ifeq (${shell uname}, Linux)
49 all: ${OBJ}/libsimavr.so
53 ${OBJ}/libsimavr.a : ${cores_o}
54 ${OBJ}/libsimavr.a : ${sim_o}
56 @$(AR) cru $@ $^ && $(RANLIB) $@
58 libsimavr: ${OBJ}/libsimavr.a
60 ${OBJ}/libsimavr.so : ${cores_o}
61 ${OBJ}/libsimavr.so : ${sim_o}
63 @$(CC) -shared -fPIC -o $@ $(LFLAGS) $^ $(LDFLAGS)
65 ${OBJ}/${target}.elf : ${OBJ}/${target}.o
66 ${OBJ}/${target}.elf : ${OBJ}/libsimavr.a
68 ${target} : ${OBJ}/${target}.elf
72 rm -rf ${target} *.a *.so