-Wno-unused-result -Wno-missing-field-initializers \
-Wno-sign-compare
CFLAGS += -g
-CORE_CFLAGS = -nostdinc -DAVR_CORE=1
+CORE_CFLAGS = -DAVR_CORE=1
ifeq (${shell uname}, Darwin)
# gcc 4.2 from MacOS is really not up to scratch anymore
CC = clang
AVR_ROOT := "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/"
- AVR_INC := ${AVR_ROOT}/avr/
AVR := ${AVR_ROOT}/bin/avr-
# Thats for MacPorts libelf
ifeq (${shell test -d /opt/local && echo Exists}, Exists)
CC = clang
IPATH += /opt/local/include /opt/local/include/libelf
LFLAGS = -L/opt/local/lib/
- AVR_INC := /opt/local/avr
AVR := /opt/local/bin/avr-
else
# That's for Homebrew libelf and avr-gcc support
LFLAGS = -L$(HOMEBREW_PREFIX)/lib/
CFLAGS += -I/$(HOMEBREW_PREFIX)/include/libelf
AVR_ROOT := $(firstword $(wildcard $(HOMEBREW_PREFIX)/Cellar/avr-libc/*/))
- AVR_INC := ${AVR_ROOT}/avr
AVR := $(HOMEBREW_PREFIX)/bin/avr-
endif
endif
else
- LINUX_AVR_ROOTS := /usr/lib/avr /usr/avr /opt/cross/avr/avr /usr/local/avr
- AVR_ROOT := $(firstword $(wildcard $(LINUX_AVR_ROOTS)))
- ifeq (${AVR_ROOT},)
- $(error No avr-libc root directory found. Tried the following paths: $(LINUX_AVR_ROOTS))
- endif
- AVR_INC := ${AVR_ROOT}
AVR := avr-
endif
ifeq (${WIN}, Msys)
AVR_ROOT := ${shell echo "${AVR32_HOME}" | tr '\\' '/'}
-AVR_INC := ${AVR_ROOT}/avr
AVR := ${AVR_ROOT}/bin/avr-
IPATH += ${PREFIX}/include
CFLAGS += -I${PREFIX}/include
CPPFLAGS += --std=gnu99 -Wall
CPPFLAGS += ${patsubst %,-I%,${subst :, ,${IPATH}}}
-AVR_CPPFLAGS= ${CPPFLAGS} -idirafter ${AVR_INC}/include
+AVR_CPPFLAGS = ${CPPFLAGS} -I${SIMAVR}/cores
CC ?= clang
AR ?= ar
endif
endif
+ifeq (${V}, 1)
+E =
+else
+E = @
+endif
+
# The code is compiled "optimized" to the max.
#
# The weird "-Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000"
# this rule has precedence
${OBJ}/sim_%.o : cores/sim_%.c
-ifeq ($(V),1)
- $(CC) $(CPPFLAGS) $(CFLAGS) $(CORE_CFLAGS) -MMD \
- ${AVR_CPPFLAGS} \
- $< -c -o $@
-else
- @$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS) $(CORE_CFLAGS) -MMD \
- ${AVR_CPPFLAGS} \
- $< -c -o $@
+ifneq ($(E),)
@echo CORE $<
endif
+ ${E}$(CC) $(CPPFLAGS) $(CFLAGS) $(CORE_CFLAGS) -MMD \
+ ${AVR_CPPFLAGS} \
+ $< -c -o $@
${OBJ}/%.o: %.c
-ifeq ($(V),1)
- $(CC) $(CPPFLAGS) $(CFLAGS) -MMD \
- $< -c -o $@
-else
- @$(CC) $(CPPFLAGS) $(CFLAGS) -MMD \
- $< -c -o $@
+ifneq ($(E),)
@echo CC $<
endif
+ ${E}$(CC) $(CPPFLAGS) $(CFLAGS) -MMD \
+ $< -c -o $@
${OBJ}/%.elf:
-ifeq ($(V),1)
- $(CC) -MMD ${CFLAGS} ${LFLAGS} -o $@ $^ $(LDFLAGS)
-else
+ifneq ($(E),)
@echo LD $@
- @$(CC) -MMD ${CFLAGS} ${LFLAGS} -o $@ $^ $(LDFLAGS)
endif
+ ${E}$(CC) -MMD ${CFLAGS} ${LFLAGS} -o $@ $^ $(LDFLAGS)
obj: ${OBJ}
# Static library
#
${OBJ}/libsimavr.a : ${sim_o}
-ifeq ($(V),1)
- $(AR) cru $@ $^ && $(RANLIB) $@
-else
+ifneq ($(E),)
@echo AR $@
- @$(AR) cru $@ $^ && $(RANLIB) $@
endif
+ ${E}$(AR) cru $@ $^ && $(RANLIB) $@
#
# Shared library (Linux)
#
${OBJ}/libsimavr.so.1 : ${sim_o}
-ifeq ($(V),1)
- $(CC) -shared -Wl,-soname,libsimavr.so.1 -o $@ $^ ${filter-out -lsimavr, $(LDFLAGS)}
-else
+ifneq ($(E),)
@echo SHARED $@
- @$(CC) -shared -Wl,-soname,libsimavr.so.1 -o $@ $^ ${filter-out -lsimavr, $(LDFLAGS)}
endif
+ ${E}$(CC) -shared -Wl,-soname,libsimavr.so.1 -o $@ $^ \
+ ${filter-out -lsimavr, $(LDFLAGS)}
${OBJ}/libsimavr.so : ${OBJ}/libsimavr.so.1
ln -sf libsimavr.so.1 $@
libsimavr : config ${OBJ}/libsimavr.a
# shared library won't work that easily on non-linux
ifeq (${shell uname}, Linux)
-libsimavr : ${OBJ}/libsimavr.so
+libsimavr : ${OBJ}/libsimavr.so
endif
${OBJ}/${target}.elf : ${OBJ}/${target}.o
printf "\$${OBJ}/libsimavr.a: \$${OBJ}/$$obj\n">>${OBJ}/cores.deps ; \
printf "\$${OBJ}/libsimavr.so.1: \$${OBJ}/$$obj\n">>${OBJ}/cores.deps ; \
else \
+ conf+="#undef CONFIG_$$upper\n"; \
echo WARNING $$file did not compile, check your avr-gcc toolchain; \
fi \
done ; \