Skip to content

Commit

Permalink
Install public executables into bindir instead of pkgdatadir
Browse files Browse the repository at this point in the history
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 verilator#5140
  • Loading branch information
gezalore committed Oct 17, 2024
1 parent 0dce97b commit f352800
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
12 changes: 8 additions & 4 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion bin/verilator
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
20 changes: 8 additions & 12 deletions test_regress/t/t_flag_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit f352800

Please sign in to comment.