#!/bin/sh
PATH=/usr/local/gnu-autotools/bin/:$PATH
export PATH
if [ -f version ]; then
cd ..
fi
if [ \! -f build/version ]; then
echo "Can't find source directory"
exit 1
fi
export MAKEOBJDIRPREFIX=/junk
if [ -f build/version ]; then
cd build
fi
if [ \! -f version ]; then
echo "Can't find version file"
exit 1
fi
MARKER=`cat version | sed 's/[0-9.]//g'`
VN=`cat version | sed 's/[^0-9.]//g'`
VS="$(($VN/1000000)).$(( ($VN/1000)%1000 )).$(( $VN%1000 ))$MARKER"
cd ..
/bin/sh build/clean.sh
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_NUMBER).*/\$1 $VN/" libarchive/archive.h
perl -p -i -e "s/^(#define\tARCHIVE_VERSION_STRING).*/\$1 \"libarchive $VS\"/" libarchive/archive.h
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' configure.ac
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac
set -xe
aclocal -I build/autoconf
case `uname` in
Darwin) glibtoolize --automake -c;;
*) libtoolize --automake -c;;
esac
autoconf
autoheader
automake -a -c
./configure
make distcheck