#!/bin/sh
#usage: ./build-autotools 0.38-0 or 0.38-0test4

if test x$1 == x
then
   echo usage: ./build-autotools 0.38-0 or 0.38-0test4
   exit 1
fi

if test -f pd-$1.src.tar.gz
then
   /bin/echo -n
else
   echo cant find file pd-$1.src.tar.gz
   exit 1
fi

rm -rf pd-$1 Pd-$1-macosx7.app

tar xzf pd-$1.src.tar.gz
cd pd-$1
./autogen.sh
./configure --enable-jack

#workaround for libpd build wierdness
for i in \
  bob~ bonk~ choice fiddle~ loop~ lrshift~ \pd~ pd~ pique sigmund~ stdout; do
cp /dev/null extra/$i/.deps/libpd_la-$i.Plo
done
cp /dev/null extra/pd~/.deps/libpd_la-pdsched.Plo

if make
then
    echo -n
else
   echo build failed
   exit 1
fi

rm -rf po
cp -pr ../po/ po/

cd mac
./osx-app.sh  --wish \
  /Users/msp/work/build/tcltk/pd-wish-8.6.10/mac/Wish-8.6.10.app $1-macosx7
mv Pd-$1-macosx7.app ../../
cd ../..
tar czf pd-$1-macosx7.mac.tar.gz Pd-$1-macosx7.app
