blob: 8bd847e8abf86622b60d70ac230f8bb4dd2805da [file] [log] [blame]
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SPIKE_SRC_DIR := $(ROOTDIR)/toolchain/spike
SPIKE_BUILD_DIR := $(OUT)/tmp/spike
SPIKE_INSTALL_DIR := $(OUT)/host/spike
$(SPIKE_BUILD_DIR):
mkdir -p $(SPIKE_BUILD_DIR)
$(SPIKE_INSTALL_DIR):
mkdir -p $(SPIKE_INSTALL_DIR)
$(SPIKE_INSTALL_DIR)/bin/spike: $(SPIKE_SRC_DIR) | $(SPIKE_BUILD_DIR) $(SPIKE_INSTALL_DIR)
cd $(SPIKE_BUILD_DIR) && \
CC=gcc-11 CXX=g++-11 \
$(SPIKE_SRC_DIR)/configure --prefix=$(SPIKE_INSTALL_DIR) \
--with-isa=rv32imafcv1p0_xspringbok --with-target=riscv32-unknown-elf \
--enable-commitlog
$(MAKE) -C $(SPIKE_BUILD_DIR) install
## Build spike RISCV ISA simulator
#
# Using sources in toolchain/spike, this target builds spike from source and stores
# its output in out/host/spike.
#
# You may want to build with `m -j64 spike` to enable parallel build.
#
# To rebuild this target, run `m spike_clean` and re-run.
spike: $(SPIKE_INSTALL_DIR)/bin/spike
spike_clean:
rm -r $(SPIKE_BUILD_DIR) $(SPIKE_INSTALL_DIR)
QEMU_SRC_DIR := $(ROOTDIR)/toolchain/riscv-qemu
QEMU_OUT_DIR := $(OUT)/host/qemu
QEMU_BINARY := $(QEMU_OUT_DIR)/riscv32-softmmu/qemu-system-riscv32
QEMU_DEPS=$(wildcard $(QEMU_SRC_DIR)/**/*.[ch])
$(QEMU_OUT_DIR): | $(QEMU_SRC_DIR)
mkdir -p $(QEMU_OUT_DIR);
# Disable configure check to be compatible with lib6 2.36.
$(QEMU_BINARY): $(QEMU_DEPS) | $(QEMU_OUT_DIR)
cd $(QEMU_OUT_DIR) && $(QEMU_SRC_DIR)/configure \
--target-list=riscv32-softmmu,riscv32-linux-user --disable-werror
$(MAKE) -C $(QEMU_OUT_DIR)
## Builds and installs the QEMU RISCV32 simulator.
#
# Sources are in toolchain/riscv-qemu, while outputs are stored in
# out/host/qemu.
qemu: $(QEMU_BINARY)
## Removes only the QEMU build artifacts from out/
qemu_clean:
rm -rf $(QEMU_OUT_DIR)
.PHONY:: spike spike_clean
.PHONY:: qemu qemu_clean