forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_arduino.mk
52 lines (46 loc) · 1.9 KB
/
find_arduino.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
# Find Arduino, if not explicitly specified
#
ifeq ($(ARDUINO),)
#
# List locations that might be valid ARDUINO settings
#
ifeq ($(SYSTYPE),Darwin)
# use Spotlight to find Arduino.app
ARDUINO_QUERY = 'kMDItemKind == Application && kMDItemFSName == Arduino.app'
ARDUINOS := $(addsuffix /Contents/Resources/Java,$(shell mdfind -literal $(ARDUINO_QUERY)))
ifeq ($(ARDUINOS),)
$(error ERROR: Spotlight cannot find Arduino on your system.)
endif
endif
ifeq ($(SYSTYPE),Linux)
ARDUINO_SEARCHPATH = /usr/share/arduino* /usr/local/share/arduino*
ARDUINOS := $(wildcard $(ARDUINO_SEARCHPATH))
endif
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
# Most of the following commands are simply to deal with whitespaces in the path
# Read the "Program Files" system directory from the windows registry
PROGRAM_FILES := $(shell cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/ProgramFilesDir)
# Convert the path delimiters to /
PROGRAM_FILES := $(shell cygpath -m ${PROGRAM_FILES})
# Escape the space with a backslash
PROGRAM_FILES := $(shell echo $(PROGRAM_FILES) | sed s/\ /\\\\\ / )
# Use DOS paths because they do not contain spaces
PROGRAM_FILES := $(shell cygpath -d ${PROGRAM_FILES})
# Convert the path delimiters to /
PROGRAM_FILES := $(subst \,/,$(PROGRAM_FILES))
# Search for an Arduino instalation in a couple of paths
ARDUINO_SEARCHPATH := c:/arduino* $(PROGRAM_FILES)/arduino*
ARDUINOS := $(wildcard $(ARDUINO_SEARCHPATH))
endif
#
# Pick the first option if more than one candidate is found.
#
ARDUINO := $(firstword $(ARDUINOS))
ifeq ($(ARDUINO),)
$(error ERROR: Cannot find Arduino on this system, please specify on the commandline with ARDUINO=<path> or on the config.mk file)
endif
ifneq ($(words $(ARDUINOS)),1)
$(warning WARNING: More than one copy of Arduino was found, using $(ARDUINO))
endif
endif