Linux HOWTOs

About | Home | Search


HOWTO: bison
Description: Parser generator (yacc replacement)
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GNU Bison 3.0.4
# ===============
# Slackware 13.37: bison 2.4.3
# Slackware 14.0: bison 2.5.1
# Slackware 14.1: bison 2.7
# Slackware 14.2: bison 3.0.4

# Prerequisites:
# flex
# m4 >= 1.4.6
# Perl
# xsltproc
# valgrind (optional)
# gcj Java compiler and/or gij virtual machine (part of Slackware's gcc-java package)
# help2man

# If the download site URL below is not working, try one of these:
# http://ftp.gnu.org/gnu/bison/
# ftp://ftp.gnu.org/gnu/bison/
# http://savannah.gnu.org/projects/bison/

# Get it
cd
test -f installed/bison-3.0.4.tar.xz && mv installed/bison-3.0.4.tar.xz .
test ! -f bison-3.0.4.tar.xz &&
 wget http://ftpmirror.gnu.org/bison/bison-3.0.4.tar.xz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "146be9ff9fbd27497f0bf2286a5a2082  bison-3.0.4.tar.xz" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "aeb1e3544007124009e5203afe86a5676580d444  bison-3.0.4.tar.xz" | \
 sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 78D5264E > /dev/null 2>&1 || gpg --recv-keys 78D5264E ) &&
 wget -nc http://ftpmirror.gnu.org/bison/bison-3.0.4.tar.xz.sig &&
  gpg --verify bison-3.0.4.tar.xz.sig && rm bison-3.0.4.tar.xz.sig

# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "bison-*" -exec rm -r {} \;
tar xJvf ~/bison-3.0.4.tar.xz
cd bison-3.0.4
test $UID = 0 && chown -R root:root .

# Configure the build, 64-bit
test $(uname -m) = "x86_64" &&
./configure --prefix=/usr --infodir=/usr/info --libdir=/usr/lib64 \
--mandir=/usr/man --disable-nls

# Configure the build, anything else
test $(uname -m) != "x86_64" &&
./configure --prefix=/usr --infodir=/usr/info --mandir=/usr/man \
--disable-nls
 
# Build it
make

# Test the build
make check

# Become root to install it
su

# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg bison

# Install the new one
find /usr/share/locale -type f -name "bison.mo" -exec rm {} \;
make install

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Do this if you have Berkeley yacc installed and you want to replace it
# with a script that runs bison in a way that imitates yacc, run this below.
# If you don't have byacc installed, bison will have already installed the
# script for you.
test -x /sbin/removepkg && /sbin/removepkg byacc
echo '#!/bin/sh' > /usr/bin/yacc
echo 'exec /usr/bin/bison -y "$@"' >> /usr/bin/yacc
chown root:root /usr/bin/yacc
chmod 755 /usr/bin/yacc

# Become yourself again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/bison-*.tar.*
mv bison-3.0.4.tar.xz installed/


# If you ever want to uninstall Bison, this should do it:
cd
su
test -d src/bison-* && ( cd src/bison-* ; make uninstall )
( cd /usr/bin ; rm -f bison yacc )
( cd /usr/man/man1 ; rm -f bison.1 yacc.1 )
test -d /usr/share/bison && rm -r /usr/share/bison
( cd /usr/share/man/man1 ; rm -f bison.1 yacc.1 )
rm -f /usr/info/bison.info \
 /usr/lib/liby.* /usr/lib64/liby.* \
 /usr/share/aclocal/bison-i18n.m4 \
 /usr/share/info/bison.info
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "bison-*" -exec rm -r {} \;
rm -f ~/installed/bison-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>