+AVR_ROOT := /usr/lib/avr
+AVR_INC := ${AVR_ROOT}
+AVR := avr-
+CFLAGS += -fPIC
+endif
+
+CC ?= gcc
+AR ?= ar
+RANLIB ?= ranlib
+MKDIR ?= mkdir -p
+INSTALL ?= install
+SHELL := ${shell which bash}
+
+# simavr directory
+SIMAVR ?= ${shell for p in . .. ../.. ../../..;do test -d $$p/simavr/sim && echo $$p/simavr; done}
+
+OBJ = obj-${shell $(CC) -dumpmachine}
+LIBDIR = ${shell pwd}/${SIMAVR}/${OBJ}
+LDFLAGS += -L${LIBDIR} -lsimavr
+
+LDFLAGS += -lelf
+
+ifeq (${shell uname}, Linux)
+# allow the shared library to be found in the build directory
+LFLAGS += -Wl,-rpath,${LIBDIR}