summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'x11-base/opengl-update/files/opengl-update-3.0.0')
-rwxr-xr-xx11-base/opengl-update/files/opengl-update-3.0.0144
1 files changed, 144 insertions, 0 deletions
diff --git a/x11-base/opengl-update/files/opengl-update-3.0.0 b/x11-base/opengl-update/files/opengl-update-3.0.0
new file mode 100755
index 000000000000..bf9c0ef546e7
--- /dev/null
+++ b/x11-base/opengl-update/files/opengl-update-3.0.0
@@ -0,0 +1,144 @@
+#!/bin/bash
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-base/opengl-update/files/opengl-update-3.0.0,v 1.1 2005/08/13 07:42:36 eradicator Exp $
+# Author: Martin Schlemmer <azarah@gentoo.org>
+# Further modifications by Donnie Berkholz <spyderous@gentoo.org>
+# Further modifications based off submissions to bug #54984 <cyfred@gentoo.org>
+# Further modifications by Jeremy Huddleston <eradicator@gentoo.org>
+
+
+print_usage() {
+ cat << FOO
+Usage: ${0##*/} [<options>] <GL implementation>
+ Set the opengl implementation.
+ Valid options:
+ --use-old: If an implementation is already set, use that one.
+ --prefix=<val>: Set the source prefix (default: /usr)
+ --dst-prefix=<val>: Set the destination prefix (default: /usr)
+ --impl-headers: Use headers provided by this implementation to
+ override golbal ones provided by opengl-update.
+
+Usage: ${0##*/} --get-implementation
+ Print the current implementaion
+
+Notes:
+ --impl-headers was default in <opengl-update-2.2.
+
+Examples:
+ ${0##*/} xorg-x11
+ This will setup things to use libGL.so from X.org.
+
+ ${0##*/} nvidia
+ This will setup things to use libGL.so from the nVidia drivers.
+
+WARNING: opengl-update is deprecated and is just a frontend to the opengl
+ eselect module. A future version will drop support for the
+ opengl-update command. Please see 'eselect opengl help'
+
+FOO
+}
+
+get_implementations() {
+ local implems
+ for dir in ${PREFIX}/lib{,32,64}/opengl/*; do
+ if [[ -d "${dir}" && ${dir##*/} != "global" ]] && ! hasq ${dir##*/} ${implems}; then
+ implems=${implems:+${implems} }${dir##*/}
+ fi
+ done
+ echo ${implems}
+}
+
+parse_options() {
+ local opt
+ while [[ ${#} -gt 0 ]]; do
+ opt=${1}
+ shift
+ case ${opt} in
+ --use-old)
+ if [[ -n "${ACTION}" ]]; then
+ ACTION="error"
+ eerror "Invalid usage."
+ else
+ if [[ -n "${CURRENT_GL_IMPLEM}" ]] && hasq ${CURRENT_GL_IMPLEM} ${AVAIL_IMPLEMS}; then
+ ACTION="old-implementation"
+ fi
+ fi
+ ;;
+ --get-implementation)
+ if [[ -n "${ACTION}" ]]; then
+ ACTION="error"
+ eerror "Invalid usage."
+ else
+ ACTION="get-implementation"
+ fi
+ ;;
+ --prefix=*)
+ PREFIX=${opt#*=}
+ AVAIL_IMPLEMS=$(get_implementations)
+ ;;
+ --dst-prefix=*)
+ DST_PREFIX=${opt#*=}
+ ;;
+ --impl-headers)
+ USE_PROFILE_HEADERS="yes"
+ ;;
+ --help|-h|-?)
+ ACION="usage"
+ ;;
+ *)
+ if hasq ${opt} ${AVAIL_IMPLEMS}; then
+ if [[ "${ACTION}" != "old-implementation" ]]; then
+ if [[ -n "${ACTION}" ]]; then
+ ACTION="error"
+ eerror "Invalid usage."
+ else
+ ACTION="set-implementation"
+ NEW_GL_IMPLEM="${opt}"
+ fi
+ fi
+ else
+ eerror "Unrecognized option: ${opt}"
+ ACTION="error"
+ fi
+ ;;
+ esac
+ done
+}
+
+## START PROGRAM ##
+
+NEW_GL_IMPLEM=""
+ACTION=""
+PREFIX="/usr"
+DST_PREFIX="/usr"
+AVAIL_IMPLEMS=$(get_implementations)
+CURRENT_GL_IMPLEM=$(eselect opengl show)
+USE_PROFILE_HEADERS="no"
+
+parse_options ${@}
+
+case ${ACTION} in
+ get-implementation)
+ eselect opengl show
+ ;;
+ old-implementation)
+ eselect opengl set --use-old
+ exit $?
+ ;;
+ set-implementation)
+ local myconf = "set ${NEW_GL_IMPLEM} --prefix=\"${PREFIX}\" --dst-prefix=\"${DST_PREFIX}\""
+ if [[ ${USE_PROFILE_HEADERS} == "yes" ]] ; then
+ myconf="${myconf} --impl-headers"
+ fi
+ eselect opengl ${myconf}
+ ;;
+ usage)
+ print_usage
+ exit 0
+ ;;
+ *)
+ print_usage
+ exit 1
+ ;;
+esac