Skip to content

Commit b19533b

Browse files
committed
Check if AVR Toolchain exits in macOS
AVR Toolchain for macOS can also be installed from Microchip binaries in https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers
1 parent 4cd9f83 commit b19533b

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

Makefile.common

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,43 @@ CFLAGS += -g
4646
CORE_CFLAGS = -DAVR_CORE=1
4747

4848
ifeq (${shell uname}, Darwin)
49-
# gcc 4.2 from MacOS is really not up to scratch anymore
50-
CC = clang
51-
AVR_ROOT := "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/"
52-
AVR := ${AVR_ROOT}/bin/avr-
53-
# Thats for MacPorts libelf
54-
ifeq (${shell test -d /opt/local && echo Exists}, Exists)
55-
ifneq (${shell test -d /opt/local/avr && echo Exists}, Exists)
56-
$(error Please install avr-gcc: port install avr-gcc avr-libc)
57-
endif
58-
ifneq (${shell test -d /opt/local/include/libelf && echo Exists}, Exists)
59-
$(error Please install libelf: port install libelf)
60-
endif
61-
CC = clang
62-
IPATH += /opt/local/include /opt/local/include/libelf
63-
LFLAGS = -L/opt/local/lib/
64-
AVR := /opt/local/bin/avr-
49+
# If AVR Toolchain was installed from Microchip binaries
50+
ifneq (, $(shell which avr-gcc))
51+
AVR := avr-
6552
else
66-
# That's for Homebrew libelf and avr-gcc support
67-
HOMEBREW_PREFIX ?= /usr/local
68-
ifeq (${shell test -d $(HOMEBREW_PREFIX)/Cellar && echo Exists}, Exists)
69-
ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc/ && echo Exists}, Exists)
70-
$(error Please install avr-gcc: brew tap osx-cross/homebrew-avr ; brew install avr-libc)
53+
# gcc 4.2 from MacOS is really not up to scratch anymore
54+
CC = clang
55+
AVR_ROOT := "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/"
56+
AVR := ${AVR_ROOT}/bin/avr-
57+
# Thats for MacPorts libelf
58+
ifeq (${shell test -d /opt/local && echo Exists}, Exists)
59+
ifneq (${shell test -d /opt/local/avr && echo Exists}, Exists)
60+
$(error Please install avr-gcc: port install avr-gcc avr-libc)
61+
endif
62+
ifneq (${shell test -d /opt/local/include/libelf && echo Exists}, Exists)
63+
$(error Please install libelf: port install libelf)
7164
endif
72-
ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/libelf/ && echo Exists}, Exists)
73-
$(error Please install libelf: brew install libelf)
65+
CC = clang
66+
IPATH += /opt/local/include /opt/local/include/libelf
67+
LFLAGS = -L/opt/local/lib/
68+
AVR := /opt/local/bin/avr-
69+
else
70+
# That's for Homebrew libelf and avr-gcc support
71+
HOMEBREW_PREFIX ?= /usr/local
72+
ifeq (${shell test -d $(HOMEBREW_PREFIX)/Cellar && echo Exists}, Exists)
73+
ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/avr-gcc/ && echo Exists}, Exists)
74+
$(error Please install avr-gcc: brew tap osx-cross/homebrew-avr ; brew install avr-libc)
75+
endif
76+
ifneq (${shell test -d $(HOMEBREW_PREFIX)/Cellar/libelf/ && echo Exists}, Exists)
77+
$(error Please install libelf: brew install libelf)
78+
endif
79+
CC = clang
80+
IPATH += $(HOMEBREW_PREFIX)/include
81+
LFLAGS = -L$(HOMEBREW_PREFIX)/lib/
82+
CFLAGS += -I/$(HOMEBREW_PREFIX)/include/libelf
83+
AVR_ROOT := $(firstword $(wildcard $(HOMEBREW_PREFIX)/Cellar/avr-libc/*/))
84+
AVR := $(HOMEBREW_PREFIX)/bin/avr-
7485
endif
75-
CC = clang
76-
IPATH += $(HOMEBREW_PREFIX)/include
77-
LFLAGS = -L$(HOMEBREW_PREFIX)/lib/
78-
CFLAGS += -I/$(HOMEBREW_PREFIX)/include/libelf
79-
AVR_ROOT := $(firstword $(wildcard $(HOMEBREW_PREFIX)/Cellar/avr-libc/*/))
80-
AVR := $(HOMEBREW_PREFIX)/bin/avr-
8186
endif
8287
endif
8388
else

0 commit comments

Comments
 (0)