#!/bin/sh
if test "$#" != "1"; then
echo "Usage: makedist <version>" >&2
exit 1
fi
VER=$1 ; shift
old_IFS="$IFS"
IFS=.
eval set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /'`
if test "${1}" = "1" -a "${2}" -lt "28"; then
echo "You will need bison 1.28 if you want to regenerate the Zend parser (found ${1}.${2}).)"
exit 2
fi
IFS="$old_IFS"
if test "x$PHPROOT" == "x"; then
PHPROOT=git@git.php.net:php-src.git;
fi
LT_TARGETS='ltconfig ltmain.sh config.guess config.sub'
if echo '\c' | grep -s c >/dev/null 2>&1
then
ECHO_N="echo -n"
ECHO_C=""
else
ECHO_N="echo"
ECHO_C='\c'
fi
MY_OLDPWD=`pwd`
ARCHIVE=$MY_OLDPWD/php-$VER.tar
DIR=php-$VER
DIRPATH=$MY_OLDPWD/$DIR
if test -d "$DIRPATH"; then
echo "The directory $DIR"
echo "already exists, rename or remove it and run makedist again."
exit 1
fi
$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
git archive --format=tar --remote=$PHPROOT refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
echo ""
cd $DIR || exit 5
for i in $LT_TARGETS; do
if test -f "$i"; then
mv $i $i.bak
cp $i.bak $i
fi
done
set -x
./buildconf --copy --force
rm -f buildmk.stamp
./genfiles
for i in $LT_TARGETS; do
test -f "$i" && mv $i.bak $i
done
find . -name \*.orig -print0 | xargs -0 rm
rm -fr autom4te.cache/
$ECHO_N "makedist: Attempting to download PEAR's phar archive"
if test ! -x wget; then
wget http://pear.php.net/install-pear-nozlib.phar -nd -P pear/
else
$ECHO_N "Missing wget binary needed for pear download";
exit 7
fi
cd $MY_OLDPWD
$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
rm -f $ARCHIVE.gz
tar cf $ARCHIVE php-$VER || exit 8
gzip -9 $ARCHIVE || exit 9
echo ""
$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
rm -f $ARCHIVE.bz2
tar cf $ARCHIVE php-$VER || exit 10
bzip2 -9 $ARCHIVE || exit 11
echo ""
$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
rm -f $ARCHIVE.xz
tar cf $ARCHIVE php-$VER || exit 10
xz -9 $ARCHIVE || exit 12
echo ""
$ECHO_N "makedist: cleaning up...$ECHO_C"
rm -rf $DIRPATH || exit 13
echo ""
exit 0