#!/bin/sh
# create MaxDB build tools
#
#   ========== licence begin  GPL
#   Copyright (c) 2004 SAP AG
#
#   This program 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 2
#   of the License, or (at your option) any later version.
#
#   This program 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 this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#   ========== licence end
#

#
# configuration variables
#  TODO: use environment variables or command line options
buildroot=`pwd`
sourceroot=$buildroot/sys/src
buildtoolsTarget=$buildroot/buildtools
wrk=$buildroot/sys/wrk/buildtools
basetools=$sourceroot/buildtools/base
export buildroot sourceroot buildtoolsTarget

#
# cd to wrk directory
#
mkdir -p $wrk
cd $wrk

#
# copy sources of base tools to working directory
#  TODO: option to run in source tree

cp $sourceroot/buildtools/base/* .
chmod +w *
(cd $sourceroot  && tar cf - base) | tar xf -

#
# configure and make base tools
#

make -f bootstrap.mak sourceroot=$sourceroot buildtoolsTarget=$buildtoolsTarget
