67 lines
3.4 KiB
Makefile
67 lines
3.4 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))
|
|
VIVADO ?= $(lastword $(sort $(wildcard /tools/Xilinx/*/Vivado/bin/vivado) $(shell command -v vivado 2>/dev/null)))
|
|
|
|
# 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 := \
|
|
$(if $(strip $(RISCV_TOOLCHAIN)),$(RISCV_TOOLCHAIN) $(RISCV_TOOLCHAIN)/bin) \
|
|
$(TOOLCHAIN) \
|
|
$(PROJECT_TOOLS_DIR)/riscv/bin \
|
|
/tools/toolchains-medany/bin \
|
|
/tools/toolchains/rvtc-medany/bin \
|
|
/tools/toolchain/bin \
|
|
/tools/toolchains/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))
|
|
|
|
# An explicit RISCV_TOOLCHAIN is authoritative, including over an old
|
|
# TOOLCHAIN/RISCV_PREFIX inherited from the shell. Without override, Make's
|
|
# environment-variable semantics leave CROSS pointing at the stale toolchain
|
|
# even though _RISCV_GCC was found in RISCV_TOOLCHAIN.
|
|
ifneq ($(strip $(RISCV_TOOLCHAIN)),)
|
|
override TOOLCHAIN := $(patsubst %/,%,$(dir $(_RISCV_GCC)))
|
|
override RISCV_PREFIX := $(if $(_RISCV_GCC),$(patsubst %-gcc,%-,$(notdir $(_RISCV_GCC))),riscv64-unknown-elf-)
|
|
override CROSS := $(if $(strip $(TOOLCHAIN)),$(TOOLCHAIN)/)$(RISCV_PREFIX)
|
|
else
|
|
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)
|
|
endif
|
|
|
|
# Some compiler-only toolchains (notably rvtc-medany) do not ship GDB. Keep
|
|
# using the selected compiler toolchain, but fall back to the full local
|
|
# toolchain for FPGA debug targets.
|
|
_RISCV_GDB := $(firstword \
|
|
$(wildcard $(TOOLCHAIN)/$(RISCV_PREFIX)gdb) \
|
|
$(wildcard /tools/toolchains/tc/toolchain/bin/$(RISCV_PREFIX)gdb) \
|
|
$(wildcard /tools/toolchain/bin/$(RISCV_PREFIX)gdb) \
|
|
$(lastword $(sort $(wildcard /tools/Xilinx/*/gnu/riscv/lin/bin/$(RISCV_PREFIX)gdb))) \
|
|
$(shell command -v $(RISCV_PREFIX)gdb 2>/dev/null))
|
|
GDB ?= $(if $(_RISCV_GDB),$(_RISCV_GDB),$(CROSS)gdb)
|
|
|
|
# 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)
|