# get the first character of what the compiler says it is, unless it's 'x86_64' doh
ARCH = ${shell $(CC) -dumpmachine | sed -e 's/^x/i/' -e 's/\(.\).*/\1/'}
+CFLAGS += -O2 -Wall
ifeq ($(ARCH), i)
CFLAGS += -mfpmath=sse -msse2
endif
AVR_ROOT := "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/"
AVR_INC := ${AVR_ROOT}/avr-4/
AVR := ${AVR_ROOT}/bin/avr-
-LFLAGS += -L/opt/local/lib
+# Thats for MacPorts libelf
+ifeq (${shell test -d /opt/local && echo Exists}, Exists)
+IPATH += /opt/local/include
+LFLAGS = -L/opt/local/lib/
+endif
else
AVR_ROOT := /usr/lib/avr
AVR_INC := ${AVR_ROOT}
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}