SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c

.PHONY: help all software hw chisel fpga-rtl asic-rtl clean

help:
	@printf '%s\n' \
	  'Common SoC targets:' \
	  '  make software  # build common bootloader and hello app' \
	  '  make hw        # emit shared SoC FIRRTL through FPGA config' \
	  '  make chisel    # compatibility alias for make hw' \
	  '  make fpga-rtl  # emit FPGA RTL/wrapper from shared SoC' \
	  '  make asic-rtl  # emit ASIC RTL/wrapper from shared SoC' \
	  '  make clean     # remove common software and generated SoC outputs'

all: software fpga-rtl

software:
	@$(MAKE) -C software all

hw chisel:
	@$(MAKE) -C ../hardware/soc firrtl

fpga-rtl:
	@$(MAKE) -C ../hardware/soc fpga-rtl

asic-rtl:
	@$(MAKE) -C ../hardware/soc asic-rtl

clean:
	@$(MAKE) -C software clean
	$(MAKE) -C ../hardware/soc clean
