Linux HOWTOs

About | Home | Search


HOWTO: pcre
Description: Library for Perl Compatible Regular Expressions
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


# PCRE 8.42
# =========
# PCRE2 is covered in a seperate HOWTO

# Slackware 13.37, 14.0: pcre 8.12
# Slackware 14.1: pcre 8.33
# Slackware 14.2: pcre 8.39

# Prerequisites:
# pkg-config
# zlib (if you don't leave off --enable-pcregrep-libz)
# bzip2 (if you don't leave off --enable-pcregrep-libbz2)
# readline

# Apache, KDE, PHP, and other significant things use this library, so I
# would suggest shutting them down before upgrading this library or at least
# knowing what is running that uses it before beginning.
# Try running 'lsof /usr/lib*/libpcre*'
# (if you have lsof installed) to see if anything else is running that
# uses the PCRE shared library.

# If you have any trouble downloading it from the URL below, try these:
# https://ftp.pcre.org/pub/pcre/
# https://sourceforge.net/projects/pcre/files/

# Get it
cd
test -f installed/pcre-8.42.tar.bz2 && mv installed/pcre-8.42.tar.bz2 .
test ! -f pcre-8.42.tar.bz2 &&
 wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.bz2

# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "2cd04b7c887808be030254e8d77de11d3fe9d4505c39d4b15d2664ffe8bf93\
01  pcre-8.42.tar.bz2" | sha256sum -c

# Verify tarball w/ gpg:
( gpg --list-keys FB0F43D8 > /dev/null 2>&1 || gpg --recv-keys FB0F43D8 ) &&
 wget -nc ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/\
pcre-8.42.tar.bz2.sig &&
  gpg --verify pcre-8.42.tar.bz2.sig && rm pcre-8.42.tar.bz2.sig

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

## If you have readline installed, but configure says:
# checking for readline in -lreadline... no
## and lines like this are in config.log:
# /usr/lib/gcc/i486-slackware-linux/x.x.x/../../../libreadline.so: undefined
# reference to `tgetflag'
## try running configure with this before it:
# LIBS=-ltermcap \

# Configure the build - 64-bit
./configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man \
--enable-utf8 --enable-pcregrep-libz --enable-pcregrep-libbz2 \
--enable-pcretest-libreadline

# Configure the build - anything else
./configure --prefix=/usr --mandir=/usr/man --enable-utf8 \
--enable-pcregrep-libz --enable-pcregrep-libbz2 \
--enable-pcretest-libreadline

# Build it
make

# Become root to clean up old files and to install it
su

# Because grep may be linked with the existing libpcre, and configure and
# 'make install' use grep, we can't run removepkg at this point - if your
# grep is linked with a shared libpcre (ldd /usr/bin/grep).  If you're
# replacing a Slackware PCRE package, manually remove files from it except
# for /usr/lib*/libpcre* files.  Look in ./zapme.txt after this, if the list
# looks good, run:  cat zapme.txt | xargs rm -f
rm -f ./zapme.txt
egrep "^usr\/" /var/adm/packages/pcre-* |
egrep -v "\/$" | egrep -v "^usr\/(lib|lib64)\/" |
while read zapme; do echo "/${zapme}" >> ./zapme.txt; done

# Install it
make install
ldconfig

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

# Now if you want, remove old versions of libpcre.so.*, libpcrecpp.so.*,
# and libpcreposix.so.* in /usr/lib*/, if there are any.  This is purely to
# avoid clutter, so if you feel like leaving them there, that's fine.
# Normally you'd be weary of programs that are linked to libpcre.so.1 when
# you upgrade to libpcre.so.2 (remove .1 and break that program), but every
# version that I've installed so far has named the shared library files
# something like libpcre*.so.0.0.1

# If you have PHP or KDE installed, verify that KDE is linked to the
# new version OK.  If your grep is linked to it, check that.
test -x /bin/grep && ldd /bin/grep
test -x /usr/bin/kaddressbook && ldd /usr/bin/kaddressbook | grep pcre
test -x /usr/local/bin/php && ldd /usr/local/bin/php | grep pcre

# Move the package files for Slackware's PCRE out of the way (as if you had
# removed pcre with removepkg):
find /var/adm/packages -type f -name "pcre-*" \
 -exec mv {} /var/adm/removed_packages/ \;
find /var/adm/scripts -type f -name "pcre-*" \
 -exec mv {} /var/adm/removed_scripts/ \;

# Become yourself again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/pcre-*.tar.*
mv pcre-8.42.tar.bz2 installed/

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>