PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Tools/pcre-build.sh

#
Shell | 55 lines | 47 code | 7 blank | 1 comment | 13 complexity | 5cef5c6907d6d2bb66904d7d59f01dea MD5 | raw file
 1#!/bin/sh
 2
 3pcre_subdir=pcre/pcre-swig-install
 4pcre_install_dir=`pwd`/$pcre_subdir
 5
 6usage() {
 7  echo "Helper script to build PCRE as a static library from a tarball just for use during the"
 8  echo "SWIG build. It does not install PCRE for global use on your system."
 9  echo "Usage: pcre-build.sh [--help] [args]"
10  echo "  args   - optional additional arguments passed on to the PCRE configure script (leave out"
11  echo "         unless you are an expert at configure)"
12  echo "  --help - Display this help information."
13  echo "Instructions:"
14  echo "  - Download the latest PCRE source tarball from http://www.pcre.org and place in the"
15  echo "    directory that you will configure and build SWIG."
16  echo "  - Run this script in the same directory that you intend to configure and build SWIG in."
17  echo "    This will configure and build PCRE as a static library."
18  echo "  - Afterwards run the SWIG configure script which will then find and use the PCRE static"
19  echo "    libraries in the $pcre_subdir subdirectory."
20  exit 0
21}
22
23bail() {
24  echo $1 >&2
25  exit 1
26}
27
28if test "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ; then
29  usage
30fi
31
32if test -f "pcre-build.sh" ; then
33  echo "Error: this script should not be run in the Tools directory" >&2
34  echo ""
35  usage
36fi
37
38echo "Looking for PCRE tarball..."
39rm -rf pcre
40pcre_tarball=`ls pcre-*.tar*`
41test -n "$pcre_tarball" || bail "Could not find tarball matching pattern: pcre-*.tar*"
42test -f "$pcre_tarball" || bail "Could not find a single PCRE tarball. Found: $pcre_tarball"
43
44echo "Extracting tarball: $pcre_tarball"
45tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball"
46pcre_dir=`echo $pcre_tarball | sed -e "s/\.tar.*//"`
47echo "Configuring PCRE in directory: pcre"
48mv $pcre_dir pcre || bail "Could not create pcre directory"
49cd pcre && ./configure --prefix=$pcre_install_dir --disable-shared $* || bail "PCRE configure failed"
50echo "Building PCRE..."
51make -s || bail "Could not build PCRE"
52echo "Installing PCRE locally to $pcre_install_dir..."
53make -s install || bail "Could not install PCRE"
54echo ""
55echo "The SWIG configure script can now be run, whereupon PCRE will automatically be detected and used from $pcre_install_dir/bin/pcre-config."