Linux HOWTOs

About | Home | Search


HOWTO: gawk
Description: GNU Awk (gawk) - pattern scanning and processing language
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 awk 4.0.0
# =============
# Slackware 12.1: gawk 3.1.5
# Slackware 12.2, 13.0: gawk 3.1.6
# Slackware 13.1, 13.37: gawk 3.1.8

# If you ever want to uninstall gawk (?!) or want to clean up files from
# old versions before installing a new one, skip down to the bottom for
# instructions.  Do NOT remove the 'awk' binary, you can't run configure
# without it.

# Prerequisites:
# bison
# grep
# gettext

# If the download site used below is busy, try one of these:
# http://mirrors.ibiblio.org/pub/mirrors/gnu/ftp/gnu/gawk/
# http://ftp.gnu.org/gnu/gawk/

cd
test -f installed/gawk-4.0.0.tar.gz && mv installed/gawk-4.0.0.tar.gz .
test ! -f gawk-4.0.0.tar.gz &&
 wget http://ftpmirror.gnu.org/gawk/gawk-4.0.0.tar.gz

# Verify tarball w/ md5sum:
# (this came from my gpg-verified tarball)
echo "51e417b71287629940051e6f652c6492  gawk-4.0.0.tar.gz" | md5sum -c

# Verify tarball w/ sha1sum:
# (this also came from my gpg-verified tarball)
echo "dbf6601a2899669f59ea28dfad36144c5c3d2bbc  gawk-4.0.0.tar.gz" | \
 sha1sum -c

# Verify tarball w/ gpg:
gpg --list-keys D679F6CF > /dev/null 2>&1 ||
 ( wget -nc http://ftpmirror.gnu.org/gnu-keyring.gpg -O - | gpg --import )
wget -nc http://ftpmirror.gnu.org/gawk/gawk-4.0.0.tar.gz.sig &&
 gpg --verify gawk-4.0.0.tar.gz.sig && rm gawk-4.0.0.tar.gz.sig

mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "gawk-*" -exec rm -r {} \;
tar xzvf ~/gawk-4.0.0.tar.gz
cd gawk-4.0.0
test $UID = 0 && chown -R root:root .

# Make sure the correct processor type is specified for -march (i386,
# pentium2, athlon, ... - see 'man gcc') or just leave off the CFLAGS part
CFLAGS="-O2 -march=i686" \
./configure --prefix=/usr --bindir=/bin --infodir=/usr/info \
 --mandir=/usr/man --disable-nls
make

# Become root to install it
su

# Clean up some things before installing the new one to avoid issues
# The new version binaries will end up in /bin, with various symlinks in
# /bin and /usr/bin.  This will leave awk and gawk in /bin.
( cd /usr/bin ; rm -f dgawk gawk igawk pgawk )
find /usr/doc -maxdepth 1 -type d -name "gawk-*" -exec rm -r {} \;
( cd /usr/info ; rm -f gawk.info.gz gawkinet.info.gz )
( cd /usr/man/man1 ; rm -f awk.1.gz gawk.1.gz igawk.1.gz pgawk.1.gz )
find /usr/share/doc -maxdepth 1 -type d -name "gawk-*" -exec rm -r {} \;
find /usr/share/locale -type f -name gawk.mo -exec rm {} \;
( cd /usr/share/man/man1 ; rm -f gawk.1.gz igawk.1.gz pgawk.1.gz )

# If you'd like to create a gawk package for Slackware with checkinstall,
# follow these instructions instead of running 'make install' below

# If you did not create and install a package
make install
ln -sf /bin/awk /usr/bin/awk
ln -sf /bin/dgawk /usr/bin/dgawk
ln -sf /bin/gawk /usr/bin/gawk
ln -sf /bin/igawk /usr/bin/igawk
ln -sf /bin/pgawk /usr/bin/pgawk
ln -sf /usr/man/man1/gawk.1 /usr/man/man1/awk.1

# Be aware that you may have different versions named for their version,
# including this new one: /bin/gawk-3.1.6, /bin/gawk-4.0.0, etc.

# Look through /usr/share/awk for files with an older date/time, those can
# be removed.

# Make sure your non-root user can remove the source later
chown -R $USER .
chmod -R u+rw .

# Become yourself again
exit

cd
mkdir -p -m 0700 installed
rm -f installed/gawk-*.tar.*
mv gawk-4.0.0.tar.gz installed/


# If you ever want to uninstall gawk, this should do it:
cd
su
test -x /sbin/removepkg && /sbin/removepkg gawk
test -d src/gawk-* && ( cd src/gawk-* ; make uninstall )
( cd /bin ; rm -f dgawk gawk igawk pgawk gawk-* igawk-* pgawk-* )
( cd /usr/bin ; rm -f dgawk gawk igawk pgawk gawk-* igawk-* pgawk-* )
find /usr/doc -type d -name "gawk-*" -exec rm -r {} \;
( cd /usr/info
  rm -f gawk.info gawkinet.info gawk.info.gz gawkinet.info.gz )
test -d /usr/libexec/awk && rm -r /usr/libexec/awk
( cd /usr/man/man1
  rm -f awk.1 gawk.1 igawk.1 pgawk.1 ask.1.gz gawk.1.gz igawk.1.gz \
   pgawk.1.gz )
test -d /usr/share/awk && rm -r /usr/share/awk
find /usr/share/locale -type f -name "gawk.mo" -exec rm {} \;
test -L /bin/awk && rm /bin/awk
test -L /usr/bin/awk && rm /usr/bin/awk
test -L /usr/man/man1/awk.1 && rm /usr/man/man1/awk.1
exit
find ~/src -maxdepth 1 -type d -name "gawk-*" -exec rm -r {} \;
rm -f ~/installed/gawk-*.tar.*

Back to the list


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