From c0a365bd34a840753ef248e6e7eaa6c35928fd81 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 18 Mar 2008 20:26:37 +0000 Subject: [PATCH] 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 --- Changes | 3 +++ Makefile.in | 22 +++++++++++++++++----- bin/verilator | 15 ++++++++++----- configure.ac | 4 ++++ readme.texi | 6 ++++++ src/Makefile_obj.in | 21 +++++++++++++++++++++ src/V3Options.cpp | 20 ++++++++++++++++++++ src/V3Options.h | 3 +++ src/config_build.h.in | 20 ++++++++++++++++++++ test_regress/driver.pl | 9 +++++++-- test_regress/t/t_help.pl | 20 ++++++++++++++++++++ 11 files changed, 131 insertions(+), 12 deletions(-) create mode 100755 test_regress/t/t_help.pl diff --git a/Changes b/Changes index 48a50fe42..755208d3f 100644 --- a/Changes +++ b/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] diff --git a/Makefile.in b/Makefile.in index 143b408ce..7e53496d1 100644 --- a/Makefile.in +++ b/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 \ diff --git a/bin/verilator b/bin/verilator index 2b1bf5349..9a4317a84 100755 --- a/bin/verilator +++ b/bin/verilator @@ -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 diff --git a/configure.ac b/configure.ac index d15b6186d..fad5d1279 100644 --- a/configure.ac +++ b/configure.ac @@ -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++ diff --git a/readme.texi b/readme.texi index 4d96ebb01..8a89d5ca4 100644 --- a/readme.texi +++ b/readme.texi @@ -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. diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index a328d5913..abe5a1382 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -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 diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 737f5d60a..c30fb50e9 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -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="< #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 diff --git a/test_regress/driver.pl b/test_regress/driver.pl index 852c2eec8..d3219c408 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -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; diff --git a/test_regress/t/t_help.pl b/test_regress/t/t_help.pl new file mode 100755 index 000000000..24b50096e --- /dev/null +++ b/test_regress/t/t_help.pl @@ -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;