Skip to content

Commit 94ec082

Browse files
authored
Makefile: autodetect llvm-ar and llvm-nm commands
1 parent 630c498 commit 94ec082

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

Makefile

+19-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,24 @@ LLD_SRC ?= llvm-project/lld
99

1010
# Default tool selection.
1111
CLANG ?= clang-9
12-
LLVM_AR ?= llvm-ar-9
13-
LLVM_NM ?= llvm-nm-9
12+
13+
# Try to autodetect llvm-ar and llvm-nm
14+
ifneq (, $(shell command -v llvm-ar-9 2> /dev/null))
15+
LLVM_AR ?= llvm-ar-9
16+
else ifneq (, $(shell command -v llvm-ar 2> /dev/null))
17+
LLVM_AR ?= llvm-ar
18+
endif
19+
ifneq (, $(shell command -v llvm-nm-9 2> /dev/null))
20+
LLVM_NM ?= llvm-nm-9
21+
else ifneq (, $(shell command -v llvm-nm 2> /dev/null))
22+
LLVM_NM ?= llvm-nm
23+
endif
24+
ifndef LLVM_AR
25+
$(warning llvm-ar not found)
26+
endif
27+
ifndef LLVM_NM
28+
$(warning llvm-nm not found)
29+
endif
1430

1531
# Go binary and GOROOT to select
1632
GO ?= go
@@ -23,7 +39,7 @@ MD5SUM = md5sum
2339
TINYGO ?= tinygo
2440

2541
# Use CCACHE for LLVM if possible
26-
ifneq (, $(shell which ccache))
42+
ifneq (, $(shell command -v ccache 2> /dev/null))
2743
LLVM_OPTION += '-DLLVM_CCACHE_BUILD=ON'
2844
endif
2945

0 commit comments

Comments
 (0)