From 51545b36cac3281607631a735fd9413598f7b345 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 24 Jun 2025 17:58:55 -0400 Subject: [PATCH] Internals: Add format-make rule and standardize Makefile indents. No functional change intended. --- .bake.toml | 30 ++ Makefile.in | 203 +++++++------- docs/Makefile | 2 +- examples/cmake_hello_c/Makefile | 30 +- examples/cmake_hello_sc/Makefile | 60 ++-- examples/cmake_protect_lib/Makefile | 30 +- examples/cmake_tracing_c/Makefile | 30 +- examples/cmake_tracing_sc/Makefile | 60 ++-- examples/json_py/Makefile | 10 +- examples/make_hello_binary/Makefile | 8 +- examples/make_hello_c/Makefile | 8 +- examples/make_hello_sc/Makefile | 12 +- examples/make_protect_lib/Makefile | 9 +- examples/make_tracing_c/Makefile | 12 +- examples/make_tracing_c/Makefile_obj | 4 +- examples/make_tracing_sc/Makefile | 16 +- examples/make_tracing_sc/Makefile_obj | 4 +- include/verilated.mk.in | 88 +++--- src/Makefile.in | 16 +- src/Makefile_obj.in | 384 +++++++++++++------------- test_regress/Makefile | 13 +- 21 files changed, 535 insertions(+), 494 deletions(-) create mode 100644 .bake.toml diff --git a/.bake.toml b/.bake.toml new file mode 100644 index 000000000..414bc7b5e --- /dev/null +++ b/.bake.toml @@ -0,0 +1,30 @@ +# mbake configuration file + +[formatter] +# Indentation settings +use_tabs = true +tab_width = 2 + +# Spacing settings +space_around_assignment = true +space_before_colon = false +space_after_colon = true + +# Line continuation settings +normalize_line_continuations = true +max_line_length = 100 + +# PHONY settings +group_phony_declarations = false +phony_at_top = false +auto_insert_phony_declarations = false + +# General settings +remove_trailing_whitespace = true +ensure_final_newline = true +normalize_empty_lines = true +max_consecutive_empty_lines = 2 + +# Global settings +debug = false +verbose = false diff --git a/Makefile.in b/Makefile.in index 88a239a6f..9b227e719 100644 --- a/Makefile.in +++ b/Makefile.in @@ -104,45 +104,45 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ SHELL = /bin/sh SUBDIRS = docs src test_regress \ - examples/cmake_hello_c \ - examples/cmake_hello_sc \ - examples/cmake_tracing_c \ - examples/cmake_tracing_sc \ - examples/cmake_protect_lib \ - examples/make_hello_binary \ - examples/make_hello_c \ - examples/make_hello_sc \ - examples/make_tracing_c \ - examples/make_tracing_sc \ - examples/make_protect_lib \ - examples/json_py \ + examples/cmake_hello_c \ + examples/cmake_hello_sc \ + examples/cmake_tracing_c \ + examples/cmake_tracing_sc \ + examples/cmake_protect_lib \ + examples/make_hello_binary \ + examples/make_hello_c \ + examples/make_hello_sc \ + examples/make_tracing_c \ + examples/make_tracing_sc \ + examples/make_protect_lib \ + examples/json_py \ INFOS = verilator.html verilator.pdf INFOS_OLD = README README.html README.pdf EXAMPLES_FIRST = \ - examples/make_hello_c \ - examples/make_hello_sc \ + examples/make_hello_c \ + examples/make_hello_sc \ EXAMPLES = $(EXAMPLES_FIRST) $(filter-out $(EXAMPLES_FIRST), $(sort $(wildcard examples/*))) # See uninstall also - don't put wildcards in this variable, it might uninstall other stuff # No verilator_ccache_report.1, verilator_difftree.1 as those are not bin/ installed VL_INST_MAN_FILES = \ - verilator.1 \ - verilator_coverage.1 \ - verilator_gantt.1 \ - verilator_profcfunc.1 \ + verilator.1 \ + verilator_coverage.1 \ + verilator_gantt.1 \ + verilator_profcfunc.1 \ default: all all: all_nomsg msg_test all_nomsg: verilator_exe $(VL_INST_MAN_FILES) -.PHONY:verilator_exe -.PHONY:verilator_bin$(EXEEXT) -.PHONY:verilator_bin_dbg$(EXEEXT) -.PHONY:verilator_coverage_bin_dbg$(EXEEXT) +.PHONY: verilator_exe +.PHONY: verilator_bin$(EXEEXT) +.PHONY: verilator_bin_dbg$(EXEEXT) +.PHONY: verilator_coverage_bin_dbg$(EXEEXT) verilator_exe verilator_bin$(EXEEXT) verilator_bin_dbg$(EXEEXT) verilator_coverage_bin_dbg$(EXEEXT): @echo ------------------------------------------------------------ @echo "making verilator in src" @@ -151,7 +151,7 @@ verilator_exe verilator_bin$(EXEEXT) verilator_bin_dbg$(EXEEXT) verilator_covera ###################################################################### # Tests -.PHONY:msg_test +.PHONY: msg_test msg_test: all_nomsg @echo "Build complete!" @echo @@ -213,8 +213,8 @@ verilator.html: verilator.pdf: Makefile $(MAKE) -C docs verilator.pdf -TAGFILES=${srcdir}/*/*.cpp ${srcdir}/*/*.h ${srcdir}/*/*.in \ - ${srcdir}/*.in ${srcdir}/*.pod +TAGFILES = ${srcdir}/*/*.cpp ${srcdir}/*/*.h ${srcdir}/*/*.in \ + ${srcdir}/*.in ${srcdir}/*.pod TAGS: $(TAGFILES) etags $(TAGFILES) @@ -228,43 +228,45 @@ doxygen: spelling: $(MAKE) -C docs spelling - ###################################################################### # Install # Public executables intended to be invoked directly by the user # Don't put wildcards in these variables, it might cause an uninstall of other stuff -VL_INST_PUBLIC_SCRIPT_FILES = verilator \ - verilator_coverage \ - verilator_gantt \ - verilator_profcfunc \ +VL_INST_PUBLIC_SCRIPT_FILES = \ + verilator \ + verilator_coverage \ + verilator_gantt \ + verilator_profcfunc \ -VL_INST_PUBLIC_BIN_FILES = verilator_bin$(EXEEXT) \ - verilator_bin_dbg$(EXEEXT) \ - verilator_coverage_bin_dbg$(EXEEXT) \ +VL_INST_PUBLIC_BIN_FILES = \ + verilator_bin$(EXEEXT) \ + verilator_bin_dbg$(EXEEXT) \ + verilator_coverage_bin_dbg$(EXEEXT) \ # Private executabels intended to be invoked by internals # Don't put wildcards in these variables, it might cause an uninstall of other stuff -VL_INST_PRIVATE_SCRIPT_FILES = verilator_ccache_report \ - verilator_includer \ +VL_INST_PRIVATE_SCRIPT_FILES = \ + verilator_ccache_report \ + verilator_includer \ VL_INST_INC_BLDDIR_FILES = \ - include/verilated_config.h \ - include/verilated.mk \ + include/verilated_config.h \ + include/verilated.mk \ # Files under srcdir, instead of build time VL_INST_INC_SRCDIR_FILES = \ - include/*.[chv]* \ - include/*.vlt \ - include/*.sv \ - include/gtkwave/*.[chv]* \ - include/vltstd/*.[chv]* \ + include/*.[chv]* \ + include/*.vlt \ + include/*.sv \ + include/gtkwave/*.[chv]* \ + include/vltstd/*.[chv]* \ VL_INST_DATA_SRCDIR_FILES = \ - examples/*/*.[chv]* \ - examples/*/CMakeLists.txt \ - examples/*/Makefile* \ - examples/*/vl_* \ + examples/*/*.[chv]* \ + examples/*/CMakeLists.txt \ + examples/*/Makefile* \ + examples/*/vl_* \ mkbindirs: $(MKINSTALLDIRS) $(DESTDIR)$(pkgdatadir)/bin @@ -400,19 +402,20 @@ CPPCHECK6_CPP = $(wildcard $(srcdir)/src/V3[P-Z]*.cpp) CPPCHECK7_CPP = $(wildcard $(srcdir)/src/V3[L-R]*.cpp) CPPCHECK8_CPP = $(wildcard $(srcdir)/src/V3[S-Z]*.cpp) CHECK_CPP = $(CPPCHECK1_CPP) $(CPPCHECK2_CPP) $(CPPCHECK3_CPP) $(CPPCHECK4_CPP) \ - $(CPPCHECK5_CPP) $(CPPCHECK6_CPP) $(CPPCHECK7_CPP) $(CPPCHECK8_CPP) + $(CPPCHECK5_CPP) $(CPPCHECK6_CPP) $(CPPCHECK7_CPP) $(CPPCHECK8_CPP) CHECK_H = $(wildcard \ - $(srcdir)/include/*.h \ - $(srcdir)/src/*.h ) + $(srcdir)/include/*.h \ + $(srcdir)/src/*.h ) CHECK_YL = $(wildcard \ - $(srcdir)/src/*.y \ - $(srcdir)/src/*.l ) + $(srcdir)/src/*.y \ + $(srcdir)/src/*.l ) CPPCHECK = src/cppcheck_filtered cppcheck CPPCHECK_FLAGS = --enable=all --inline-suppr \ - --suppress=cstyleCast --suppress=useInitializationList \ - --suppress=nullPointer --suppress=nullPointerRedundantCheck --suppress=ctunullpointer \ - --suppress=unusedFunction --suppress=unusedScopedObject \ - --suppress=useStlAlgorithm + --suppress=cstyleCast --suppress=useInitializationList \ + --suppress=nullPointer --suppress=nullPointerRedundantCheck --suppress=ctunullpointer \ + --suppress=unusedFunction --suppress=unusedScopedObject \ + --suppress=useStlAlgorithm \ + CPPCHECK_FLAGS += --xml CPPCHECK_DEP = $(subst .cpp,.cppcheck,$(CHECK_CPP)) CPPCHECK_INC = -I$(srcdir)/include -I$(srcdir)/include/gtkwave -I$(srcdir)/include/vltstd -I$(srcdir)/src/obj_dbg -I$(srcdir)/src @@ -437,8 +440,8 @@ cppcheck-8: CLANGTIDY = clang-tidy CLANGTIDY_FLAGS = -config='' \ - -header-filter='.*' \ - -checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-avoid-goto,-modernize-avoid-c-arrays,-readability-magic-numbers,-readability-simplify-boolean-expr,-cppcoreguidelines-macro-usage' \ + -header-filter='.*' \ + -checks='-fuchsia-*,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-init-variables,-cppcoreguidelines-avoid-goto,-modernize-avoid-c-arrays,-readability-magic-numbers,-readability-simplify-boolean-expr,-cppcoreguidelines-macro-usage' \ CLANGTIDY_DEP = $(subst .cpp,.cpp.tidy,$(CHECK_CPP)) CLANGTIDY_DEFS = -DVL_DEBUG=1 -DVL_CPPCHECK=1 @@ -476,50 +479,58 @@ yamlfix: # CMake files CMAKE_FILES = \ - CMakeLists.txt \ - examples/*/CMakeLists.txt \ - src/CMakeLists.txt \ - test_regress/CMakeLists.txt \ - *.cmake.in \ + CMakeLists.txt \ + examples/*/CMakeLists.txt \ + src/CMakeLists.txt \ + test_regress/CMakeLists.txt \ + *.cmake.in \ + +# Makefiles +MAKE_FILES = \ + Makefile*.in \ + docs/Makefile* \ + include/verilated.mk.in \ + examples/*/Makefile* \ + src/Makefile*.in \ + test_regress/Makefile* \ # Python programs, subject to format and lint PY_PROGRAMS = \ - bin/verilator_ccache_report \ - bin/verilator_difftree \ - bin/verilator_gantt \ - bin/verilator_includer \ - bin/verilator_profcfunc \ - examples/json_py/vl_file_copy \ - examples/json_py/vl_hier_graph \ - docs/guide/conf.py \ - docs/bin/vl_sphinx_extract \ - docs/bin/vl_sphinx_fix \ - src/astgen \ - src/bisonpre \ - src/config_rev \ - src/cppcheck_filtered \ - src/flexfix \ - src/vlcovgen \ - src/.gdbinit.py \ - test_regress/*.py \ - test_regress/t/*.pf \ - nodist/clang_check_attributes \ - nodist/code_coverage \ - nodist/dot_importer \ - nodist/fuzzer/actual_fail \ - nodist/fuzzer/generate_dictionary \ - nodist/install_test \ - nodist/log_changes \ + bin/verilator_ccache_report \ + bin/verilator_difftree \ + bin/verilator_gantt \ + bin/verilator_includer \ + bin/verilator_profcfunc \ + examples/json_py/vl_file_copy \ + examples/json_py/vl_hier_graph \ + docs/guide/conf.py \ + docs/bin/vl_sphinx_extract \ + docs/bin/vl_sphinx_fix \ + src/astgen \ + src/bisonpre \ + src/config_rev \ + src/cppcheck_filtered \ + src/flexfix \ + src/vlcovgen \ + src/.gdbinit.py \ + test_regress/*.py \ + test_regress/t/*.pf \ + nodist/clang_check_attributes \ + nodist/code_coverage \ + nodist/dot_importer \ + nodist/fuzzer/actual_fail \ + nodist/fuzzer/generate_dictionary \ + nodist/install_test \ + nodist/log_changes \ # Python files, subject to format but not lint PY_FILES = \ - $(PY_PROGRAMS) \ - nodist/code_coverage.dat \ - test_regress/t/*.py \ + $(PY_PROGRAMS) \ + nodist/code_coverage.dat \ + test_regress/t/*.py \ # Python files, test_regress tests -PY_TEST_FILES = \ - test_regress/t/*.py \ +PY_TEST_FILES = test_regress/t/*.py YAPF = yapf3 YAPF_FLAGS = -i --parallel @@ -533,6 +544,12 @@ GERSEMI_FLAGS = -i format-cmake: $(GERSEMI) $(GERSEMI_FLAGS) $(CMAKE_FILES) +MBAKE = mbake +MBAKE_FLAGS = format --config ./.bake.toml + +format-make: + $(MBAKE) $(MBAKE_FLAGS) $(MAKE_FILES) + format-yaml: yamlfix PYLINT = pylint diff --git a/docs/Makefile b/docs/Makefile index a0d42140b..98b2f47d8 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -25,7 +25,7 @@ BUILDDIR = _build SPHINXOPTS ?= -c guide -j 4 ifneq ($(VERILATOR_ANALYTICS_ID),) -SPHINXOPTS += -D html_theme_options.analytics_id=$(VERILATOR_ANALYTICS_ID) + SPHINXOPTS += -D html_theme_options.analytics_id=$(VERILATOR_ANALYTICS_ID) endif ###################################################################### diff --git a/examples/cmake_hello_c/Makefile b/examples/cmake_hello_c/Makefile index 584c55a03..a6bb88304 100644 --- a/examples/cmake_hello_c/Makefile +++ b/examples/cmake_hello_c/Makefile @@ -20,28 +20,28 @@ # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif ###################################################################### # Check if CMake is installed and of correct version ifeq ($(shell which cmake),) -TARGET := nocmake + TARGET := nocmake else -CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') -CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) -CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) -CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) -ifeq ($(CMAKE_GT_3_8),true) -TARGET := run -else -TARGET := oldcmake -endif + CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') + CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) + CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) + CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) + ifeq ($(CMAKE_GT_3_8),true) + TARGET := run + else + TARGET := oldcmake + endif endif default: $(TARGET) diff --git a/examples/cmake_hello_sc/Makefile b/examples/cmake_hello_sc/Makefile index 7a7e2b64d..df2a9bd52 100644 --- a/examples/cmake_hello_sc/Makefile +++ b/examples/cmake_hello_sc/Makefile @@ -20,46 +20,44 @@ # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif ###################################################################### # Check if CMake is installed and of correct version ifeq ($(shell which cmake),) - TARGET := nocmake -else -CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') -CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) -CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) -CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) -ifneq ($(CMAKE_GT_3_8),true) -TARGET := oldcmake + TARGET := nocmake else + CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') + CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) + CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) + CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) + ifneq ($(CMAKE_GT_3_8),true) + TARGET := oldcmake + else + # Check if SC exists via a verilator call (empty if not) + SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC) -# Check if SC exists via a verilator call (empty if not) -SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC) + # Test whether SystemC is installed with CMake support + # This will print a CMake error about processing arguments that can (currently) be ignored. + ifneq (,$(SYSTEMC_EXISTS)) + FINDSC := $(shell mkdir -p build && cd build && cmake --find-package -DNAME=SystemCLanguage -DCMAKE_USE_PTHREADS_INIT=ON -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST -DThreads_FOUND=ON) + ifneq (,$(findstring SystemCLanguage found,$(FINDSC))) + SYSTEMC_SET := true + endif + endif -# Test whether SystemC is installed with CMake support -# This will print a CMake error about processing arguments that can (currently) be ignored. -ifneq (,$(SYSTEMC_EXISTS)) -FINDSC := $(shell mkdir -p build && cd build && cmake --find-package -DNAME=SystemCLanguage -DCMAKE_USE_PTHREADS_INIT=ON -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST -DThreads_FOUND=ON) -ifneq (,$(findstring SystemCLanguage found,$(FINDSC))) -SYSTEMC_SET := true -endif -endif - -ifeq ($(SYSTEMC_SET), true) -TARGET := run -else -TARGET := nosc -endif - -endif + ifeq ($(SYSTEMC_SET), true) + TARGET := run + else + TARGET := nosc + endif + endif endif default: $(TARGET) diff --git a/examples/cmake_protect_lib/Makefile b/examples/cmake_protect_lib/Makefile index 6bec54bf3..e33a41038 100644 --- a/examples/cmake_protect_lib/Makefile +++ b/examples/cmake_protect_lib/Makefile @@ -20,28 +20,28 @@ # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif ###################################################################### # Check if CMake is installed and of correct version ifeq ($(shell which cmake),) -TARGET := nocmake + TARGET := nocmake else -CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') -CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) -CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) -CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) -ifeq ($(CMAKE_GT_3_8),true) -TARGET := run -else -TARGET := oldcmake -endif + CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') + CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) + CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) + CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) + ifeq ($(CMAKE_GT_3_8),true) + TARGET := run + else + TARGET := oldcmake + endif endif default: $(TARGET) diff --git a/examples/cmake_tracing_c/Makefile b/examples/cmake_tracing_c/Makefile index 220ec52fb..4a14fbc1e 100644 --- a/examples/cmake_tracing_c/Makefile +++ b/examples/cmake_tracing_c/Makefile @@ -20,28 +20,28 @@ # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif ###################################################################### # Check if CMake is installed and of correct version ifeq ($(shell which cmake),) -TARGET := nocmake + TARGET := nocmake else -CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') -CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) -CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) -CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) -ifeq ($(CMAKE_GT_3_8),true) -TARGET := run -else -TARGET := oldcmake -endif + CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') + CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) + CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) + CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) + ifeq ($(CMAKE_GT_3_8),true) + TARGET := run + else + TARGET := oldcmake + endif endif default: $(TARGET) diff --git a/examples/cmake_tracing_sc/Makefile b/examples/cmake_tracing_sc/Makefile index b479eddf8..2346cfebd 100644 --- a/examples/cmake_tracing_sc/Makefile +++ b/examples/cmake_tracing_sc/Makefile @@ -20,46 +20,44 @@ # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif ###################################################################### # Check if CMake is installed and of correct version ifeq ($(shell which cmake),) - TARGET := nocmake -else -CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') -CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) -CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) -CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) -ifneq ($(CMAKE_GT_3_8),true) -TARGET := oldcmake + TARGET := nocmake else + CMAKE_VERSION := $(shell cmake --version | grep -o '[0-9][.0-9]\+') + CMAKE_MAJOR := $(shell echo $(CMAKE_VERSION) | cut -f1 -d.) + CMAKE_MINOR := $(shell echo $(CMAKE_VERSION) | cut -f2 -d.) + CMAKE_GT_3_8 := $(shell [ $(CMAKE_MAJOR) -gt 3 -o \( $(CMAKE_MAJOR) -eq 3 -a $(CMAKE_MINOR) -ge 8 \) ] && echo true) + ifneq ($(CMAKE_GT_3_8),true) + TARGET := oldcmake + else + # Check if SC exists via a verilator call (empty if not) + SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC) -# Check if SC exists via a verilator call (empty if not) -SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC) + # Test whether SystemC is installed with CMake support + # This will print a CMake error about processing arguments that can (currently) be ignored. + ifneq (,$(SYSTEMC_EXISTS)) + FINDSC := $(shell mkdir -p build && cd build && cmake --find-package -DNAME=SystemCLanguage -DCMAKE_USE_PTHREADS_INIT=ON -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST -DThreads_FOUND=ON) + ifneq (,$(findstring SystemCLanguage found,$(FINDSC))) + SYSTEMC_SET := true + endif + endif -# Test whether SystemC is installed with CMake support -# This will print a CMake error about processing arguments that can (currently) be ignored. -ifneq (,$(SYSTEMC_EXISTS)) -FINDSC := $(shell mkdir -p build && cd build && cmake --find-package -DNAME=SystemCLanguage -DCMAKE_USE_PTHREADS_INIT=ON -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST -DThreads_FOUND=ON) -ifneq (,$(findstring SystemCLanguage found,$(FINDSC))) -SYSTEMC_SET := true -endif -endif - -ifeq ($(SYSTEMC_SET), true) -TARGET := run -else -TARGET := nosc -endif - -endif + ifeq ($(SYSTEMC_SET), true) + TARGET := run + else + TARGET := nosc + endif + endif endif default: $(TARGET) diff --git a/examples/json_py/Makefile b/examples/json_py/Makefile index 1a6f5cd38..0f530185e 100644 --- a/examples/json_py/Makefile +++ b/examples/json_py/Makefile @@ -15,10 +15,10 @@ # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator + VERILATOR = verilator else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator endif DOT = dot @@ -31,9 +31,9 @@ PYTHON_VERSION_MINOR := $(word 2,${PYTHON_VERSION_FULL}) PYTHON_GE_3_5 := $(shell [ ${PYTHON_VERSION_MAJOR} -eq 3 -a ${PYTHON_VERSION_MINOR} -ge 5 ] && echo true) ifeq (${PYTHON_GE_3_5},true) -default: test + default: test else -default: python_message + default: python_message endif python_message: diff --git a/examples/make_hello_binary/Makefile b/examples/make_hello_binary/Makefile index 19bec2dd0..476d4829a 100644 --- a/examples/make_hello_binary/Makefile +++ b/examples/make_hello_binary/Makefile @@ -13,7 +13,7 @@ # Check for sanity to avoid later confusion ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -26,10 +26,10 @@ endif # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator + VERILATOR = verilator else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator endif default: diff --git a/examples/make_hello_c/Makefile b/examples/make_hello_c/Makefile index 98ce3a67e..95f2d3ca6 100644 --- a/examples/make_hello_c/Makefile +++ b/examples/make_hello_c/Makefile @@ -13,7 +13,7 @@ # Check for sanity to avoid later confusion ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -26,10 +26,10 @@ endif # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator + VERILATOR = verilator else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator endif default: diff --git a/examples/make_hello_sc/Makefile b/examples/make_hello_sc/Makefile index 20a26d034..20ee646f4 100644 --- a/examples/make_hello_sc/Makefile +++ b/examples/make_hello_sc/Makefile @@ -13,7 +13,7 @@ # Check for sanity to avoid later confusion ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -26,19 +26,19 @@ endif # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator + VERILATOR = verilator else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator endif # Check if SC exists via a verilator call (empty if not) SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC) ifneq ($(SYSTEMC_EXISTS),) -default: run + default: run else -default: nosc + default: nosc endif run: diff --git a/examples/make_protect_lib/Makefile b/examples/make_protect_lib/Makefile index 5628db9c6..f4cc7a0b0 100644 --- a/examples/make_protect_lib/Makefile +++ b/examples/make_protect_lib/Makefile @@ -13,7 +13,7 @@ # Check for sanity to avoid later confusion ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -23,10 +23,10 @@ endif # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator + VERILATOR = verilator else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator endif VERILATOR_FLAGS = @@ -90,7 +90,6 @@ run: @echo "To see waveforms, open logs/vlt_dump.vcd in a waveform viewer" @echo - ###################################################################### # Other targets diff --git a/examples/make_tracing_c/Makefile b/examples/make_tracing_c/Makefile index 060c4fa39..e501bc502 100644 --- a/examples/make_tracing_c/Makefile +++ b/examples/make_tracing_c/Makefile @@ -13,7 +13,7 @@ # Check for sanity to avoid later confusion ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -23,12 +23,12 @@ endif # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif # Generate C++ in executable form diff --git a/examples/make_tracing_c/Makefile_obj b/examples/make_tracing_c/Makefile_obj index d91039d21..d18fe44e1 100644 --- a/examples/make_tracing_c/Makefile_obj +++ b/examples/make_tracing_c/Makefile_obj @@ -32,7 +32,7 @@ CPPFLAGS += -DVL_DEBUG=1 # For testing inside Verilator, "configure --enable-ccwarn" will do this # automatically; otherwise you may want this unconditionally enabled ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users -USER_CPPFLAGS_WALL += -W -Werror -Wall + USER_CPPFLAGS_WALL += -W -Werror -Wall endif # See the benchmarking section of bin/verilator. @@ -51,5 +51,5 @@ OPT_FAST = -Os -fstrict-aliasing DEPS := $(wildcard *.d) ifneq ($(DEPS),) -include $(DEPS) + include $(DEPS) endif diff --git a/examples/make_tracing_sc/Makefile b/examples/make_tracing_sc/Makefile index b7b312d94..b5565a330 100644 --- a/examples/make_tracing_sc/Makefile +++ b/examples/make_tracing_sc/Makefile @@ -13,7 +13,7 @@ # Check for sanity to avoid later confusion ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -23,12 +23,12 @@ endif # package install, and verilator is in your path. Otherwise find the # binary relative to $VERILATOR_ROOT (such as when inside the git sources). ifeq ($(VERILATOR_ROOT),) -VERILATOR = verilator -VERILATOR_COVERAGE = verilator_coverage + VERILATOR = verilator + VERILATOR_COVERAGE = verilator_coverage else -export VERILATOR_ROOT -VERILATOR = $(VERILATOR_ROOT)/bin/verilator -VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage + export VERILATOR_ROOT + VERILATOR = $(VERILATOR_ROOT)/bin/verilator + VERILATOR_COVERAGE = $(VERILATOR_ROOT)/bin/verilator_coverage endif VERILATOR_FLAGS = @@ -60,9 +60,9 @@ SYSTEMC_EXISTS := $(shell $(VERILATOR) --get-supported SYSTEMC) ###################################################################### ifneq ($(SYSTEMC_EXISTS),) -default: run + default: run else -default: nosc + default: nosc endif run: diff --git a/examples/make_tracing_sc/Makefile_obj b/examples/make_tracing_sc/Makefile_obj index be55d066c..834bfc7ba 100644 --- a/examples/make_tracing_sc/Makefile_obj +++ b/examples/make_tracing_sc/Makefile_obj @@ -31,7 +31,7 @@ CPPFLAGS += -Wno-deprecated # For testing inside Verilator, "configure --enable-ccwarn" will do this # automatically; otherwise you may want this unconditionally enabled ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users -USER_CPPFLAGS_WALL += -W -Werror -Wall + USER_CPPFLAGS_WALL += -W -Werror -Wall endif # If you build your own rules from scratch, note you need to include @@ -61,5 +61,5 @@ sim_main.o: sim_main.cpp $(VM_PREFIX).h DEPS := $(wildcard *.d) ifneq ($(DEPS),) -include $(DEPS) + include $(DEPS) endif diff --git a/include/verilated.mk.in b/include/verilated.mk.in index e89880a2d..a7a1f021c 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -69,7 +69,7 @@ export CCACHE_SLOPPINESS # Make checks ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif ###################################################################### @@ -81,20 +81,20 @@ UNAME_S := $(shell uname -s) # Add -MMD -MP if you're using a recent version of GCC. VK_CPPFLAGS_ALWAYS += \ - -MMD \ - -I$(VERILATOR_ROOT)/include \ - -I$(VERILATOR_ROOT)/include/vltstd \ - -DVM_COVERAGE=$(VM_COVERAGE) \ - -DVM_SC=$(VM_SC) \ - -DVM_TIMING=$(VM_TIMING) \ - -DVM_TRACE=$(VM_TRACE) \ - -DVM_TRACE_FST=$(VM_TRACE_FST) \ - -DVM_TRACE_VCD=$(VM_TRACE_VCD) \ - -DVM_TRACE_SAIF=$(VM_TRACE_SAIF) \ - $(CFG_CXXFLAGS_NO_UNUSED) \ + -MMD \ + -I$(VERILATOR_ROOT)/include \ + -I$(VERILATOR_ROOT)/include/vltstd \ + -DVM_COVERAGE=$(VM_COVERAGE) \ + -DVM_SC=$(VM_SC) \ + -DVM_TIMING=$(VM_TIMING) \ + -DVM_TRACE=$(VM_TRACE) \ + -DVM_TRACE_FST=$(VM_TRACE_FST) \ + -DVM_TRACE_VCD=$(VM_TRACE_VCD) \ + -DVM_TRACE_SAIF=$(VM_TRACE_SAIF) \ + $(CFG_CXXFLAGS_NO_UNUSED) \ ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users -VK_CPPFLAGS_WALL += -Wall $(CFG_CXXFLAGS_WEXTRA) -Werror + VK_CPPFLAGS_WALL += -Wall $(CFG_CXXFLAGS_WEXTRA) -Werror endif CPPFLAGS += -I. $(VK_CPPFLAGS_WALL) $(VK_CPPFLAGS_ALWAYS) @@ -103,7 +103,7 @@ VPATH += .. VPATH += $(VERILATOR_ROOT)/include VPATH += $(VERILATOR_ROOT)/include/vltstd -LDFLAGS += $(CFG_LDFLAGS_VERILATED) +LDFLAGS += $(CFG_LDFLAGS_VERILATED) #OPT = -ggdb -DPRINTINITSTR -DDETECTCHANGE #OPT = -ggdb -DPRINTINITSTR @@ -112,19 +112,19 @@ CPPFLAGS += $(OPT) # On macOS, specify all weak symbols as dynamic_lookup. # Otherwise, you get undefined symbol errors. ifeq ($(UNAME_S),Darwin) - LDFLAGS += -Wl,-U,__Z15vl_time_stamp64v,-U,__Z13sc_time_stampv + LDFLAGS += -Wl,-U,__Z15vl_time_stamp64v,-U,__Z13sc_time_stampv endif # Allow upper level user makefiles to specify flags they want. # These aren't ever set by Verilator, so users are free to override them. CPPFLAGS += $(USER_CPPFLAGS) -LDFLAGS += $(USER_LDFLAGS) -LDLIBS += $(USER_LDLIBS) +LDFLAGS += $(USER_LDFLAGS) +LDLIBS += $(USER_LDLIBS) # Add flags from -CFLAGS and -LDFLAGS on Verilator command line CPPFLAGS += $(VM_USER_CFLAGS) -LDFLAGS += $(VM_USER_LDFLAGS) -LDLIBS += $(VM_USER_LDLIBS) +LDFLAGS += $(VM_USER_LDFLAGS) +LDLIBS += $(VM_USER_LDLIBS) ###################################################################### # Optimization control. @@ -148,7 +148,7 @@ OPT_GLOBAL = -Os ifeq ($(VM_PROFC),1) CPPFLAGS += $(CFG_CXXFLAGS_PROFILE) - LDFLAGS += $(CFG_CXXFLAGS_PROFILE) + LDFLAGS += $(CFG_CXXFLAGS_PROFILE) endif ####################################################################### @@ -156,12 +156,12 @@ endif ifeq ($(VM_SC),1) CPPFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -I, $(SYSTEMC_INCLUDE)) - LDFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -L, $(SYSTEMC_LIBDIR)) - SC_LIBS = -lsystemc - ifneq ($(wildcard $(SYSTEMC_LIBDIR)/*numeric_bit*),) - # SystemC 1.2.1beta - SC_LIBS += -lnumeric_bit -lqt - endif + LDFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -L, $(SYSTEMC_LIBDIR)) + SC_LIBS = -lsystemc + ifneq ($(wildcard $(SYSTEMC_LIBDIR)/*numeric_bit*),) + # SystemC 1.2.1beta + SC_LIBS += -lnumeric_bit -lqt + endif endif ####################################################################### @@ -171,12 +171,11 @@ CPPFLAGS += $(CFG_CXXFLAGS_STD) LDLIBS += $(CFG_LDLIBS_THREADS) ifneq ($(VM_TIMING),0) - ifneq ($(VM_TIMING),) - CPPFLAGS += $(CFG_CXXFLAGS_COROUTINES) - endif + ifneq ($(VM_TIMING),) + CPPFLAGS += $(CFG_CXXFLAGS_COROUTINES) + endif endif - ####################################################################### ### Aggregates @@ -258,7 +257,6 @@ endif $(VM_PREFIX)__ALL.a: $(VK_OBJS) $(VM_HIER_LIBS) - ###################################################################### ### Compile rules @@ -269,24 +267,24 @@ ifneq ($(VM_DEFAULT_RULES),0) # # These rules put OPT_FAST/OPT_SLOW/OPT_GLOBAL before the other flags to # allow USER_CPPFLAGS to override them -%.o: %.cpp + %.o: %.cpp $(OBJCACHE) $(CXX) $(OPT_FAST) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< -$(VK_OBJS_FAST): %.o: %.cpp $(VK_PCH_H).fast.gch + $(VK_OBJS_FAST): %.o: %.cpp $(VK_PCH_H).fast.gch $(OBJCACHE) $(CXX) $(OPT_FAST) $(CXXFLAGS) $(CPPFLAGS) $(VK_PCH_I_FAST) -c -o $@ $< -$(VK_OBJS_SLOW): %.o: %.cpp $(VK_PCH_H).slow.gch + $(VK_OBJS_SLOW): %.o: %.cpp $(VK_PCH_H).slow.gch $(OBJCACHE) $(CXX) $(OPT_SLOW) $(CXXFLAGS) $(CPPFLAGS) $(VK_PCH_I_SLOW) -c -o $@ $< -$(VK_GLOBAL_OBJS): %.o: %.cpp + $(VK_GLOBAL_OBJS): %.o: %.cpp $(OBJCACHE) $(CXX) $(OPT_GLOBAL) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< # Precompile a header file # PCH's compiler flags must match exactly the rules' above FAST/SLOW # arguments used for the .cpp files, or the PCH file won't be used. -%.fast.gch: % + %.fast.gch: % $(OBJCACHE) $(CXX) $(OPT_FAST) $(CXXFLAGS) $(CPPFLAGS) $(CFG_CXXFLAGS_PCH) $< -o $@ -%.slow.gch: % + %.slow.gch: % $(OBJCACHE) $(CXX) $(OPT_SLOW) $(CXXFLAGS) $(CPPFLAGS) $(CFG_CXXFLAGS_PCH) $< -o $@ endif @@ -313,22 +311,22 @@ ifneq ($(findstring ccache-report,$(MAKECMDGOALS)),) # Remove previous logfiles and report $(shell rm -rf $(VK_CCACHE_LOGDIR) $(VK_CCACHE_REPORT)) -$(VK_CCACHE_LOGDIR): + $(VK_CCACHE_LOGDIR): mkdir -p $@ -$(VK_OBJS): | $(VK_CCACHE_LOGDIR) + $(VK_OBJS): | $(VK_CCACHE_LOGDIR) -$(VK_OBJS): export CCACHE_LOGFILE=$(VK_CCACHE_LOGDIR)/$@.log + $(VK_OBJS): export CCACHE_LOGFILE=$(VK_CCACHE_LOGDIR)/$@.log -$(VK_CCACHE_REPORT): $(VK_OBJS) + $(VK_CCACHE_REPORT): $(VK_OBJS) $(VERILATOR_CCACHE_REPORT) -o $@ $(VK_CCACHE_LOGDIR) -.PHONY: ccache-report -ccache-report: $(VK_CCACHE_REPORT) + .PHONY: ccache-report + ccache-report: $(VK_CCACHE_REPORT) @cat $< # ccache-report runs last -ccache-report: $(VK_OTHER_GOALS) + ccache-report: $(VK_OTHER_GOALS) endif ###################################################################### @@ -358,5 +356,5 @@ debug-make:: DEPS := $(wildcard *.d) ifneq ($(DEPS),) -include $(DEPS) + include $(DEPS) endif diff --git a/src/Makefile.in b/src/Makefile.in index daf96c38e..1fb95ab68 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -30,7 +30,7 @@ debug: dbg optimize: opt ifneq ($(words $(CURDIR)),1) - $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') + $(error Unsupported: GNU Make cannot build in directories containing spaces, build elsewhere: '$(CURDIR)') endif UNDER_GIT = $(wildcard ${srcdir}/../.git/logs/HEAD) @@ -50,9 +50,9 @@ else endif ifneq ($(BEAR),) -BEAR_OBJ_OPT := $(BEAR) --append --output obj_dbg/compile_commands.json -- + BEAR_OBJ_OPT := $(BEAR) --append --output obj_dbg/compile_commands.json -- else -BEAR_OBJ_OPT := + BEAR_OBJ_OPT := endif #********************************************************************* @@ -70,11 +70,11 @@ obj_dbg: opt: ../bin/verilator_bin$(EXEEXT) ifeq ($(VERILATOR_NO_OPT_BUILD),1) # Faster laptop development... One build -../bin/verilator_bin$(EXEEXT): ../bin/verilator_bin_dbg$(EXEEXT) + ../bin/verilator_bin$(EXEEXT): ../bin/verilator_bin_dbg$(EXEEXT) -cp -p $< $@.tmp -mv -f $@.tmp $@ else -../bin/verilator_bin$(EXEEXT): obj_opt ../bin prefiles + ../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 endif @@ -89,9 +89,9 @@ dbg: ../bin/verilator_bin_dbg$(EXEEXT) ../bin/verilator_coverage_bin_dbg$(EXEEXT $(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 + ifneq ($(UNDER_GIT),) # If local git tree... else don't burden users + GIT_CHANGE_DEP = ${srcdir}/../.git/logs/HEAD + endif endif prefiles:: diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 12269dea2..87a585fde 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -21,13 +21,13 @@ # from a level lower, so we need to move up if it's relative, not if absolute. config_srcdir = @srcdir@ ifeq ($(config_srcdir),.) - srcdir = .. + srcdir = .. else # Run an experiment - ifeq ($(wildcard $(config_srcdir)/../Makefile_obj.in),) - srcdir = $(config_srcdir) - else - srcdir = $(config_srcdir)/.. - endif + ifeq ($(wildcard $(config_srcdir)/../Makefile_obj.in),) + srcdir = $(config_srcdir) + else + srcdir = $(config_srcdir)/.. + endif endif incdir = $(srcdir)/../include @@ -81,14 +81,14 @@ TGT = ../../verilator_bin$(EXEEXT) ################# ifeq ($(VL_NOOPT),1) -CPPFLAGS += -O0 + CPPFLAGS += -O0 else ifeq ($(VL_DEBUG),) -# Optimize -CPPFLAGS += -O3 + # Optimize + CPPFLAGS += -O3 else -# Debug -CPPFLAGS += @CFG_CXXFLAGS_DEBUG@ -DVL_DEBUG -D_GLIBCXX_DEBUG -LDFLAGS += @CFG_LDFLAGS_DEBUG@ + # Debug + CPPFLAGS += @CFG_CXXFLAGS_DEBUG@ -DVL_DEBUG -D_GLIBCXX_DEBUG + LDFLAGS += @CFG_LDFLAGS_DEBUG@ endif ################# @@ -104,35 +104,35 @@ CPPFLAGS += -I. -I$(bldsrc) -I$(srcdir) -I$(incdir) -I../../include #CPPFLAGS += -DVL_LEAK_CHECKS # If running valgrind or other hunting tool CPPFLAGS += -MP # Only works on recent GCC versions ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users -CPPFLAGS += -W -Wall $(CFG_CXXFLAGS_WEXTRA) $(CFG_CXXFLAGS_SRC) -Werror -#CPPFLAGS += -pedantic-errors + CPPFLAGS += -W -Wall $(CFG_CXXFLAGS_WEXTRA) $(CFG_CXXFLAGS_SRC) -Werror + #CPPFLAGS += -pedantic-errors else -CPPFLAGS += $(CFG_CXXFLAGS_SRC) + CPPFLAGS += $(CFG_CXXFLAGS_SRC) endif LDFLAGS += $(CFG_LDFLAGS_SRC) -CPPFLAGSWALL = $(CPPFLAGS) +CPPFLAGSWALL = $(CPPFLAGS) CPPFLAGSPARSER = $(CPPFLAGS) $(CFG_CXXFLAGS_PARSER) # Allow RPM builds to specify hardcoded data directories # To do this: ifeq ($(CFG_WITH_DEFENV),yes) - CPPFLAGS += -DDEFENV_SYSTEMC=\"$(SYSTEMC)\" - CPPFLAGS += -DDEFENV_SYSTEMC_ARCH=\"$(SYSTEMC_ARCH)\" - CPPFLAGS += -DDEFENV_SYSTEMC_INCLUDE=\"$(SYSTEMC_INCLUDE)\" - CPPFLAGS += -DDEFENV_SYSTEMC_LIBDIR=\"$(SYSTEMC_LIBDIR)\" - ifeq ($(VERILATOR_ROOT),) # Use what we're given, or intuit - CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(pkgdatadir)\" - else - CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(VERILATOR_ROOT)\" - endif - ifneq ($(CFG_WITH_SOLVER),no) - CPPFLAGS += -DDEFENV_VERILATOR_SOLVER='"$(CFG_WITH_SOLVER)"' - else - ifneq ($(VERILATOR_SOLVER),) - CPPFLAGS += -DDEFENV_VERILATOR_SOLVER='"$(VERILATOR_SOLVER)"' + CPPFLAGS += -DDEFENV_SYSTEMC=\"$(SYSTEMC)\" + CPPFLAGS += -DDEFENV_SYSTEMC_ARCH=\"$(SYSTEMC_ARCH)\" + CPPFLAGS += -DDEFENV_SYSTEMC_INCLUDE=\"$(SYSTEMC_INCLUDE)\" + CPPFLAGS += -DDEFENV_SYSTEMC_LIBDIR=\"$(SYSTEMC_LIBDIR)\" + ifeq ($(VERILATOR_ROOT),) # Use what we're given, or intuit + CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(pkgdatadir)\" + else + CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(VERILATOR_ROOT)\" + endif + ifneq ($(CFG_WITH_SOLVER),no) + CPPFLAGS += -DDEFENV_VERILATOR_SOLVER='"$(CFG_WITH_SOLVER)"' + else + ifneq ($(VERILATOR_SOLVER),) + CPPFLAGS += -DDEFENV_VERILATOR_SOLVER='"$(VERILATOR_SOLVER)"' + endif endif - endif endif HEADERS = $(wildcard V*.h v*.h) @@ -171,175 +171,175 @@ maintainer-copy:: #### Top executable RAW_OBJS = \ - V3Const__gen.o \ - V3Error.o \ - V3FileLine.o \ - V3Graph.o \ - V3GraphAcyc.o \ - V3GraphAlg.o \ - V3GraphPathChecker.o \ - V3GraphTest.o \ - V3Hash.o \ - V3OptionParser.o \ - V3Os.o \ - V3ParseGrammar.o \ - V3ParseImp.o \ - V3ParseLex.o \ - V3PreProc.o \ - V3PreShell.o \ - V3String.o \ - V3ThreadPool.o \ - V3Waiver.o \ - Verilator.o \ + V3Const__gen.o \ + V3Error.o \ + V3FileLine.o \ + V3Graph.o \ + V3GraphAcyc.o \ + V3GraphAlg.o \ + V3GraphPathChecker.o \ + V3GraphTest.o \ + V3Hash.o \ + V3OptionParser.o \ + V3Os.o \ + V3ParseGrammar.o \ + V3ParseImp.o \ + V3ParseLex.o \ + V3PreProc.o \ + V3PreShell.o \ + V3String.o \ + V3ThreadPool.o \ + V3Waiver.o \ + Verilator.o \ RAW_OBJS_PCH_ASTMT = \ - V3Ast.o \ - V3AstNodes.o \ - V3Broken.o \ - V3Config.o \ - V3EmitCBase.o \ - V3EmitCConstPool.o \ - V3EmitCFunc.o \ - V3EmitCHeaders.o \ - V3EmitCImp.o \ - V3EmitCInlines.o \ - V3EmitCPch.o \ - V3EmitV.o \ - V3File.o \ - V3FuncOpt.o \ - V3Global.o \ - V3Hasher.o \ - V3Number.o \ - V3Options.o \ - V3Stats.o \ - V3StatsReport.o \ - V3VariableOrder.o \ + V3Ast.o \ + V3AstNodes.o \ + V3Broken.o \ + V3Config.o \ + V3EmitCBase.o \ + V3EmitCConstPool.o \ + V3EmitCFunc.o \ + V3EmitCHeaders.o \ + V3EmitCImp.o \ + V3EmitCInlines.o \ + V3EmitCPch.o \ + V3EmitV.o \ + V3File.o \ + V3FuncOpt.o \ + V3Global.o \ + V3Hasher.o \ + V3Number.o \ + V3Options.o \ + V3Stats.o \ + V3StatsReport.o \ + V3VariableOrder.o \ RAW_OBJS_PCH_ASTNOMT = \ - V3Active.o \ - V3ActiveTop.o \ - V3Assert.o \ - V3AssertPre.o \ - V3Begin.o \ - V3Branch.o \ - V3CCtors.o \ - V3CUse.o \ - V3Case.o \ - V3Cast.o \ - V3Class.o \ - V3Clean.o \ - V3Clock.o \ - V3Combine.o \ - V3Common.o \ - V3Coverage.o \ - V3CoverageJoin.o \ - V3Dead.o \ - V3Delayed.o \ - V3Depth.o \ - V3DepthBlock.o \ - V3Descope.o \ - V3Dfg.o \ - V3DfgAstToDfg.o \ - V3DfgCache.o \ - V3DfgDecomposition.o \ - V3DfgDfgToAst.o \ - V3DfgOptimizer.o \ - V3DfgPasses.o \ - V3DfgPeephole.o \ - V3DfgRegularize.o \ - V3DiagSarif.o \ - V3DupFinder.o \ - V3EmitCMain.o \ - V3EmitCMake.o \ - V3EmitCModel.o \ - V3EmitCSyms.o \ - V3EmitMk.o \ - V3EmitMkJson.o \ - V3EmitXml.o \ - V3ExecGraph.o \ - V3Expand.o \ - V3Force.o \ - V3Fork.o \ - V3Gate.o \ - V3HierBlock.o \ - V3Inline.o \ - V3Inst.o \ - V3InstrCount.o \ - V3Interface.o \ - V3Life.o \ - V3LifePost.o \ - V3LinkCells.o \ - V3LinkDot.o \ - V3LinkInc.o \ - V3LinkJump.o \ - V3LinkLValue.o \ - V3LinkLevel.o \ - V3LinkParse.o \ - V3LinkResolve.o \ - V3Localize.o \ - V3MergeCond.o \ - V3Name.o \ - V3Order.o \ - V3OrderGraphBuilder.o \ - V3OrderMoveGraph.o \ - V3OrderParallel.o \ - V3OrderProcessDomains.o \ - V3OrderSerial.o \ - V3Param.o \ - V3Premit.o \ - V3ProtectLib.o \ - V3Randomize.o \ - V3Reloop.o \ - V3Sampled.o \ - V3Sched.o \ - V3SchedAcyclic.o \ - V3SchedPartition.o \ - V3SchedReplicate.o \ - V3SchedTiming.o \ - V3SchedVirtIface.o \ - V3Scope.o \ - V3Scoreboard.o \ - V3Slice.o \ - V3Split.o \ - V3SplitAs.o \ - V3SplitVar.o \ - V3StackCount.o \ - V3Subst.o \ - V3TSP.o \ - V3Table.o \ - V3Task.o \ - V3Timing.o \ - V3Trace.o \ - V3TraceDecl.o \ - V3Tristate.o \ - V3Udp.o \ - V3Undriven.o \ - V3Unknown.o \ - V3Unroll.o \ - V3Width.o \ - V3WidthCommit.o \ - V3WidthSel.o \ + V3Active.o \ + V3ActiveTop.o \ + V3Assert.o \ + V3AssertPre.o \ + V3Begin.o \ + V3Branch.o \ + V3CCtors.o \ + V3CUse.o \ + V3Case.o \ + V3Cast.o \ + V3Class.o \ + V3Clean.o \ + V3Clock.o \ + V3Combine.o \ + V3Common.o \ + V3Coverage.o \ + V3CoverageJoin.o \ + V3Dead.o \ + V3Delayed.o \ + V3Depth.o \ + V3DepthBlock.o \ + V3Descope.o \ + V3Dfg.o \ + V3DfgAstToDfg.o \ + V3DfgCache.o \ + V3DfgDecomposition.o \ + V3DfgDfgToAst.o \ + V3DfgOptimizer.o \ + V3DfgPasses.o \ + V3DfgPeephole.o \ + V3DfgRegularize.o \ + V3DiagSarif.o \ + V3DupFinder.o \ + V3EmitCMain.o \ + V3EmitCMake.o \ + V3EmitCModel.o \ + V3EmitCSyms.o \ + V3EmitMk.o \ + V3EmitMkJson.o \ + V3EmitXml.o \ + V3ExecGraph.o \ + V3Expand.o \ + V3Force.o \ + V3Fork.o \ + V3Gate.o \ + V3HierBlock.o \ + V3Inline.o \ + V3Inst.o \ + V3InstrCount.o \ + V3Interface.o \ + V3Life.o \ + V3LifePost.o \ + V3LinkCells.o \ + V3LinkDot.o \ + V3LinkInc.o \ + V3LinkJump.o \ + V3LinkLValue.o \ + V3LinkLevel.o \ + V3LinkParse.o \ + V3LinkResolve.o \ + V3Localize.o \ + V3MergeCond.o \ + V3Name.o \ + V3Order.o \ + V3OrderGraphBuilder.o \ + V3OrderMoveGraph.o \ + V3OrderParallel.o \ + V3OrderProcessDomains.o \ + V3OrderSerial.o \ + V3Param.o \ + V3Premit.o \ + V3ProtectLib.o \ + V3Randomize.o \ + V3Reloop.o \ + V3Sampled.o \ + V3Sched.o \ + V3SchedAcyclic.o \ + V3SchedPartition.o \ + V3SchedReplicate.o \ + V3SchedTiming.o \ + V3SchedVirtIface.o \ + V3Scope.o \ + V3Scoreboard.o \ + V3Slice.o \ + V3Split.o \ + V3SplitAs.o \ + V3SplitVar.o \ + V3StackCount.o \ + V3Subst.o \ + V3TSP.o \ + V3Table.o \ + V3Task.o \ + V3Timing.o \ + V3Trace.o \ + V3TraceDecl.o \ + V3Tristate.o \ + V3Udp.o \ + V3Undriven.o \ + V3Unknown.o \ + V3Unroll.o \ + V3Width.o \ + V3WidthCommit.o \ + V3WidthSel.o \ # verilator_coverage VLCOV_OBJS = \ - VlcMain.o \ + VlcMain.o \ NON_STANDALONE_HEADERS = \ - V3AstInlines.h \ - V3AstNodeDType.h \ - V3AstNodeExpr.h \ - V3AstNodeOther.h \ - V3DfgVertices.h \ - V3ThreadPool.h \ - V3WidthRemove.h \ + V3AstInlines.h \ + V3AstNodeDType.h \ + V3AstNodeExpr.h \ + V3AstNodeOther.h \ + V3DfgVertices.h \ + V3ThreadPool.h \ + V3WidthRemove.h \ AST_DEFS := \ - V3AstNodeDType.h \ - V3AstNodeExpr.h \ - V3AstNodeOther.h \ + V3AstNodeDType.h \ + V3AstNodeExpr.h \ + V3AstNodeOther.h \ DFG_DEFS := \ - V3DfgVertices.h + V3DfgVertices.h #### astgen common flags @@ -350,11 +350,11 @@ ASTGENFLAGS += $(foreach f,$(DFG_DEFS),--dfgdef $f) #### Linking ifeq ($(VL_VLCOV),) -PREDEP_H = V3Ast__gen_forward_class_decls.h -OBJS += $(RAW_OBJS) $(RAW_OBJS_PCH_ASTMT) $(RAW_OBJS_PCH_ASTNOMT) + PREDEP_H = V3Ast__gen_forward_class_decls.h + OBJS += $(RAW_OBJS) $(RAW_OBJS_PCH_ASTMT) $(RAW_OBJS_PCH_ASTNOMT) else -PREDEP_H = -OBJS += $(VLCOV_OBJS) + PREDEP_H = + OBJS += $(VLCOV_OBJS) endif $(TGT): $(PREDEP_H) $(OBJS) @@ -454,5 +454,5 @@ header_cc: $(addsuffix __header_cc.o, $(basename $(HEADER_CC_H))) DEPS := $(wildcard *.d) ifneq ($(DEPS),) -include $(DEPS) + include $(DEPS) endif diff --git a/test_regress/Makefile b/test_regress/Makefile index 4df2bb3df..38e88f14f 100644 --- a/test_regress/Makefile +++ b/test_regress/Makefile @@ -36,7 +36,7 @@ endif # Run tests in parallel. ifeq ($(CFG_WITH_LONGTESTS),yes) - DRIVER_FLAGS ?= -j 0 --quiet --rerun + DRIVER_FLAGS ?= -j 0 --quiet --rerun endif .SUFFIXES: @@ -75,7 +75,7 @@ random: random_forever: while ( VERILATOR_NO_DEBUG=1 CPPFLAGS_ADD=-Wno-error $(MAKE) random ) ; do \ - echo ; \ + echo ; \ done ####################################################################### @@ -102,10 +102,11 @@ TEST_SNAP_DIR ?= snapshot # Command to diff directories TEST_DIFF_TOOL ?= $(if $(shell which icdiff), icdiff -N -r, diff -r) -TEST_SNAP_IGNORE := *.status *.log *.dat *.d *.o *.a *.so *stats*.txt *.html \ - *.includecache *.out *.fst *.fst.vcd *.tree *.tree*.json \ - *.dot *.csv *.xml *.hash *.cmake gmon.out.* CMakeFiles \ - profile_exec.vcd t_pgo_threads +TEST_SNAP_IGNORE := \ + *.status *.log *.dat *.d *.o *.a *.so *stats*.txt *.html \ + *.includecache *.out *.fst *.fst.vcd *.tree *.tree*.json \ + *.dot *.csv *.xml *.hash *.cmake gmon.out.* CMakeFiles \ + profile_exec.vcd t_pgo_threads define TEST_SNAP_template mkdir -p $(TEST_SNAP_DIR)