Fix running configure outside of kit, and update README, bug193

This commit is contained in:
Wilson Snyder 2009-11-25 17:20:28 -05:00
parent 955824e634
commit 5a502d451d
4 changed files with 199 additions and 26 deletions

View File

@ -243,26 +243,27 @@ VL_INST_BIN_FILES = verilator verilator_bin verilator_bin_dbg \
# so they can be found by the user, and under $VERILATOR_ROOT. # so they can be found by the user, and under $VERILATOR_ROOT.
installbin: installbin:
$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(bindir) $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(bindir)
( cd bin ; $(INSTALL_PROGRAM) verilator $(DESTDIR)$(bindir)/verilator ) ( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator $(DESTDIR)$(bindir)/verilator )
( cd bin ; $(INSTALL_PROGRAM) verilator_profcfunc $(DESTDIR)$(bindir)/verilator_profcfunc ) ( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_profcfunc $(DESTDIR)$(bindir)/verilator_profcfunc )
( $(INSTALL_PROGRAM) verilator_bin $(DESTDIR)$(bindir)/verilator_bin ) ( $(INSTALL_PROGRAM) verilator_bin $(DESTDIR)$(bindir)/verilator_bin )
( $(INSTALL_PROGRAM) verilator_bin_dbg $(DESTDIR)$(bindir)/verilator_bin_dbg ) ( $(INSTALL_PROGRAM) verilator_bin_dbg $(DESTDIR)$(bindir)/verilator_bin_dbg )
$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(pkgdatadir)/bin $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(pkgdatadir)/bin
( cd bin ; $(INSTALL_PROGRAM) verilator_includer $(DESTDIR)$(pkgdatadir)/bin/verilator_includer ) ( cd ${srcdir}/bin ; $(INSTALL_PROGRAM) verilator_includer $(DESTDIR)$(pkgdatadir)/bin/verilator_includer )
installman: installman: $(VL_INST_MAN_FILES)
$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(mandir)/man1 $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(mandir)/man1
for p in $(VL_INST_MAN_FILES) ; do \ for p in $(VL_INST_MAN_FILES) ; do \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(mandir)/man1/$$p; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(mandir)/man1/$$p; \
done done
installdata: installdata:
$(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(pkgdatadir)/examples $(SHELL) ${srcdir}/mkinstalldirs $(DESTDIR)$(pkgdatadir)/include $(DESTDIR)$(pkgdatadir)/examples
cp -r include $(DESTDIR)$(pkgdatadir) cp -r include/* $(DESTDIR)$(pkgdatadir)/include
cp -r test_c $(DESTDIR)$(pkgdatadir)/examples cp -r ${srcdir}/include/* $(DESTDIR)$(pkgdatadir)/include
cp -r test_sc $(DESTDIR)$(pkgdatadir)/examples cp -r ${srcdir}/test_c $(DESTDIR)$(pkgdatadir)/examples
cp -r test_sp $(DESTDIR)$(pkgdatadir)/examples cp -r ${srcdir}/test_sc $(DESTDIR)$(pkgdatadir)/examples
cp -r test_v $(DESTDIR)$(pkgdatadir)/examples cp -r ${srcdir}/test_sp $(DESTDIR)$(pkgdatadir)/examples
cp -r ${srcdir}/test_v $(DESTDIR)$(pkgdatadir)/examples
VL_INST_DATA_FILES = verilator.1 VL_INST_DATA_FILES = verilator.1
install: all_nomsg installbin installman installdata install-msg install: all_nomsg installbin installman installdata install-msg
@ -373,7 +374,7 @@ dist-file-list:
###################################################################### ######################################################################
# Distributions # Distributions
DISTCONFIG = src/config_build.h.in DISTCONFIG = ${srcdir}/src/config_build.h.in
DISTTITLE := $(shell sed -e '/DTVERSION/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e 's/v/V/' -e q $(DISTCONFIG)) DISTTITLE := $(shell sed -e '/DTVERSION/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e 's/v/V/' -e q $(DISTCONFIG))
DISTNAME := $(shell sed -e '/DTVERSION/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e q $(DISTCONFIG)) DISTNAME := $(shell sed -e '/DTVERSION/!d' -e 's/[^0-9]*\([0-9.a-z]*\).*/verilator-\1/' -e q $(DISTCONFIG))

136
nodist/install_test Executable file
View File

@ -0,0 +1,136 @@
#!/usr/bin/perl -w
# See copyright, etc in below POD section.
######################################################################
use Getopt::Long;
use Cwd;
use IO::File;
use Pod::Usage;
use strict;
use vars qw ($Debug);
#======================================================================
# main
autoflush STDOUT 1;
autoflush STDERR 1;
Getopt::Long::config ("no_auto_abbrev");
if (! GetOptions (
"debug" => sub { $Debug = 1; },
"<>" => sub { die "%Error: Unknown parameter: $_[0]\n"; },
)) {
die "%Error: Bad usage, try 'install_test --help'\n";
}
test();
#######################################################################
sub test {
-r "nodist/install_test" or die "%Error: Run from the top of the verilator kit,";
cleanenv();
$ENV{VERILATOR_NO_OPT_BUILD} = 1; # Don't build optimized executables; just slows this down
run("make distclean") if -r "Makefile";
# Try building from a scratch area
my $srcdir = getcwd();
my $blddir = $srcdir."/test_regress/obj_dir/install_test_bld";
my $prefix = $srcdir."/test_regress/obj_dir/install_test_prefix";
my $testdir = $srcdir."/test_regress/obj_dir/install_test_test";
if (1) {
run("/bin/rm -rf $blddir");
run("/bin/mkdir -p $blddir");
run("cd $blddir && $srcdir/configure --prefix $prefix");
run("cd $blddir && make -j");
}
# Install it under the prefix
if (1) {
run("/bin/rm -rf $prefix");
run("/bin/mkdir -p $prefix");
run("cd $blddir && make install");
}
# Run a test using just the path
if (1) {
run("/bin/rm -rf $testdir");
run("/bin/mkdir -p $testdir");
my $bin1 = $prefix."/bin";
my $bin2 = $prefix."/share/bin";
IO::File->new(">$testdir/foo.v")->print('module t; initial begin $display("HELLO WORLD"); end endmodule'."\n");
run("cd $testdir && PATH=$bin1:$bin2:\$PATH verilator --cc --exe foo.v");
run("cd $testdir/obj_dir && PATH=$bin1:$bin2:\$PATH make -f Vfoo.mk");
#Need .c file for this to work
#run("cd $testdir && PATH=$bin1:$bin2:\$PATH obj_dir/Vfoo");
}
}
sub cleanenv {
foreach my $var (keys %ENV) {
if ($var eq "VERILATOR_ROOT") {
print "unset $var # Was '$ENV{$var}'\n";
delete $ENV{$var}
}
}
}
#######################################################################
sub run {
# Run a system command, check errors
my $command = shift;
print "\t$command\n";
system "$command";
my $status = $?;
($status == 0) or die "%Error: Command Failed $command, $status, stopped";
}
#######################################################################
__END__
=pod
=head1 NAME
install_test - Build and install Verilator several ways
=head1 SYNOPSIS
install_test
=head1 DESCRIPTION
install_test performs several make-and-install iterations to verify the
kit. It isn't part of the normal "make test" due to the number of builds
required.
=head1 ARGUMENTS
=over 4
=item --help
Displays this message and program version and exits.
=back
=head1 DISTRIBUTION
Copyright 2009-2009 by Wilson Snyder. This package is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License Version 3 or the Perl Artistic License
Version 2.0.
=head1 AUTHORS
Wilson Snyder <wsnyder@wsnyder.org>
=head1 SEE ALSO
=cut
######################################################################
### Local Variables:
### compile-command: "cd .. ; nodist/install_test "
### End:

View File

@ -95,13 +95,34 @@ C<cd> to the Verilator directory containing this README.
=item =item
Type C<./configure> to configure Verilator for your system. You now have to decide how you're going to eventually install the kit.
If you are configuring Verilator to be part of a RPM or other distribution Our personal favorite is to always run Verilator from the kit directory.
package system, you may want to use the --enable-defenv configure flag. This allows the easiest experimentation and upgrading. It's also how most
This will take the current value of VERILATOR_ROOT, SYSTEMC, SYSTEMC_ARCH, EDA tools operate; you just point to the tarball.
SYSTEMPERL, and SYSTEMPERL_INCLUDE and build them as defaults into the
executable. export VERILATOR_ROOT=`pwd` # if your shell is bash
setenv VERILATOR_ROOT `pwd` # if your shell is csh
./configure
The next option is to install it globally, using the normal system paths:
unset VERILATOR_ROOT # if your shell is bash
unsetenv VERILATOR_ROOT # if your shell is csh
./configure
Alternatively you can configure a prefix that install will populate, as
most GNU tools support:
unset VERILATOR_ROOT # if your shell is bash
unsetenv VERILATOR_ROOT # if your shell is csh
./configure --prefix /opt/verilator-VERSION
Finally, if you are configuring Verilator to be part of a RPM or other
distribution package system, you may want to tune the various install
directories and use the --enable-defenv configure flag. This will take the
current value of VERILATOR_ROOT, SYSTEMC, SYSTEMC_ARCH, SYSTEMPERL, and
SYSTEMPERL_INCLUDE and build them as defaults into the executable.
=item =item
@ -119,11 +140,12 @@ unsigned long uint32_t;}.
=item =item
There is no installation at present; this package runs from the If you used the VERILATOR_ROOT sheme you're done. Programs should set the
distribution directory. Programs should set the environment variable environment variable VERILATOR_ROOT to point to this distribution, then
VERILATOR_ROOT to point to this distribution, then execute execute $VERILATOR_ROOT/bin/verilator, which will find the path to all
$VERILATOR_ROOT/bin/verilator, which will find the path to all needed needed files.
files.
If you used the prefix scheme, now do a C<make install>.
Verilator assumes you did a make in the SystemC kit directory. If not, you Verilator assumes you did a make in the SystemC kit directory. If not, you
will need to populate C<$SYSTEMC/include> and C<$SYSTEMC/lib-linux> will need to populate C<$SYSTEMC/include> and C<$SYSTEMC/lib-linux>

