#!/bin/sh

##
##  Copyright 2010-2012 SRI International
##
##  This file is part of the Computational Morphometry Toolkit.
##
##  http://www.nitrc.org/projects/cmtk/
##
##  The Computational Morphometry Toolkit is free software: you can
##  redistribute it and/or modify it under the terms of the GNU General Public
##  License as published by the Free Software Foundation, either version 3 of
##  the License, or (at your option) any later version.
##
##  The Computational Morphometry Toolkit is distributed in the hope that it
##  will be useful, but WITHOUT ANY WARRANTY; without even the implied
##  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU General Public License for more details.
##
##  You should have received a copy of the GNU General Public License along
##  with the Computational Morphometry Toolkit.  If not, see
##  <http://www.gnu.org/licenses/>.
##
##  $Revision: 4636 $
##
##  $LastChangedDate: 2012-11-20 14:05:08 -0800 (Tue, 20 Nov 2012) $
##
##  $LastChangedBy: torstenrohlfing $
##

##
## SYNOPSIS
##
##  This script can be run from anywhere and will create
##  all officially distributed MacOS packages, each in
##  its own subdirectory of the current working directory.
##

SOURCEDIR=`dirname $0`
SOURCEDIR=`dirname ${SOURCEDIR}`
SOURCEDIR=`cd ${SOURCEDIR}; pwd`

SDKs="$*"
if [ "${SDKs}" == "" ]; then
    SDKs="OSX-10.4 OSX-10.5 OSX-10.6 gcc4.7-macports-OSX-10.6"
fi

svn update source
for sdk in ${SDKs}; do
    if [ ! -d ${sdk} ]; then
	mkdir ${sdk}
	pushd ${sdk}
	cmake -C ${SOURCEDIR}/config/package.cmake -C ${SOURCEDIR}/config/${sdk}*.cmake ${SOURCEDIR}
    else
	pushd ${sdk}
	cmake .
    fi
    
    make -j2 package
    cpack -G PackageMaker
    popd
done

