#	executed from source directory, $1 = distribution name
#
#	WINDOWS ONLY: DISTRIB hard-coded (no version in directory name,
#	and the directory is persistent)
#
#	This distribution is for Advanced Installer. Note that the CV++
#	libraries are handled as a Merge Module within the installer, so
#	no vcredist.exe is needed.
#
#	This version copies any .DLL-s that are present in in/WIN32-VC
#	into the distribution. That should be just the Root DLL-s.
#
#	NOTE: avoid using .. as that fails in the presence of symbolic links;
#	use `dirname "$PWD"` instead.

if test ! -r g4beamline.cc
then
	echo wrong directory!
	exit 1
fi


DISTRIB=G4beamline-WIN32-VC

'cd' `dirname "$PWD"`

echo "Building from "`pwd`

rm -f $DISTRIB.tgz

# clean up a bit
rm -fr doc/html doc/doxygen.log *.dat *.hst *.ldd \
	examples/*.dat examples/g4beamline.hst examples/?.hst examples/*.out \
	examples/??.hst examples/???.hst examples/*.heprep* \
	examples/*.root examples/zap* \
	examples/*.swf examples/*.mov examples/*.avi \
	zap* gui/zap*

rm -fr $DISTRIB
mkdir $DISTRIB $DISTRIB/data $DISTRIB/bin $DISTRIB/bin/$G4SYSTEM $DISTRIB/gui 

cp -LRp doc examples setup test viewer.def $DISTRIB
cp -LRp data/PhotonEvaporation* $DISTRIB/data
cp -Lp gui/[D-z]*  $DISTRIB/gui
rm -f $DISTRIB/gui/*.icns $DISTRIB/gui/*.root $DISTRIB/gui/*.txt

### construct bin
cp -Lp bin/historoot bin/g4bl* bin/G4bl* $DISTRIB/bin 
cp -Lp bin/$G4SYSTEM/* $DISTRIB/bin/$G4SYSTEM
chmod 755 $DISTRIB/bin/$G4SYSTEM/*

rm -fr $DISTRIB/*/CVS $DISTRIB/*/*/CVS $DISTRIB/*/*/*/CVS

#tar -czf $DISTRIB.tgz $DISTRIB
#rm -fr $DISTRIB
echo $DISTRIB directory created
echo "Now you should run the AdvancedInstaller, open" `cygpath -m "$PWD/G4beamline.aip"`
echo "edit the version number, make other changes (if necessary),"
echo "and build the product (G4beamline.msi)."