View File

@ -21,8 +21,22 @@
#### Start of system configuration section. #### #### Start of system configuration section. ####
srcdir = .. # Unfortunately configure uses relative paths, and this makefile is called
incdir = ../../include # from a level lower, so we need to move up if it's relative, not if absolute.
config_srcdir = @srcdir@
ifeq ($(config_srcdir),.)
srcdir = ..
else # Run an experiment
ifeq ($(shell -e $(config_srcdir)/../Makefile_obj.in),)
srcdir = $(config_srcdir)
else
srcdir = $(config_srcdir)/..
endif
endif
incdir = $(srcdir)/../include
# Bldsrc may differ from srcdir if configure wan't run from the kit top
bldsrc = ..
# Programs # Programs
CC = @CC@ CC = @CC@
@ -49,7 +63,7 @@ LDFLAGS += @LDFLAGS@
#### End of system configuration section. #### #### End of system configuration section. ####
VPATH += . $(srcdir) VPATH += . $(bldsrc) $(srcdir)
TGT = ../../verilator_bin TGT = ../../verilator_bin
################# #################
@ -71,7 +85,7 @@ endif
LIBS = -lm -lfl LIBS = -lm -lfl
CPPFLAGSNOWALL += -MMD CPPFLAGSNOWALL += -MMD
CPPFLAGSNOWALL += -I. -I$(srcdir) -I$(incdir) CPPFLAGSNOWALL += -I. -I$(bldsrc) -I$(srcdir) -I$(incdir)
CPPFLAGSNOWALL += -DYYDEBUG # Required to get nice error messages CPPFLAGSNOWALL += -DYYDEBUG # Required to get nice error messages
#CPPFLAGSNOWALL += -DVL_LEAK_CHECKS # If running valgrind or other hunting tool #CPPFLAGSNOWALL += -DVL_LEAK_CHECKS # If running valgrind or other hunting tool
CPPFLAGSNOWALL += $(COPT) CPPFLAGSNOWALL += $(COPT)