#!/bin/bash 
#------------------

# http://proteowizard.svn.sourceforge.net/viewvc/proteowizard/trunk/pwiz/libraries/boost_aux/boost/utility/

cd src

rm -rf pwiz
mkdir pwiz
cd pwiz

PWIZREPO=http://proteowizard.svn.sourceforge.net/svnroot/proteowizard/trunk/pwiz/
svn co --non-recursive $PWIZREPO .

for DIR in data/msdata data/common utility/chemistry/ utility/misc/ utility/math/ utility/minimxml/ ; do 
    svn co $PWIZREPO/pwiz/$DIR $DIR
done

#------------------

cd ..
rm -rf boost
mkdir boost
cd boost

BOOSTVER=Boost_1_43_0
BOOSTREPO=http://svn.boost.org/svn/boost/tags/release/$BOOSTVER/boost

svn co --non-recursive $BOOSTREPO .

for DIR in smart_ptr  config config mpl detail iostreams exception function_types \
    io type_traits preprocessor format algorithm logic optional range \
    iterator function utility concept bind regex filesystem system thread \
    date_time lambda  tuple multi_index serialization archive functional integer ; do 
    svn co $BOOSTREPO/$DIR $DIR
done
       
BOOSTLIBSREPO=http://svn.boost.org/svn/boost/tags/release/$BOOSTVER/libs
for DIR in iostreams/src thread/src/pthread/ filesystem/src/ regex/src system/src ; do 
    svn co $BOOSTLIBSREPO/$DIR $DIR
done

cd ..
           
#------------------

rm -rf boost_aux
mkdir boost_aux
cd boost_aux

PWIZBOOSTREPO=http://proteowizard.svn.sourceforge.net/svnroot/proteowizard/trunk/pwiz/libraries/boost_aux/boost/
svn co $PWIZBOOSTREPO boost

cd ..

#------------------


PWIZ_MAJOR=$(grep "constant PWIZ_MAJOR" pwiz/Jamroot.jam | sed -e 's/constant PWIZ_MAJOR : \([0-9+]\) ;/\1/')
PWIZ_MINOR=$(grep "constant PWIZ_MINOR" pwiz/Jamroot.jam | sed -e 's/constant PWIZ_MINOR : \([0-9+]\) ;/\1/')

lastchangedrev=$(svn info pwiz/data/msdata | grep "Last Changed Rev:" | cut -d: -f 2)
lastchangeddate=$(svn info pwiz/data/msdata | grep "Last Changed Date:" | cut -d" " -f 4 | tr "-" " ")
revisioninfo="($lastchangedrev $lastchangeddate)"

cat >pwiz/data/msdata/Version.cpp <<EOF
// This file was generated by the \"svnrev\" utility
// You should not modify it manually, as it may be re-generated.
//
// $Revision: ${revisioninfo[1]} $
// $Date: ${revisioninfo[2]}-${revisioninfo[3]}-${revisioninfo[4]} $
//

#define PWIZ_SOURCE
#include "Version.hpp"
#include <sstream>

#ifdef PWIZ_USER_VERSION_INFO_H // in case you need to add any info version of your own
#include PWIZ_USER_VERSION_INFO_H  // must define PWIZ_USER_VERSION_INFO_H_STR for use below
#endif

namespace pwiz {
namespace msdata {

using std::string;

int Version::Major()                {return 0${PWIZ_MAJOR};}
int Version::Minor()                {return 0${PWIZ_MINOR};}
int Version::Revision()             {return 0${revisioninfo[1]};}
string Version::LastModified()      {return "${revisioninfo[2]}-${revisioninfo[3]}-${revisioninfo[4]}";}
string Version::str()               
{
	std::ostringstream v;
	v << Major() << '.' << Minor() << '.' << Revision();
#ifdef PWIZ_USER_VERSION_INFO_H
	v << " (" << PWIZ_USER_VERSION_INFO_H_STR << ")";
#endif
	return v.str();
}
}
}
EOF

#------------------