Blame glib/update-pcre/update.sh

Packit ae235b
#! /bin/sh
Packit ae235b
Packit ae235b
IN="../update-pcre"
Packit ae235b
PCRE=$1
Packit ae235b
Packit ae235b
if [ "x$PCRE" = x -o "x$PCRE" = x--help -o "x$PCRE" = x-h ]; then
Packit ae235b
    cat >&2 << EOF
Packit ae235b
Packit ae235b
$0 PCRE-DIR
Packit ae235b
Packit ae235b
  Updates the local PCRE copy with a different version of the library,
Packit ae235b
  contained in the directory PCRE-DIR.
Packit ae235b
Packit ae235b
  This will delete the content of the local pcre directory, copy the
Packit ae235b
  necessary files from PCRE-DIR, and generate other needed files, such
Packit ae235b
  as Makefile.am
Packit ae235b
EOF
Packit ae235b
    exit
Packit ae235b
fi
Packit ae235b
Packit ae235b
if [ ! -f gregex.h ]; then
Packit ae235b
    echo "This script should be executed from the directory containing gregex.c." 2> /dev/null
Packit ae235b
    exit 1
Packit ae235b
fi
Packit ae235b
Packit ae235b
if [ ! -f $PCRE/Makefile.in -o ! -f $PCRE/pcre_compile.c ]; then
Packit ae235b
    echo "'$PCRE' does not contain a valid PCRE version." 2> /dev/null
Packit ae235b
    exit 1
Packit ae235b
fi
Packit ae235b
Packit ae235b
Packit ae235b
echo "Deleting old PCRE library"
Packit ae235b
mv pcre/.svn tmp-pcre-svn
Packit ae235b
rm -R pcre 2> /dev/null
Packit ae235b
mkdir pcre
Packit ae235b
cd pcre
Packit ae235b
Packit ae235b
# pcre_chartables.c is generated by dfatables.
Packit ae235b
# We do not want to compile and execute dfatables.c every time, because
Packit ae235b
# this could be a problem (e.g. when cross-compiling), so now generate
Packit ae235b
# the file and then distribuite it with GRegex.
Packit ae235b
echo "Generating pcre_chartables.c"
Packit ae235b
cp -R $PCRE tmp-build
Packit ae235b
cd tmp-build
Packit ae235b
./configure --enable-utf8 --enable-unicode-properties --disable-cpp > /dev/null
Packit ae235b
make pcre_chartables.c > /dev/null
Packit ae235b
cat > ../pcre_chartables.c << \EOF
Packit ae235b
/* This file is autogenerated by ../update-pcre/update.sh during
Packit ae235b
 * the update of the local copy of PCRE.
Packit ae235b
 */
Packit ae235b
EOF
Packit ae235b
cat pcre_chartables.c >> ../pcre_chartables.c
Packit ae235b
cd ..
Packit ae235b
rm -R tmp-build
Packit ae235b
Packit ae235b
# Compiled C files.
Packit ae235b
echo "Generating makefiles"
Packit ae235b
all_files=`awk '/^OBJ = /, /^\\s*$/ \
Packit ae235b
            { \
Packit ae235b
                sub("^OBJ = ", ""); \
Packit ae235b
                sub(".@OBJEXT@[[:blank:]]*\\\\\\\\", ""); \
Packit ae235b
                sub("\\\\$\\\\(POSIX_OBJ\\\\)", ""); \
Packit ae235b
                print; \
Packit ae235b
            }' \
Packit ae235b
            $PCRE/Makefile.in`
Packit ae235b
Packit ae235b
# Headers.
Packit ae235b
included_files="pcre.h pcre_internal.h ucp.h ucpinternal.h"
Packit ae235b
Packit ae235b
# Generate Makefile.am.
Packit ae235b
cat $IN/Makefile.am-1 > Makefile.am
Packit ae235b
for name in $all_files; do
Packit ae235b
    echo "	$name.c \\" >> Makefile.am
Packit ae235b
    if [ $name != pcre_chartables ]; then
Packit ae235b
        # pcre_chartables.c is a generated file.
Packit ae235b
        cp $PCRE/$name.c .
Packit ae235b
    fi
Packit ae235b
done
Packit ae235b
for f in $included_files; do
Packit ae235b
    echo "	$f \\" >> Makefile.am
Packit ae235b
    cp $PCRE/$f .
Packit ae235b
done
Packit ae235b
cat $IN/Makefile.am-2 >> Makefile.am
Packit ae235b
Packit ae235b
echo "Patching PCRE"
Packit ae235b
Packit ae235b
# Copy the license.
Packit ae235b
cp $PCRE/COPYING .
Packit ae235b
Packit ae235b
# Use glib for memory allocation.
Packit ae235b
patch > /dev/null < $IN/memory.patch
Packit ae235b
Packit ae235b
# Copy the modified version of pcre_valid_utf8.c.
Packit ae235b
cp $IN/pcre_valid_utf8.c .
Packit ae235b
Packit ae235b
# Copy the modified version of pcre_ucp_searchfuncs.c that uses glib
Packit ae235b
# for Unicode properties.
Packit ae235b
cp $IN/pcre_ucp_searchfuncs.c .
Packit ae235b
patch > /dev/null < $IN/ucp.patch
Packit ae235b
Packit ae235b
# Remove the digitab array in pcre_compile.c.
Packit ae235b
patch > /dev/null < $IN/digitab.patch
Packit ae235b
sed -i -e 's/(digitab\[\(.*\)\] & ctype_digit)/g_ascii_isdigit(\1)/' pcre_compile.c
Packit ae235b
sed -i -e 's/(digitab\[\(.*\)\] & ctype_xdigit)/g_ascii_isxdigit(\1)/' pcre_compile.c
Packit ae235b
Packit ae235b
# Reduce the number of relocations.
Packit ae235b
python $IN/make_utt.py
Packit ae235b
patch > /dev/null < $IN/utt.patch
Packit ae235b
patch > /dev/null < $IN/table-reduction.patch
Packit ae235b
Packit ae235b
# Copy back the old SVN directory.
Packit ae235b
mv ../tmp-pcre-svn .svn
Packit ae235b
Packit ae235b
Packit ae235b
cat << EOF
Packit ae235b
Packit ae235b
Update completed. You now should check that everything is working.
Packit ae235b
Remember to update the regex syntax doc with the new features
Packit ae235b
(docs/reference/glib/regex-syntax.sgml) and to run the tests.
Packit ae235b
EOF
Packit ae235b