#!/bin/sh
# The default path should be /usr/local

# Get some info from configure
chmod +x ./scripts/setsomevars
. ./scripts/setsomevars

#make

# This should really be integrated with automake and not duplicate the
# installation list.

BASE=mysql-$version-$system-$machine
mkdir $BASE $BASE/bin $BASE/data $BASE/data/mysql $BASE/data/test \
 $BASE/include $BASE/lib $BASE/mysqlperl $BASE/scripts \
 $BASE/share $BASE/tests

for i in BUGS NEWS CREDITS sql/ChangeLog EXAMPLE \
 INSTALL-BINARY INSTALL-SOURCE PORTING PUBLIC README TODO \
 FAQs/mysql-faq.html FAQs/mysql-faq.txt FAQs/mysql-faq_toc.html
do
  ln $i $BASE
done

for i in extra/comp_err client/mysql sql/mysqld client/mysqlshow \
 extra/replace isam/isamchk client/mysqladmin client/mysqldump \
 extra/perror
do
  ln $i $BASE/bin
done

ln include/* $BASE/include; rm $BASE/include/Makefile*; rm $BASE/include/*.in
ln tests/*.res tests/*.tst tests/*.pl $BASE/tests
ln data/mysql/*.frm $BASE/data/mysql 
ln client/libmysqlclient.a $BASE/lib
cd perl/mysqlperl/; cp -r . ../../$BASE/mysqlperl; cd ../.. 
sh -c "cd $BASE/mysqlperl ; make clean"
rm $BASE/mysqlperl/*.sh
cp -r sql/share/* $BASE/share; rm -f $BASE/share/Makefile* $BASE/share/*/*.OLD

ln scripts/* $BASE/scripts
rm -f $BASE/scripts/Makefile* $BASE/scripts/*.in $BASE/scripts/*.sh $BASE/scripts/make_binary_distribution $BASE/scripts/setsomevars
$BASE/bin/replace @localstatedir@ ./data @bindir@ ./bin @scriptdir@ ./scripts < scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
chmod a+x $BASE/scripts/*

tar cvf - $BASE | gzip > $BASE.tgz 

rm -rf $BASE
