Building GHDL on FreeBSD-9.2
C-shell Alert!
Some commands in this guide specifically use bourne shell syntax (sh, ksh93, pdksh, bash, zsh, etc.). csh users will need to adjust accordingly.
Convention:
The root prompt is indicated by #
A system user prompt is indicated by $Warning!
Pay close attention to the prompt! For this procedure to go smoothly, some operations must to be performed by the root user and others should be performed with your regular system user account.
The gcc-aux compiler will be used to compile the gcc-4.8.2/ghdl-0.31 source.
# cd /usr/ports/lang/gcc-aux/ # make install clean
Note:
The dialog4ports system will prompt the user several times with configuration options for the compiler and its dependencies. Minimally, ADA and CXX must be selected for gcc-aux.
- ADA - Build Ada language
- CXX - Build C++ language
STATIC and NLS were also selected on the test system.
- STATIC - Build with no shared libraries other than libc
- NLS - Native language support
wget is a computer program that retrieves content from web servers. It will be used to fetch the GHDL source files.
# cd /usr/ports/ftp/wget # make install clean
mercurial is a distributed revision control tool for software developers. The ghdl-updates project uses mercurial to track changes to the ghdl source code.
# cd /usr/ports/devel/mercurial # make install clean
For the convenience of scripting and having a common reference, this directory structure is used throughout this guide.
$ mkdir $HOME/local $ mkdir -p $HOME/ghdl_build/distfiles $ mkdir -p $HOME/ghdl_build/source
The directory tree just created, if visualized, might look like this:
$HOME ├── local └── ghdl_build ├── distfiles └── source
The gcc-4.8.2 source is accessible through the FreeBSD ports systems. These commands will not build or install gcc-4.8.2, we're only fetching the source.
# cd /usr/ports/lang/gcc48 # make fetch checksum extract patch
Note:
The dialog4ports system will prompt the user with a single option for Java platform support.
- JAVA - Java platform support
This is not needed and can safely be unchecked.
The gcc-4.8.2 source can now be copied into the user's directory where ghdl will be built.
$ cd /usr/ports/lang/gcc48/work/ $ cp -R gcc-4.8-20130808 $HOME/ghdl_build/source/
The ports tree can now be cleaned up a bit.
# cd /usr/ports/lang/gcc48 # make clean
Set a shell variable for the GHDL version you would like to install.
C-shell Alert!
The following export command is specifically bourne shell syntax. csh users will need to adjust accordingly.
$ export GHDL_VER="0.31"
Download and unpack the GHDL source.
$ cd $HOME/ghdl_build/distfiles/ $ wget http://downloads.sourceforge.net/project/ghdl-updates/Source/ghdl-${GHDL_VER}.tar.gz $ mkdir ghdl-${GHDL_VER} $ tar xzf ghdl-${GHDL_VER}.tar.gz -C ghdl-${GHDL_VER}/
Pack the set of ghdl source files that will be compiled together with gcc-4.8.2 to create the ghdl compiler.
$ cd $HOME/ghdl_build/distfiles/ghdl-${GHDL_VER}/translate/gcc/ $ ./dist.sh sources $ mv ghdl-${GHDL_VER}.tar.bz2 $HOME/ghdl_build/distfiles/
Unpack the bundle into the source tree.
$ cd $HOME/ghdl_build/distfiles/ $ tar xjf ghdl-${GHDL_VER}.tar.bz2 -C $HOME/ghdl_build/source/
If visualized, the directory tree should now look like this:
$HOME `-- ghdl_build |-- distfiles | `-- ghdl_${GHDL_VER} `-- source |-- gcc-4.8-20130808 `-- ghdl-${GHDL_VER}
Note:
The distfiles/ghdl_${GHDL_VER} directory and the source/ghdl-${GHDL_VER} are not exactly the same.
The development branch of GHDL can be followed by cloning the repository.
$ cd $HOME/ghdl_build/distfiles/ $ hg clone http://hg.code.sf.net/p/ghdl-updates/code ghdl-updates-code
Your repository can later be updated like this:
$ cd $HOME/ghdl_build/distfiles/ghdl-updates-code/ $ hg pull $ hg update
Pack the set of ghdl source files that will be compiled together with gcc-4.8.2 to create the ghdl compiler.
$ cd $HOME/ghdl_build/distfiles/ghdl-updates-code/translate/gcc/ $ ./dist.sh sources
Set a shell variable for the GHDL version you would like to install.
C-shell Alert!
The following export command is specifically bourne shell syntax. csh users will need to adjust accordingly.
$ export GHDL_VER="0.32dev"
Warning!
Following -current means things will be changing. If GHDL does not seem to compile, try an earlier tag.
$ cd $HOME/ghdl_build/distfiles/ghdl-updates-code/translate/gcc/ $ mv ghdl-${GHDL_VER}.tar.bz2 $HOME/ghdl_build/distfiles/
Unpack the bundle into the source tree.
$ cd $HOME/ghdl_build/distfiles/ $ tar xjf ghdl-${GHDL_VER}.tar.bz2 -C $HOME/ghdl_build/source/
If visualized, the directory tree should look like this:
$HOME `-- ghdl_build |-- distfiles | `-- ghdl-updates-code `-- source |-- gcc-4.8-20130808 `-- ghdl-${GHDL_VER}
The FreeBSD / gcc-aux environment uses the command ada rather than gnatgcc.
$ sed -i .orig 's/gnatgcc/ada/' $HOME/ghdl_build/source/ghdl-${GHDL_VER}/vhdl/Makefile.in
The GHDL source files can now be copied into the gcc tree.
$ cp -R $HOME/ghdl_build/source/ghdl-${GHDL_VER}/vhdl $HOME/ghdl_build/source/gcc-4.8-20130808/gcc/
Create the shell script $HOME/ghdl_build/build_gcc.sh
$ cd $HOME/ghdl_build $ vi build_gcc.sh
Copy and paste this build_gcc.sh script into your editor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #!/bin/sh BASEDIR=$HOME/ghdl_build PREFIX=$HOME/local export CONFIG_SHELL=/bin/sh SOURCEDIR=$BASEDIR/source/gcc-4.8-20130808 BUILD_DIR=$BASEDIR/build if [ -d "$BUILD_DIR" ]; then cd $BUILD_DIR gmake distclean gmake clean else mkdir $BUILD_DIR cd $BUILD_DIR fi $SOURCEDIR/configure --enable-languages=vhdl --enable-libada --enable-checking --prefix=$PREFIX --disable-bootstrap gmake |
Note:
This script will install GHDL into $HOME/local. The value of PREFIX can be set to /usr/local/ghdl if you wish to make GHDL globally available on your system.
Set your $PATH to include the gcc-aux compiler directory and your $HOME/local/bin directory.
C-shell Alert!
The following export command is specifically bourne shell syntax. csh users will need to adjust accordingly.
Note:
It is probably best to modify PATH in your $HOME/.profile file.
$ export PATH=$HOME/local/bin:/usr/local/gcc-aux/bin:$PATH
Compile GHDL.
C-shell Alert!
The following redirection of stderr to stdout to a pipe specifically uses bourne shell syntax. csh users will need to adjust accordingly.
$ chmod u+x $HOME/ghdl_build/build_gcc.sh $ $HOME/ghdl_build/build_gcc.sh 2>&1 | tee $HOME/ghdl_build/build_gcc-${GHDL_VER}.log
[...a lot of build status notifications...]
If there were no errors (there shouldn't have been), the installation can be completed:
$ cd $HOME/ghdl_build/build/ $ gmake install
Note:
If the value of PREFIX was set to /usr/local (rather than $HOME/local) in the build_gcc.sh script, then gmake install should be executed with root privileges.
Congratulations! You should now have a working GHDL compiler installed on your FreeBSD system.