mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 10:03:44 +02:00
119 lines
4.0 KiB
Makefile
119 lines
4.0 KiB
Makefile
# -*- Makefile -*-
|
|
#*****************************************************************************
|
|
#
|
|
# DESCRIPTION: Verilator: Makefile for verilog source
|
|
#
|
|
# Code available from: https://verilator.org
|
|
#
|
|
#*****************************************************************************
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
# under the terms of either the GNU Lesser General Public License Version 3
|
|
# or the Perl Artistic License Version 2.0.
|
|
# SPDX-FileCopyrightText: 2025-2026 Wilson Snyder
|
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
|
#
|
|
#****************************************************************************/
|
|
|
|
#### Start of system configuration section. ####
|
|
|
|
srcdir = @srcdir@
|
|
EXEEXT = @EXEEXT@
|
|
PYTHON3 = @PYTHON3@
|
|
# VPATH only does sources; fix install_test's not creating ../bin
|
|
vpath %.h @srcdir@
|
|
|
|
#### End of system configuration section. ####
|
|
|
|
default: dbg opt
|
|
debug: dbg
|
|
optimize: opt
|
|
|
|
ifneq ($(words $(CURDIR)),1)
|
|
$(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)')
|
|
endif
|
|
|
|
UNDER_GIT = $(wildcard ${srcdir}/../.git/logs/HEAD)
|
|
|
|
# Use bear if installed, and new enough to support the '--output FILE --' syntax
|
|
BEAR := $(shell bear=$$(which bear 2>/dev/null) && tmp=$$(mktemp -d 2>/dev/null) \
|
|
&& { "$$bear" --output "$$tmp/probe.json" -- true >/dev/null 2>&1 && echo "$$bear"; rm -rf "$$tmp"; })
|
|
BEAR_OBJ_OPT := $(if $(BEAR),$(BEAR) --append --output obj_dbg/compile_commands.json --)
|
|
|
|
#*********************************************************************
|
|
|
|
obj_opt:
|
|
mkdir -p $@
|
|
obj_dbg:
|
|
mkdir -p $@
|
|
obj_shared:
|
|
mkdir -p $@
|
|
../bin:
|
|
mkdir -p $@
|
|
|
|
.SUFFIXES:
|
|
|
|
.PHONY: ../bin/verilator_bin$(EXEEXT) ../bin/verilator_bin_dbg$(EXEEXT) ../bin/verilator_coverage_bin$(EXEEXT) ../bin/verilator_coverage_bin_dbg$(EXEEXT)
|
|
|
|
opt: ../bin/verilator_bin$(EXEEXT) ../bin/verilator_coverage_bin$(EXEEXT)
|
|
ifeq ($(VERILATOR_NO_OPT_BUILD),1) # Faster laptop development... One build
|
|
../bin/verilator_bin$(EXEEXT): ../bin/verilator_bin_dbg$(EXEEXT)
|
|
-cp -p $< $@.tmp
|
|
-mv -f $@.tmp $@
|
|
../bin/verilator_coverage_bin$(EXEEXT): ../bin/verilator_coverage_bin_dbg$(EXEEXT)
|
|
-cp -p $< $@.tmp
|
|
-mv -f $@.tmp $@
|
|
else
|
|
../bin/verilator_bin$(EXEEXT): obj_opt ../bin prefiles
|
|
$(MAKE) -C obj_opt -j 1 TGT=../$@ -f ../Makefile_obj serial
|
|
$(MAKE) -C obj_opt TGT=../$@ -f ../Makefile_obj
|
|
../bin/verilator_coverage_bin$(EXEEXT): obj_opt ../bin prefiles
|
|
$(MAKE) -C obj_opt TGT=../$@ VL_VLCOV=1 -f ../Makefile_obj
|
|
endif
|
|
|
|
dbg: ../bin/verilator_bin_dbg$(EXEEXT) ../bin/verilator_coverage_bin_dbg$(EXEEXT)
|
|
../bin/verilator_bin_dbg$(EXEEXT): obj_dbg ../bin prefiles
|
|
$(BEAR_OBJ_OPT) $(MAKE) -C obj_dbg -j 1 TGT=../$@ VL_DEBUG=1 -f ../Makefile_obj serial
|
|
$(BEAR_OBJ_OPT) $(MAKE) -C obj_dbg TGT=../$@ VL_DEBUG=1 -f ../Makefile_obj
|
|
|
|
../bin/verilator_coverage_bin_dbg$(EXEEXT): obj_dbg ../bin prefiles
|
|
$(MAKE) -C obj_dbg TGT=../$@ VL_DEBUG=1 VL_VLCOV=1 -f ../Makefile_obj
|
|
|
|
ifneq ($(VERILATOR_NO_OPT_BUILD),1) # Faster laptop development... don't rebuild each commit
|
|
ifneq ($(UNDER_GIT),) # If local git tree... else don't burden users
|
|
GIT_CHANGE_DEP = ${srcdir}/../.git/logs/HEAD
|
|
endif
|
|
endif
|
|
|
|
prefiles::
|
|
prefiles:: config_rev.h obj_shared/vlcovgen.d
|
|
|
|
# Generate the shared header once, before any binary can read it.
|
|
obj_shared/vlcovgen.d: ${srcdir}/vlcovgen ${srcdir}/../include/verilated_cov_key.h | obj_shared
|
|
$(PYTHON3) ${srcdir}/vlcovgen --srcdir ${srcdir}
|
|
touch $@
|
|
|
|
# This output goes into srcdir if locally configured, as we need to distribute it as part of the kit.
|
|
config_rev.h: ${srcdir}/config_rev $(GIT_CHANGE_DEP)
|
|
$(PYTHON3) ${srcdir}/config_rev ${srcdir} >$@
|
|
|
|
# Human convenience
|
|
format:
|
|
$(MAKE) -C .. $@
|
|
clang-format:
|
|
$(MAKE) -C .. $@
|
|
|
|
maintainer-copy::
|
|
clean mostlyclean distclean maintainer-clean::
|
|
-rm -f config_rev.h
|
|
-rm -rf obj_* *.log *.dmp *.vpd core
|
|
-rm -f *.o *.d *_gen_*
|
|
-rm -f *__gen* obj_*
|
|
-rm -f .objcache*
|
|
|
|
distclean maintainer-clean::
|
|
-rm -f Makefile Makefile_obj config_package.h
|
|
|
|
maintainer-clean::
|
|
-rm -f config_rev.h
|