#---
## @Synopsis libdepends
#---

function query_spell_dependencies() {
  if ! [[ $SPELL_DEPENDENCIES ]] ||
     ! query "Are \"${SPELL_DEPENDENCIES}\" the proper dependencies for this spell" y
  then
    query_msg "Please enter the dependencies(non optional) \
of the spell if any:"
    read "SPELL_DEPENDENCIES"
    SPELL_DEPENDENCIES=$(tr ',' ' ' <<< "$SPELL_DEPENDENCIES")
    SPELL_DEPENDENCIES=$(sort <<< "$SPELL_DEPENDENCIES")
    SPELL_DEPENDENCIES=$(uniq <<< "$SPELL_DEPENDENCIES")
fi
}

function query_spell_optional_dependencies() {
  query_msg "Please enter the optional dependencies of the \
spell if any:"
  read -a "SPELL_OPTIONAL_DEPENDENCIES"
}

function add_dependencies() {
  touch DEPENDS
  DEPENDSISON="DEPENDS, "
  for i in ${SPELL_DEPENDENCIES}
  do
     echo "depends ${i}" >> DEPENDS
  done
}

function add_optional_dependencies() {
  touch DEPENDS
  DEPENDSISON="DEPENDS, "
  SPELL_OPTIONAL_DEPENDENCIES_ENABLED[0]=""
  SPELL_OPTIONAL_DEPENDENCIES_DISABLED[0]=""
  SPELL_OPTIONAL_DEPENDENCIES_DESCRIPTION[0]=""
  NM=${#SPELL_OPTIONAL_DEPENDENCIES[*]}
  for  ((MN=0; MN < $NM; MN++))
  do
    query_msg "${SPELL_OPTIONAL_DEPENDENCIES[$MN]} needs a ./configure enable option"
    read SPELL_OPTIONAL_DEPENDENCIES_ENABLED[$MN]
    query_msg "${SPELL_OPTIONAL_DEPENDENCIES[$MN]} needs a ./configure disable option"
    read SPELL_OPTIONAL_DEPENDENCIES_DISABLED[$MN]
    query_msg "${SPELL_OPTIONAL_DEPENDENCIES[$MN]} needs a description"
    read SPELL_OPTIONAL_DEPENDENCIES_DESCRIPTION[$MN]

    message "optional_depends ${SPELL_OPTIONAL_DEPENDENCIES[$MN]} \\" >> DEPENDS
    message "                 \"${SPELL_OPTIONAL_DEPENDENCIES_ENABLED[$MN]}\" \\" >> DEPENDS
    message "                 \"${SPELL_OPTIONAL_DEPENDENCIES_DISABLED[$MN]}\" \\" >> DEPENDS
    message "                 \"${SPELL_OPTIONAL_DEPENDENCIES_DESCRIPTION[$MN]}\"" >> DEPENDS
  done
# "optional_depends ${j} \"enabled-option\" \"disabled-option\" \"description\""
}
#---
##
## This software 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 software 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 software; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##
#---

