forked from github/verilator
With --enable-defenv, support for hard-coding VERILATOR_ROOT etc in the executables
git-svn-id: file://localhost/svn/verilator/trunk/verilator@998 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
parent
45940ff820
commit
c0a365bd34
3
Changes
3
Changes
@ -5,6 +5,9 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||
|
||||
* Verilator 3.65****
|
||||
|
||||
*** Add support for hard-coding VERILATOR_ROOT etc in the executables,
|
||||
to enable easier use of Verilator RPMs. [Gunter Dannoritzer]
|
||||
|
||||
**** Fix genvar to be signed, so "< 0" works properly. [Niranjan Prabhu]
|
||||
|
||||
**** Fix assignments to inputs inside functions/tasks. [Patricio Kaplan]
|
||||
|
22
Makefile.in
22
Makefile.in
@ -78,6 +78,7 @@ datadir = @datadir@
|
||||
infodir = @infodir@
|
||||
|
||||
# Directory in which to install package specific files
|
||||
# Generally ${prefix}/share/verilator
|
||||
pkgdatadir = @pkgdatadir@
|
||||
|
||||
#### End of system configuration section. ####
|
||||
@ -203,21 +204,31 @@ README: readme.texi
|
||||
$(MAKEINFO) -I$(srcdir) $(srcdir)/readme.texi --output=$@ \
|
||||
--no-headers --no-validate
|
||||
|
||||
installdirs:
|
||||
$(SHELL) ${srcdir}/mkinstalldirs $(bindir) $(infodir)
|
||||
|
||||
# See uninstall also
|
||||
VL_INST_BIN_FILES = verilator
|
||||
VL_INST_BIN_FILES = verilator verilator_bin verilator_bin_dbg
|
||||
installbin:
|
||||
$(SHELL) ${srcdir}/mkinstalldirs $(bindir)
|
||||
( cd bin ; $(INSTALL_PROGRAM) verilator $(bindir)/verilator )
|
||||
( $(INSTALL_PROGRAM) verilator_bin $(bindir)/verilator_bin )
|
||||
( $(INSTALL_PROGRAM) verilator_bin_dbg $(bindir)/verilator_bin_dbg )
|
||||
|
||||
VL_INST_MAN_FILES = verilator.1
|
||||
installman:
|
||||
$(SHELL) ${srcdir}/mkinstalldirs $(mandir)
|
||||
for p in $(VL_INST_MAN_FILES) ; do \
|
||||
$(INSTALL_PROGRAM) $$p $(mandir)/man1/$$p; \
|
||||
done
|
||||
|
||||
install: all_nomsg installdirs installbin installman install-msg
|
||||
installdata:
|
||||
$(SHELL) ${srcdir}/mkinstalldirs $(pkgdatadir)/examples
|
||||
cp -r include $(pkgdatadir)
|
||||
cp -r src $(pkgdatadir)
|
||||
cp -r test_c $(pkgdatadir)/examples
|
||||
cp -r test_sc $(pkgdatadir)/examples
|
||||
cp -r test_sp $(pkgdatadir)/examples
|
||||
|
||||
VL_INST_DATA_FILES = verilator.1
|
||||
install: all_nomsg installbin installman installdata install-msg
|
||||
|
||||
install-here: installman ftp
|
||||
|
||||
@ -263,6 +274,7 @@ install-msg:
|
||||
uninstall:
|
||||
-cd $(mandir)/man1 && rm -f $(VL_INST_MAN_FILES)
|
||||
-cd $(bindir) && rm -f $(VL_INST_BIN_FILES)
|
||||
-rm -f $(pkgdatadir)
|
||||
|
||||
# autoheader might not change config_build.h.in, so touch a stamp file.
|
||||
IN_WILD := ${srcdir}/*.in ${srcdir}/*/*.in ${srcdir}/*/*/*.in \
|
||||
|
@ -84,7 +84,6 @@ run ($vcmd);
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
sub usage {
|
||||
bin_version();
|
||||
print '$Revision$$Date$ ', "\n";
|
||||
pod2usage(-exitstatus=>2, -verbose=>2);
|
||||
}
|
||||
@ -828,14 +827,16 @@ After running Make, the C++ compiler should produce the following:
|
||||
|
||||
Required for SystemC output mode. If set, specifies the directory
|
||||
containing the SystemC distribution. This is used to find the SystemC
|
||||
include files.
|
||||
include files. If not specified, it will come from a default optionally
|
||||
specified at configure time (before Verilator was compiled).
|
||||
|
||||
=item SYSTEMC_ARCH
|
||||
|
||||
Specifies the architecture name used by the SystemC kit. This is the part
|
||||
after the dash in the lib-{...} directory name created by a 'make' in the
|
||||
SystemC distribution. If not set, Verilator will try to intuit the proper
|
||||
setting.
|
||||
setting, or use the default optionally specified at configure time (before
|
||||
Verilator was compiled). .
|
||||
|
||||
=item SYSTEMC_CXX_FLAGS
|
||||
|
||||
@ -845,7 +846,9 @@ building the SystemC model.
|
||||
=item SYSTEMPERL
|
||||
|
||||
Specifies the directory containing the Verilog-Perl distribution kit. This
|
||||
is used to find the Verilog-Perl library and include files.
|
||||
is used to find the Verilog-Perl library and include files. If not
|
||||
specified, it will come from a default optionally specified at configure
|
||||
time (before Verilator was compiled).
|
||||
|
||||
=item VCS_HOME
|
||||
|
||||
@ -861,7 +864,9 @@ for debugging and selecting between multiple operating system builds.
|
||||
=item VERILATOR_ROOT
|
||||
|
||||
Specifies the directory containing the distribution kit. This is used to
|
||||
find the executable, Perl library, and include files.
|
||||
find the executable, Perl library, and include files. If not specified, it
|
||||
will come from a default optionally specified at configure time (before
|
||||
Verilator was compiled).
|
||||
|
||||
=back
|
||||
|
||||
|
@ -9,6 +9,10 @@ AC_INIT(src/Verilator.cpp)
|
||||
AC_CONFIG_HEADER(src/config_build.h)
|
||||
|
||||
dnl Special Substitutions
|
||||
AC_ARG_ENABLE(defenv,
|
||||
[AS_HELP_STRING([--enable-defenv], [hardcode default environment variables])],
|
||||
CFG_WITH_DEFENV=1,)
|
||||
AC_SUBST(CFG_WITH_DEFENV)
|
||||
|
||||
dnl Checks for programs.
|
||||
CXX=g++
|
||||
|
@ -126,6 +126,12 @@ do a @code{make sc_patch}.
|
||||
@item
|
||||
Type @samp{./configure} to configure Verilator for your system.
|
||||
|
||||
If you are configuring Verilator to be part of a RPM or other
|
||||
distribution package system, you may want to use the --enable-defenv
|
||||
configure flag. This will take the current value of VERILATOR_ROOT,
|
||||
SYSTEMC, SYSTEMC_ARCH, and SYSTEMPERL and build them as defaults into
|
||||
the executable.
|
||||
|
||||
@item
|
||||
Type @samp{make} to compile Verilator.
|
||||
|
||||
|
@ -30,6 +30,14 @@ LINK = @CXX@
|
||||
|
||||
LDFLAGS += @LDFLAGS@
|
||||
|
||||
CFG_WITH_DEFENV = @CFG_WITH_DEFENV@
|
||||
|
||||
prefix = @prefix@
|
||||
|
||||
# Directory in which to install package specific files
|
||||
# Generally ${prefix}/share/verilator
|
||||
pkgdatadir = @pkgdatadir@
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
VPATH += . $(srcdir)
|
||||
@ -70,6 +78,19 @@ CPPFLAGS += -W -Wall -Wno-unused-parameter -Wno-char-subscripts -Werror
|
||||
#CPPFLAGS += -pedantic-errors
|
||||
endif
|
||||
|
||||
# Allow RPM builds to specify hardcoded data directories
|
||||
# To do this:
|
||||
ifneq ($(CFG_WITH_DEFENV),)
|
||||
CPPFLAGS += -DDEFENV_SYSTEMC=\"$(SYSTEMC)\"
|
||||
CPPFLAGS += -DDEFENV_SYSTEMC_ARCH=\"$(SYSTEMC_ARCH)\"
|
||||
CPPFLAGS += -DDEFENV_SYSTEMPERL=\"$(SYSTEMPERL)\"
|
||||
ifeq ($(VERILATOR_ROOT),) # Use what we're given, or intuit
|
||||
CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(pkgdatadir)\"
|
||||
else
|
||||
CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(VERILATOR_ROOT)\"
|
||||
endif
|
||||
endif
|
||||
|
||||
HEADERS = $(wildcard V*.h v*.h)
|
||||
|
||||
ASTGEN = $(srcdir)/astgen
|
||||
|
@ -261,6 +261,11 @@ string V3Options::getenvStr(const char* envvar, const char* defaultValue) {
|
||||
}
|
||||
string V3Options::getenvSYSTEMC() {
|
||||
string var = getenvStr("SYSTEMC","");
|
||||
if (var == "" && string(DEFENV_SYSTEMC) != "") {
|
||||
var = DEFENV_SYSTEMC;
|
||||
UINFO(1,"export SYSTEMC="<<var<<" # Hardcoded at build time"<<endl);
|
||||
setenv("SYSTEMC", var.c_str(), false);
|
||||
}
|
||||
// Only correct or check it if we really need the value
|
||||
if ((v3Global.opt.systemPerl() || v3Global.opt.systemC())
|
||||
&& !v3Global.opt.lintOnly()) {
|
||||
@ -273,6 +278,11 @@ string V3Options::getenvSYSTEMC() {
|
||||
}
|
||||
string V3Options::getenvSYSTEMC_ARCH() {
|
||||
string var = getenvStr("SYSTEMC_ARCH","");
|
||||
if (var == "" && string(DEFENV_SYSTEMC_ARCH) != "") {
|
||||
var = DEFENV_SYSTEMC_ARCH;
|
||||
UINFO(1,"export SYSTEMC_ARCH="<<var<<" # Hardcoded at build time"<<endl);
|
||||
setenv("SYSTEMC_ARCH", var.c_str(), false);
|
||||
}
|
||||
if (var == "") {
|
||||
struct utsname uts;
|
||||
uname(&uts);
|
||||
@ -287,6 +297,11 @@ string V3Options::getenvSYSTEMC_ARCH() {
|
||||
}
|
||||
string V3Options::getenvSYSTEMPERL() {
|
||||
string var = getenvStr("SYSTEMPERL","");
|
||||
if (var == "" && string(DEFENV_SYSTEMPERL) != "") {
|
||||
var = DEFENV_SYSTEMPERL;
|
||||
UINFO(1,"export SYSTEMPERL="<<var<<" # Hardcoded at build time"<<endl);
|
||||
setenv("SYSTEMC_PERL", var.c_str(), false);
|
||||
}
|
||||
// Only correct or check it if we really need the value
|
||||
if ((v3Global.opt.systemPerl() || v3Global.opt.trace()) && !v3Global.opt.lintOnly()) {
|
||||
if (var == "") {
|
||||
@ -310,6 +325,11 @@ string V3Options::getenvSYSTEMPERL() {
|
||||
}
|
||||
string V3Options::getenvVERILATOR_ROOT() {
|
||||
string var = getenvStr("VERILATOR_ROOT","");
|
||||
if (var == "" && string(DEFENV_VERILATOR_ROOT) != "") {
|
||||
var = DEFENV_VERILATOR_ROOT;
|
||||
UINFO(1,"export VERILATOR_ROOT="<<var<<" # Hardcoded at build time"<<endl);
|
||||
setenv("VERILATOR_ROOT", var.c_str(), false);
|
||||
}
|
||||
if (var == "") {
|
||||
v3fatal("$VERILATOR_ROOT needs to be in environment\n");
|
||||
}
|
||||
|
@ -217,6 +217,9 @@ class V3Options {
|
||||
static string filenameDir (const string& filename); ///< Return directory part of filename
|
||||
static void unlinkRegexp(const string& dir, const string& regexp);
|
||||
|
||||
// METHODS (environment)
|
||||
// Most of these may be built into the executable with --enable-defenv,
|
||||
// see the README. If adding new variables, also see src/Makefile_obj.in
|
||||
static string getenvPERL() { return getenvStr("PERL","perl"); }
|
||||
static string getenvSYSTEMC();
|
||||
static string getenvSYSTEMC_ARCH();
|
||||
|
@ -57,6 +57,26 @@
|
||||
// Set define if we have header: <inttypes.h>
|
||||
#define HAVE_INTTYPES_H 0
|
||||
|
||||
//**********************************************************************
|
||||
//**** Default environment
|
||||
|
||||
// Set defines to defaults for environment variables
|
||||
// If set to "", this default is ignored and the user is expected
|
||||
// to set them at Verilator runtime.
|
||||
|
||||
#ifndef DEFENV_SYSTEMC
|
||||
# define DEFENV_SYSTEMC ""
|
||||
#endif
|
||||
#ifndef DEFENV_SYSTEMC_ARCH
|
||||
# define DEFENV_SYSTEMC_ARCH ""
|
||||
#endif
|
||||
#ifndef DEFENV_SYSTEMPERL
|
||||
# define DEFENV_SYSTEMPERL ""
|
||||
#endif
|
||||
#ifndef DEFENV_VERILATOR_ROOT
|
||||
# define DEFENV_VERILATOR_ROOT ""
|
||||
#endif
|
||||
|
||||
//**********************************************************************
|
||||
//**** Compile options
|
||||
|
||||
|
@ -443,7 +443,8 @@ sub sc_or_sp {
|
||||
|
||||
sub _run {
|
||||
my $self = (ref $_[0]? shift : $Last_Self);
|
||||
my %param = (@_);
|
||||
my %param = (tee=>1,
|
||||
@_);
|
||||
my $command = join(' ',@{$param{cmd}});
|
||||
print "\t$command\n";
|
||||
|
||||
@ -451,7 +452,11 @@ sub _run {
|
||||
open(SAVEOUT, ">&STDOUT") or die "%Error: Can't dup stdout";
|
||||
open(SAVEERR, ">&STDERR") or die "%Error: Can't dup stderr";
|
||||
if (0) {close(SAVEOUT); close(SAVEERR);} # Prevent unused warning
|
||||
open(STDOUT, "|tee $param{logfile}") or die "%Error: Can't redirect stdout";
|
||||
if ($param{tee}) {
|
||||
open(STDOUT, "|tee $param{logfile}") or die "%Error: Can't redirect stdout";
|
||||
} else {
|
||||
open(STDOUT, ">$param{logfile}") or die "%Error: Can't open $param{logfile}";
|
||||
}
|
||||
open(STDERR, ">&STDOUT") or die "%Error: Can't dup stdout";
|
||||
autoflush STDOUT 1;
|
||||
autoflush STDERR 1;
|
||||
|
20
test_regress/t/t_help.pl
Executable file
20
test_regress/t/t_help.pl
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/perl
|
||||
if (!$::Driver) { use FindBin; exec("./driver.pl", @ARGV, $0); die; }
|
||||
# $Id$
|
||||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||
#
|
||||
# Copyright 2003-2007 by Wilson Snyder. This program is free software; you can
|
||||
# redistribute it and/or modify it under the terms of either the GNU
|
||||
# General Public License or the Perl Artistic License.
|
||||
|
||||
$Last_Self->_run(fails=>1,
|
||||
cmd=>["perl","../bin/verilator",
|
||||
"--help"],
|
||||
logfile=>"obj_dir/t_help.log",
|
||||
tee=>0,
|
||||
) if $Last_Self->{v3};
|
||||
|
||||
file_grep ("obj_dir/t_help.log", qr/DISTRIBUTION/i);
|
||||
|
||||
ok(1);
|
||||
1;
|
Loading…
Reference in New Issue
Block a user