
# --8<--8<--8<--8<--
#
# Copyright (C) 2006 Smithsonian Astrophysical Observatory
#
# This file is part of sysarch
#
# sysarch 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.
#
# sysarch 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.
#       51 Franklin Street, Fifth Floor
#       Boston, MA  02110-1301, USA
#
# -->8-->8-->8-->8--


###############################################################################
#
# Requires:
#   platforms - a colon separated list of platform names
#
# Initializes:
#   buildgeneric  - the least specific plat name, used for building code
#   buildtarget   - the (currently) prefered plat name, used for building code
#   buildtargetdist - the (currently) prefered plat name, but
#                     distribution specificused for building code
#   buildspecific - the most specific plat name, used for building code
#   exectarget    - the (currently) prefered plat name, used to run code
#
# Notes:
#   This script sets up the buildtarget and buildspecific variables.  These
#   variables are meant to be the least specific and most specific platform
#   names for build code.
#
#   For the x86_64 platforms, it has been decided that the most general
#   platform should be x86_64 with the 2.6_2 OSrev.
#
###############################################################################

case $platforms in
  *x86_64*)

    # first x86_64 entry
    buildtarget=${platforms_nodist#*:x86_64}
    buildtarget="x86_64${buildtarget%%:*}"

    buildgeneric="${platforms_nodist##*:}"
    buildspecific="${platforms_nodist%%:*}"
    exectarget="$buildtarget"
    ;;

  *)
    buildgeneric="${platforms_nodist##*:}"
    buildspecific="${platforms%%:*}"
    buildtarget="$buildgeneric"
    exectarget="$buildgeneric"
    ;;
esac


# no need to repeat oneself if OS == OSdist

if [ "$OS" != "$OSdist" ]; then
  buildtargetdist=${buildtarget/$OS/${OS}_${OSdist}}
  buildgenericdist=${buildgeneric/$OS/${OS}_${OSdist}}
  buildspecificdist=${buildspecific/$OS/${OS}_${OSdist}}

else

  buildtargetdist=${buildtarget}
  buildgenericdist=${buildgeneric}
  buildspecificdist=${buildspecific}

fi
