aboutsummaryrefslogtreecommitdiff
path: root/arduino-mk
diff options
context:
space:
mode:
authorRyan Pavlik <rpavlik@iastate.edu>2012-06-28 18:32:23 -0500
committerRyan Pavlik <rpavlik@iastate.edu>2012-06-28 18:32:23 -0500
commit7f3fe664956930c35181d6c2f8198f565177718a (patch)
treedd5b6ac78dbba4373032cd0de83d741d5397e374 /arduino-mk
parent854a7aa8c03bd4bc5c5e9fc6fb5d6c46bf860472 (diff)
Only use Arduino's bundled AVR tools if they exist, otherwise try using "which"
Diffstat (limited to 'arduino-mk')
-rw-r--r--arduino-mk/Arduino.mk20
1 files changed, 18 insertions, 2 deletions
diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk
index 18a9860..6102893 100644
--- a/arduino-mk/Arduino.mk
+++ b/arduino-mk/Arduino.mk
@@ -301,10 +301,26 @@ endif
ifdef ARDUINO_DIR
ifndef AVR_TOOLS_DIR
-AVR_TOOLS_DIR = $(ARDUINO_DIR)/hardware/tools/avr
+
+BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr)
+
+ifdef BUNDLED_AVR_TOOLS_DIR
+$(info Using autodetected (bundled) AVR_TOOLS_DIR '$(BUNDLED_AVR_TOOLS_DIR)')
+AVR_TOOLS_DIR = $(BUNDLED_AVR_TOOLS_DIR)
# The avrdude bundled with Arduino can't find it's config
AVRDUDE_CONF = $(AVR_TOOLS_DIR)/etc/avrdude.conf
-endif
+
+else
+
+SYSTEMPATH_AVR_TOOLS_DIR := $(call dir_if_exists,$(abspath $(dir $(shell which avr-gcc))/..))
+ifdef SYSTEMPATH_AVR_TOOLS_DIR
+$(info Using autodetected (from PATH) AVR_TOOLS_DIR '$(SYSTEMPATH_AVR_TOOLS_DIR)')
+AVR_TOOLS_DIR = $(SYSTEMPATH_AVR_TOOLS_DIR)
+endif # SYSTEMPATH_AVR_TOOLS_DIR
+
+endif # BUNDLED_AVR_TOOLS_EIR
+
+endif #ndef AVR_TOOLS_DIR
ifndef AVR_TOOLS_PATH
AVR_TOOLS_PATH = $(AVR_TOOLS_DIR)/bin