1899
|
1 #!/bin/sh
|
|
2
|
|
3 pcre_subdir=pcre/pcre-swig-install
|
|
4 pcre_install_dir=`pwd`/$pcre_subdir
|
|
5
|
|
6 usage() {
|
|
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
|
|
23 bail() {
|
|
24 echo $1 >&2
|
|
25 exit 1
|
|
26 }
|
|
27
|
|
28 if test "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ; then
|
|
29 usage
|
|
30 fi
|
|
31
|
|
32 if test -f "pcre-build.sh" ; then
|
|
33 echo "Error: this script should not be run in the Tools directory" >&2
|
|
34 echo ""
|
|
35 usage
|
|
36 fi
|
|
37
|
|
38 echo "Looking for PCRE tarball..."
|
|
39 rm -rf pcre
|
|
40 pcre_tarball=`ls pcre-*.tar*`
|
|
41 test -n "$pcre_tarball" || bail "Could not find tarball matching pattern: pcre-*.tar*"
|
|
42 test -f "$pcre_tarball" || bail "Could not find a single PCRE tarball. Found: $pcre_tarball"
|
|
43
|
|
44 echo "Extracting tarball: $pcre_tarball"
|
|
45 tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball"
|
|
46 pcre_dir=`echo $pcre_tarball | sed -e "s/\.tar.*//"`
|
|
47 echo "Configuring PCRE in directory: pcre"
|
|
48 mv $pcre_dir pcre || bail "Could not create pcre directory"
|
|
49 cd pcre && ./configure --prefix=$pcre_install_dir --disable-shared $* || bail "PCRE configure failed"
|
|
50 echo "Building PCRE..."
|
|
51 ${MAKE:-make} -s || bail "Could not build PCRE"
|
|
52 echo "Installing PCRE locally to $pcre_install_dir..."
|
|
53 ${MAKE:-make} -s install || bail "Could not install PCRE"
|
|
54 echo ""
|
|
55 echo "The SWIG configure script can now be run, whereupon PCRE will automatically be detected and used from $pcre_install_dir/bin/pcre-config."
|