From f352800941f596e7bca29ada259591da4b8455ab Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Thu, 17 Oct 2024 11:23:57 +0100 Subject: [PATCH] Install public executables into bindir instead of pkgdatadir Instead of installing redirect scripts in to bindir, and real executables in to pkgdatadir/bin, we now put the real executables into bindir, and add redirect scripts into pkgdatadir/bin. (That is, we redirect in the opposite direction as before). This enables the same relocatable and testable installations as before without putting architecture specific binaries into pkgdatadir, so hopefully we now conform to the Linux Filesystem Hierarchy Standard. This requires a small fixup in the installed `verilator` script to hardcode the relative path between bindir and pkgdatadir. Fixes #5140 --- Makefile.in | 12 ++++++++---- bin/verilator | 4 +++- test_regress/t/t_flag_help.py | 20 ++++++++------------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1a90b46ab7..8002d77fbc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -266,11 +266,15 @@ mkbindirs: installbin: | mkbindirs cd $(srcdir)/bin; \ for p in $(VL_INST_PUBLIC_SCRIPT_FILES) ; do \ - $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkgdatadir)/bin/$$p; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p; \ done + perl -p -i -e 'use File::Spec;' \ + -e' $$path = File::Spec->abs2rel("$(realpath $(DESTDIR)$(pkgdatadir))", "$(realpath $(DESTDIR)$(bindir))");' \ + -e 's/my \$$verilator_pkdatadir_relpath = .*/my \$$verilator_pkdatadir_relpath = "$$path";/g' \ + -- "$(DESTDIR)/$(bindir)/verilator" cd bin; \ for p in $(VL_INST_PUBLIC_BIN_FILES) ; do \ - $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkgdatadir)/bin/$$p; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p; \ done cd $(srcdir)/bin; \ for p in $(VL_INST_PRIVATE_SCRIPT_FILES) ; do \ @@ -280,11 +284,11 @@ installbin: | mkbindirs installredirect: installbin | mkbindirs cp ${srcdir}/bin/redirect ${srcdir}/bin/redirect.tmp perl -p -i -e 'use File::Spec;' \ - -e' $$path = File::Spec->abs2rel("$(realpath $(DESTDIR)$(pkgdatadir)/bin)", "$(realpath $(DESTDIR)$(bindir))");' \ + -e' $$path = File::Spec->abs2rel("$(realpath $(DESTDIR)$(bindir))", "$(realpath $(DESTDIR)$(pkgdatadir)/bin)");' \ -e 's/RELPATH.*/"$$path";/g' -- "${srcdir}/bin/redirect.tmp" cd $(srcdir)/bin; \ for p in $(VL_INST_PUBLIC_SCRIPT_FILES) $(VL_INST_PUBLIC_BIN_FILES) ; do \ - $(INSTALL_PROGRAM) redirect.tmp $(DESTDIR)$(bindir)/$$p; \ + $(INSTALL_PROGRAM) redirect.tmp $(DESTDIR)$(pkgdatadir)/bin/$$p; \ done rm ${srcdir}/bin/redirect.tmp diff --git a/bin/verilator b/bin/verilator index d25f6e5258..8b4f2045ed 100755 --- a/bin/verilator +++ b/bin/verilator @@ -69,7 +69,9 @@ if (! GetOptions( pod2usage(-exitstatus => 2, -verbose => 0); } -my $verilator_root = realpath("$RealBin/.."); +# WARNING: $verilator_pkdatadir_relpath is substituted during Verilator 'make install' +my $verilator_pkdatadir_relpath = ".."; +my $verilator_root = realpath("$RealBin/$verilator_pkdatadir_relpath"); if (defined $ENV{VERILATOR_ROOT}) { if ((!-d $ENV{VERILATOR_ROOT}) || $verilator_root ne realpath($ENV{VERILATOR_ROOT})) { warn "%Error: verilator: VERILATOR_ROOT is set to inconsistent path. Suggest leaving it unset.\n"; diff --git a/test_regress/t/t_flag_help.py b/test_regress/t/t_flag_help.py index d9ec36e3c6..262ed934fb 100755 --- a/test_regress/t/t_flag_help.py +++ b/test_regress/t/t_flag_help.py @@ -14,26 +14,22 @@ # See also t_flag_version.py -def check(interpreter, prog): +def check(prog): logfile = test.obj_dir + "/t_help__" + os.path.basename(prog) + ".log" - test.run(fails=False, - cmd=[interpreter, prog, "--help"], - logfile=logfile, - tee=False, - verilator_run=True) + test.run(fails=False, cmd=[prog, "--help"], logfile=logfile, tee=False, verilator_run=True) test.file_grep(logfile, r'(DISTRIBUTION|usage:)') -check("perl", os.environ["VERILATOR_ROOT"] + "/bin/verilator") -check("perl", os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage") +check(os.environ["VERILATOR_ROOT"] + "/bin/verilator") +check(os.environ["VERILATOR_ROOT"] + "/bin/verilator_coverage") -check("python3", os.environ["VERILATOR_ROOT"] + "/bin/verilator_ccache_report") -check("python3", os.environ["VERILATOR_ROOT"] + "/bin/verilator_gantt") -check("python3", os.environ["VERILATOR_ROOT"] + "/bin/verilator_profcfunc") +check(os.environ["VERILATOR_ROOT"] + "/bin/verilator_ccache_report") +check(os.environ["VERILATOR_ROOT"] + "/bin/verilator_gantt") +check(os.environ["VERILATOR_ROOT"] + "/bin/verilator_profcfunc") if os.path.exists(os.environ["VERILATOR_ROOT"] + "/bin/verilator_difftree"): - check("python3", os.environ["VERILATOR_ROOT"] + "/bin/verilator_difftree") + check(os.environ["VERILATOR_ROOT"] + "/bin/verilator_difftree") test.passes()