Find clang 7 better

If LLVM_DIR is defined, use it to locate clang.  Otherwise use brew on
macOS, and assume clang-7 otherwise
This commit is contained in:
Michael Vines 2018-11-01 09:26:06 -07:00
parent 1e01088698
commit 6b777b066a
1 changed files with 13 additions and 8 deletions

View File

@ -13,13 +13,20 @@ OUT_DIR ?= ./out
OS=$(uname) OS=$(uname)
ifeq ($(OS),Darwin) ifeq ($(OS),Darwin)
LLVM_DIR ?= $(brew --prefix llvm) LLVM_DIR ?= $(brew --prefix llvm)
endif
ifdef LLVM_DIR
CC := $(LLVM_DIR)/bin/clang
LLC := $(LLVM_DIR)/bin/llc
OBJ_DUMP := $(LLVM_DIR)/bin/llvm-objdump
else else
LLVM_DIR ?= /usr/local/opt/llvm CC := clang-7
LLC := llc-7
OBJ_DUMP := llvm-objdump-7
endif endif
SYSTEM_INC_DIRS := -isystem $(dir $(lastword $(MAKEFILE_LIST)))inc SYSTEM_INC_DIRS := -isystem $(dir $(lastword $(MAKEFILE_LIST)))inc
CC := $(LLVM_DIR)/bin/clang
CC_FLAGS := \ CC_FLAGS := \
-Werror \ -Werror \
-target bpf \ -target bpf \
@ -27,13 +34,11 @@ CC_FLAGS := \
-emit-llvm \ -emit-llvm \
-fno-builtin \ -fno-builtin \
LLC := $(LLVM_DIR)/bin/llc
LLC_FLAGS := \ LLC_FLAGS := \
-march=bpf \ -march=bpf \
-filetype=obj \ -filetype=obj \
-function-sections \ -function-sections \
OBJ_DUMP := $(LLVM_DIR)/bin/llvm-objdump
OBJ_DUMP_FLAGS := \ OBJ_DUMP_FLAGS := \
-color \ -color \
-source \ -source \
@ -52,11 +57,11 @@ help:
@echo '' @echo ''
@echo 'User settings' @echo 'User settings'
@echo ' - The following setting are overridable on the command line, default values shown:' @echo ' - The following setting are overridable on the command line, default values shown:'
@echo ' - Show commands:' @echo ' - Show commands while building:'
@echo ' V=1' @echo ' V=1'
@echo ' - List of include dirs:' @echo ' - List of include directories:'
@echo ' INC_DIRS=$(INC_DIRS)' @echo ' INC_DIRS=$(INC_DIRS)'
@echo ' - List of systme include dirs:' @echo ' - List of system include directories:'
@echo ' SYSTEM_INC_DIRS=$(SYSTEM_INC_DIRS)' @echo ' SYSTEM_INC_DIRS=$(SYSTEM_INC_DIRS)'
@echo ' - Location of source files:' @echo ' - Location of source files:'
@echo ' SRC_DIR=$(SRC_DIR)' @echo ' SRC_DIR=$(SRC_DIR)'