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)
ifeq ($(OS),Darwin)
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
LLVM_DIR ?= /usr/local/opt/llvm
CC := clang-7
LLC := llc-7
OBJ_DUMP := llvm-objdump-7
endif
SYSTEM_INC_DIRS := -isystem $(dir $(lastword $(MAKEFILE_LIST)))inc
CC := $(LLVM_DIR)/bin/clang
CC_FLAGS := \
-Werror \
-target bpf \
@ -27,13 +34,11 @@ CC_FLAGS := \
-emit-llvm \
-fno-builtin \
LLC := $(LLVM_DIR)/bin/llc
LLC_FLAGS := \
-march=bpf \
-filetype=obj \
-function-sections \
OBJ_DUMP := $(LLVM_DIR)/bin/llvm-objdump
OBJ_DUMP_FLAGS := \
-color \
-source \
@ -52,11 +57,11 @@ help:
@echo ''
@echo 'User settings'
@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 ' - List of include dirs:'
@echo ' - List of include directories:'
@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 ' - Location of source files:'
@echo ' SRC_DIR=$(SRC_DIR)'