45 lines
2.1 KiB
Makefile
45 lines
2.1 KiB
Makefile
# Common, relocatable tool configuration.
|
|
#
|
|
# The including Makefile must define REPO_DIR before including this file.
|
|
# Every value can be overridden from the environment or make command line.
|
|
|
|
ifndef REPO_DIR
|
|
$(error REPO_DIR must be defined before including tools/project.mk)
|
|
endif
|
|
|
|
SOC_TOOLS_ROOT ?= /tools/soc-tools
|
|
PROJECT_TOOLS_DIR := $(REPO_DIR)/tools/local
|
|
|
|
JAVA_HOME ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/jdk17) $(wildcard $(PROJECT_TOOLS_DIR)/jdk17))
|
|
MILL ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/mill-current) $(wildcard $(PROJECT_TOOLS_DIR)/mill))
|
|
FIRTOOL ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/circt-current/bin/firtool) $(wildcard $(PROJECT_TOOLS_DIR)/circt/bin/firtool))
|
|
Z3_LIB_DIR ?= $(firstword $(wildcard $(SOC_TOOLS_ROOT)/z3-current/bin) $(wildcard $(PROJECT_TOOLS_DIR)/z3/*/bin))
|
|
CIRCT_LIB_DIR ?= $(patsubst %/bin/firtool,%/lib,$(FIRTOOL))
|
|
|
|
# RISCV_TOOLCHAIN may point either to the toolchain root or its bin directory.
|
|
# TOOLCHAIN keeps compatibility with the existing software Makefiles.
|
|
RISCV_TOOLCHAIN ?=
|
|
_RISCV_SEARCH_DIRS := \
|
|
$(TOOLCHAIN) \
|
|
$(RISCV_TOOLCHAIN) \
|
|
$(RISCV_TOOLCHAIN)/bin \
|
|
$(PROJECT_TOOLS_DIR)/riscv/bin \
|
|
/tools/toolchain/bin \
|
|
/tools/toolchains/bin \
|
|
/tools/toolchains/rvtc-medany/bin
|
|
_RISCV_GCC := $(firstword \
|
|
$(foreach d,$(_RISCV_SEARCH_DIRS),$(wildcard $(d)/riscv64-unknown-elf-gcc)) \
|
|
$(foreach d,$(_RISCV_SEARCH_DIRS),$(wildcard $(d)/riscv64-none-elf-gcc)) \
|
|
$(shell command -v riscv64-unknown-elf-gcc 2>/dev/null) \
|
|
$(shell command -v riscv64-none-elf-gcc 2>/dev/null))
|
|
|
|
TOOLCHAIN ?= $(patsubst %/,%,$(dir $(_RISCV_GCC)))
|
|
RISCV_PREFIX ?= $(if $(_RISCV_GCC),$(patsubst %-gcc,%-,$(notdir $(_RISCV_GCC))),riscv64-unknown-elf-)
|
|
CROSS ?= $(if $(strip $(TOOLCHAIN)),$(TOOLCHAIN)/)$(RISCV_PREFIX)
|
|
|
|
# Mill's launcher resolves java through PATH, and build.sc resolves firtool the
|
|
# same way. CIRCT has an rpath for its own libraries; Z3 is shipped separately.
|
|
export JAVA_HOME
|
|
export PATH := $(JAVA_HOME)/bin:$(dir $(FIRTOOL)):$(TOOLCHAIN):$(PATH)
|
|
export LD_LIBRARY_PATH := $(Z3_LIB_DIR):$(CIRCT_LIB_DIR):$(LD_LIBRARY_PATH)
|