#!/bin/sh
#
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"%Z%%M%	%I%	%E% SMI"
#


# GNU emacs is delivered to Solaris as a core package (SUNWemacs)
# that contains a complete emacs environment, minus the actual emacs
# binaries. There are multiple binaries, which are optionally
# installed from separate packages:
#
#	emacs-x (SUNWemacs-x)
#		X11 support, using the Athena (Xaw) toolkit.
#
#	emacs-nox (SUNWemacs-nox)
#		Pure tty emacs, without any X Window support.
#		emacs-nox can run on a system minimized to not include
#		the X11 libraries.
#
# This script is installed as /usr/bin/emacs. It examines the
# emacs binaries on the system, and runs the "best" version available.
#
for EXE in emacs-x emacs-nox; do
	if [ -f /usr/bin/$EXE ]; then
		exec /usr/bin/$EXE "$@"
	fi
done

# If we get here, the system has SUNWemacs installed without
# one of the packages that deliver the executables.
#
echo "$0: no emacs binaries available. Install software package SUNWemacs-x, or SUNWemacs-nox" 1>&2

exit 1
