# You should have received a copy of the GNU General Public License
# along with simavr. If not, see <http://www.gnu.org/licenses/>.
-target = simavr
+target = run_avr
-ifeq (${shell uname}, Darwin)
-AVR_ROOT := "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/avr-4/"
-else
-AVR_ROOT := /usr/lib/avr
-endif
-
-CFLAGS = -g -std=gnu99 -Wall
-CFLAGS += -O3 -mfpmath=sse -msse2
+CFLAGS += -O3 -mfpmath=sse -msse2 -Wall
+#CFLAGS += -DCONFIG_SIMAVR_TRACE=1
cores = ${wildcard cores/*.c}
cores_o = ${patsubst cores/%.c, obj/%.o, ${cores}}
-sim = ${wildcard sim/*.c}
+sim = ${wildcard sim/sim_*.c} ${wildcard sim/avr_*.c}
sim_o = ${patsubst sim/%.c, obj/%.o, ${sim}}
-VPATH = .
-VPATH += cores
+VPATH = cores
VPATH += sim
-IPATH = .
-IPATH += sim
+IPATH = sim
IPATH += ../../shared
IPATH += ../include
-IPATH += /opt/local/include
-CFLAGS += ${patsubst %,-I%,${subst :, ,${IPATH}}}
+# Thats for MacPorts libelf
+IPATH += /opt/local/include
LFLAGS = -L/opt/local/lib/
-LDFLAGS += -lelf
-
-all: obj ${target}
-obj:
- @mkdir -p obj
+all: obj libsimavr.a ${target}
-obj/sim_%.o : cores/sim_%.h ${wildcard cores/*.h} ${wildcard sim/*.h}
obj/sim_%.o : cores/sim_%.c
- @gcc $(CFLAGS) \
- -I${AVR_ROOT}/include/ \
+ @gcc $(CFLAGS) -MD \
+ -I${AVR_INC}/include/ \
$< -c -o $@
@echo CORE $<
-obj/%.o: %.h sim/*.h
-obj/%.o: %.c
- @gcc $(CFLAGS) \
- $< -c -o $@
- @echo CC $<
-
-${target} : ${cores_o}
-${target} : ${sim_o}
+include ../Makefile.common
+
+libsimavr.a : ${cores_o}
+libsimavr.a : ${sim_o}
+ @echo AR $@
+ @ar cru $@ $^
+ @ranlib $@
+
+${target} : libsimavr.a
+${target} : obj/${target}.o
@gcc $(CFLAGS) $(LFLAGS) \
${^} -o $@ \
$(LDFLAGS)
@echo LD $@
clean:
- rm -rf ${target} obj
-
+ rm -rf ${target} obj *.a