#! /bin/sh -c "echo This script should not be run directly.; exit 1"
################################################################
# Myricom GM networking software and documentation
# Copyright 2001, 2002 by Myricom, Inc.
# All rights reserved.	 See the file `COPYING' for copyright notice.
################################################################
# author: glenn@myri.com
# $Source: /repository/gm/scripts/sbin/gm_install_drivers,v $

################
# Install machine-specific configuration
################

gm_install_gm ()
{
    gm_arch_install_gm && return $?
}

gm_install_ethernet ()
{
    gm_arch_install_ethernet && return $?
}

gm_install_drivers ()
{
    gm_installed_make_id_matches "${prefix}" \
    || gm_die "--prefix=$prefix is not configured by GM_INSTALL."
    
    gm_create_uninstall_file "/sbin/gm_uninstall_drivers" \
    || gm_die "Could not create \"/sbin/gm_uninstall_drivers\""
    
    gm_install_gm \
    || gm_die "Could not install GM drivers"
    
    gm_install_ethernet \
    || gm_die "Could not install ethernet emulation"
    
    gm_close_uninstall_log \
    || gm_die "Could not close uninstall script"
}

gm_help_for_install_drivers ()
{
    gm_echo "Syntax: gm_install_drivers <options>"
    gm_echo "Legitimate options are:"
    gm_echo "    --copy         Copy files instead of linking them."
    gm_echo "                   (Useful if the GM driver must be brought up"
    gm_echo "                   before $prefix is mounted."
    gm_echo "    --help         Print this help information."
    gm_echo "    --link         Link subsequent files instead of copying"
    gm_echo "    --quiet        Turn off verbose output. [default]"
    gm_echo "    --verbose      Turn on verbose output."
}

# Check preconditions on user actions

gm_running_as_root \
|| gm_die GM drivers must be installed as root.

gm_installed_make_id_matches "${prefix}" \
|| gm_die "${prefix} does not hold a GM_INSTALLed release."

# Note where we can find the libtool script.

gm_libtool="${prefix}/etc/gm/gm_libtool"

# # Try to guess the install directory from whatever context information
# # we have.
# 
# gm_infer_installed_prefix

# Parse args, executing each in turn as a command.

gm_link_not_copy=0
while true
do
    case $1 in
    	"")
	    break # Exit while loop
	    ;;
	--copy)
	    gm_link_not_copy=0
	    ;;
    	--help | -h | /?)
	    gm_help_for_install_drivers || exit $?
    	    ;;
	--link)
	    gm_link_not_copy=1
	    ;;
    	--quiet | -q)
    	    gm_verbose=0
    	    ;;
    	--verbose | -v)
    	    gm_verbose=1
    	    ;;
	*)
	    gm_die "Option \"$1\" is not recognized."
    esac
    shift
done

gm_install_drivers || gm_die "Could not install the GM driver."

gm_echo "GM drivers are now installed.  Remember to run"
gm_echo "	${gm_arch_driver_start_command}"
gm_echo "to start the GM driver."
