#!/bin/sh
##
##  aux.prereq.sh -- Platform Pre-Requisite Checks
##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##
##  Usage: aux.prereq.sh source|binary
##

mode=$1

#   determine platform id
platform=`sh ./shtool guessos`

#
#   CHECK: amount of platform support
#
support=no
case $platform in
    *-solaris* )
       case $platform in
           *-solaris2.[67] )
               support=maybe
               ;;
           *-solaris2.[89] )
               support=yes
               ;;
       esac
       ;;
    *-linux* ) 
       if [ -f /etc/redhat-release ]; then
           redhat=`cat /etc/redhat-release | sed -e 's;^.*\([0-9]\.[0-9]*\).*$;\1;'`
           case "$redhat" in
               7.2    )
                   support=yes
                   ;;
               7.[13] ) 
                   support=maybe 
                   ;;
           esac
       elif [ -f /etc/debian_version ]; then
           debian=`cat /etc/debian_version`
           case "$debian" in
               2.2|3.0 ) 
                   support=yes
                   ;;
           esac
       fi
       ;;
    *-freebsd* )
       case $platform in
           *-freebsd4.[56] )
               support=yes
               ;;
           *-freebsd4.[01234789] )
               support=maybe
               ;;
           *-freebsd5.0 )
               support=maybe
               ;;
       esac
       ;;
    *-netbsd* )
       support=maybe
       ;;
    *-osf* )
       support=maybe
       ;;
    *-hpux* )
       support=maybe
       ;;
    *-darwin* )
       support=maybe
       ;;
    *-64-sgi-irix* )
       support=maybe
       ;;
esac
case $support in
    yes   ) support="Congratulations: officially supported" ;;
    maybe ) support="Good luck: unofficially supported" ;;
    no    ) support="Sorry: not supported" ;;
esac
echo "++ platform: $platform ($support)"
case $support in
    no ) exit 1 ;;
esac

#
#   CHECK: diskspace requirement
#
case $platform in
    *-solaris* )
       ;;
    *-linux* ) 
       ;;
    *-freebsd* )
       ;;
    *-osf* )
       ;;
esac

#
#   CHECK: available vendor packages
#
case $platform in
    *-solaris* )
       ;;
    *-linux* ) 
       ;;
    *-freebsd* )
       ;;
    *-osf* )
       ;;
esac

# 
#   CHECK: available tools in $PATH
#

# 
#   CHECK: available devices /dev/random, etc.
#

#
#   CHECK: consistency check for /cw (symlink!)
#

