2 # Copyright 2008-2012 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/>.
19 SIMAVR_VERSION = 1.0a10
24 CFLAGS += -O3 -Wall -Werror
26 # tracing id useful especialy if you develop simavr core.
27 # it otherwise eat quite a bit of few cycles, even disabled
28 #CFLAGS += -DCONFIG_SIMAVR_TRACE=1
32 include ../Makefile.common
34 cores = ${wildcard cores/*.c}
35 cores_o = ${patsubst cores/%.c, ${OBJ}/%.o, ${cores}}
36 sim = ${wildcard sim/sim_*.c} ${wildcard sim/avr_*.c}
37 sim_o = ${patsubst sim/%.c, ${OBJ}/%.o, ${sim}}
46 # Thats for MacPorts libelf
47 ifeq (${shell test -d /opt/local && echo Exists}, Exists)
48 IPATH += /opt/local/include
49 LFLAGS = -L/opt/local/lib/
55 ${OBJ}/libsimavr.a : ${cores_o}
56 ${OBJ}/libsimavr.a : ${sim_o}
58 @$(AR) cru $@ $^ && $(RANLIB) $@
61 # Shared library (Linux)
63 ${OBJ}/libsimavr.so.1 : ${cores_o}
64 ${OBJ}/libsimavr.so.1 : ${sim_o}
66 @$(CC) -shared -Wl,-soname,libsimavr.so.1 -o $@ $^
68 ${OBJ}/libsimavr.so : ${OBJ}/libsimavr.so.1
69 ln -sf libsimavr.so.1 $@
71 libsimavr : ${OBJ}/libsimavr.a
72 # shared library won't work that easily on non-linux
73 ifeq (${shell uname}, Linux)
74 libsimavr : ${OBJ}/libsimavr.so
77 ${OBJ}/${target}.o : libsimavr
78 ${OBJ}/${target}.elf : ${OBJ}/${target}.o
80 ${target} : ${OBJ}/${target}.elf
84 rm -rf ${target} *.a *.so
89 $(MKDIR) $(DESTDIR)/include/simavr/avr
90 $(INSTALL) sim/*.h $(DESTDIR)/include/simavr/
91 $(INSTALL) ../include/*.h $(DESTDIR)/include/simavr/avr/
92 $(MKDIR) $(DESTDIR)/lib
93 $(INSTALL) ${OBJ}/libsimavr.a $(DESTDIR)/lib/
94 $(MKDIR) $(DESTDIR)/lib/pkgconfig/
95 sed -e "s|PREFIX|${DESTDIR}|g" -e "s|VERSION|${SIMAVR_VERSION}|g" \
96 simavr.pc >$(DESTDIR)/lib/pkgconfig/simavr.pc
97 ifeq (${shell uname}, Linux)
98 $(INSTALL) ${OBJ}/libsimavr.so.1 $(DESTDIR)/lib/
99 ln -sf libsimavr.so.1 $(DESTDIR)/lib/libsimavr.so
101 $(MKDIR) $(DESTDIR)/bin
102 $(INSTALL) ${OBJ}/${target}.elf $(DESTDIR)/bin/simavr