1 |
#!/bin/bash |
#!/bin/bash |
2 |
# Copyright 1999-2004 Gentoo Foundation |
# Copyright 1999-2004 Gentoo Foundation |
3 |
# Distributed under the terms of the GNU General Public License v2 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/opengl-update/opengl-update.sh,v 1.3 2007-11-14 18:15:35 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/opengl-update/opengl-update.sh,v 1.10 2007-11-14 19:19:16 niro Exp $ |
5 |
# Author: Martin Schlemmer <azarah@gentoo.org> |
# Author: Martin Schlemmer <azarah@gentoo.org> |
6 |
# Further modifications by Donnie Berkholz <spyderous@gentoo.org> |
# Further modifications by Donnie Berkholz <spyderous@gentoo.org> |
7 |
# Further modifications based off submissions to bug #54984 <cyfred@gentoo.org> |
# Further modifications based off submissions to bug #54984 <cyfred@gentoo.org> |
11 |
# <niro@magellan-linux.de> |
# <niro@magellan-linux.de> |
12 |
# |
# |
13 |
|
|
|
. /etc/init.d/functions |
|
|
|
|
14 |
hasq() |
hasq() |
15 |
{ |
{ |
16 |
local x |
local x |
65 |
for dir in ${PREFIX}/lib{,32,64}/opengl/* |
for dir in ${PREFIX}/lib{,32,64}/opengl/* |
66 |
do |
do |
67 |
if [[ -d ${dir} ]] && |
if [[ -d ${dir} ]] && |
68 |
[[ ${dir##*/} != global ]] |
[[ ${dir##*/} != global ]] && |
69 |
&& ! hasq ${dir##*/} ${implems} |
! hasq ${dir##*/} ${implems} |
70 |
then |
then |
71 |
implems=${implems:+${implems} }${dir##*/} |
implems=${implems:+${implems} }${dir##*/} |
72 |
fi |
fi |
100 |
Usage: ${0##*/} [<options>] <GL implementation> |
Usage: ${0##*/} [<options>] <GL implementation> |
101 |
Set the opengl implementation. |
Set the opengl implementation. |
102 |
Valid options: |
Valid options: |
103 |
|
--help|-h|-?: Prints this help. |
104 |
|
--version: Shows the version of this utility. |
105 |
--use-old: If an implementation is already set, use that one. |
--use-old: If an implementation is already set, use that one. |
106 |
--prefix=<val>: Set the source prefix (default: /usr) |
--prefix=<val>: Set the source prefix (default: /usr) |
107 |
--dst-prefix=<val>: Set the destination prefix (default: /usr) |
--dst-prefix=<val>: Set the destination prefix (default: /usr) |
108 |
--impl-headers: Use headers provided by this implementation to |
--impl-headers: Use headers provided by this implementation to |
109 |
override golbal ones provided by opengl-update. |
override global ones provided by opengl-update. |
110 |
|
|
111 |
Usage: ${0##*/} --get-implementation |
Usage: ${0##*/} --get-implementation |
112 |
Print the current implementaion |
Print the current implementaion |
197 |
done |
done |
198 |
} |
} |
199 |
|
|
200 |
set-new-implementation() |
set_new_implementation() |
201 |
{ |
{ |
202 |
local GL_IMPLEM=${1} |
local GL_IMPLEM=${1} |
203 |
local GL_LOCAL |
local GL_LOCAL |
227 |
[[ -d ${PREFIX}/${LIBDIR}/opengl ]] || continue |
[[ -d ${PREFIX}/${LIBDIR}/opengl ]] || continue |
228 |
else |
else |
229 |
[[ -d ${PREFIX}/${LIBDIR}/opengl ]] && |
[[ -d ${PREFIX}/${LIBDIR}/opengl ]] && |
230 |
! -h ${PREFIX}/${LIBDIR} ]] || continue |
[[ ! -h ${PREFIX}/${LIBDIR} ]] || continue |
231 |
fi |
fi |
232 |
|
|
233 |
# Fallback on xorg if we don't have this implementation for this LIBDIR. |
# Fallback on xorg if we don't have this implementation for this LIBDIR. |
241 |
mkdir -p ${DST_PREFIX}/${LIBDIR} |
mkdir -p ${DST_PREFIX}/${LIBDIR} |
242 |
pushd ${DST_PREFIX}/${LIBDIR} &> /dev/null |
pushd ${DST_PREFIX}/${LIBDIR} &> /dev/null |
243 |
# First remove old symlinks |
# First remove old symlinks |
244 |
for file in libGL{,core}.{a,so,la} |
for file in lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la} |
245 |
do |
do |
246 |
[[ -h ${file} ]] && rm -f ${file} |
[[ -h ${file} ]] && rm -f ${file} |
247 |
done |
done |
249 |
# Note that we don't do .so*, just .so on purpose. The |
# Note that we don't do .so*, just .so on purpose. The |
250 |
# loader knows to look in the profile dir, and the |
# loader knows to look in the profile dir, and the |
251 |
# linked just needs the .so |
# linked just needs the .so |
252 |
for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL{,core}.{so,a,la} |
for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib/lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la} |
253 |
do |
do |
254 |
[[ -f ${file} ]] || continue |
[[ -f ${file} ]] || continue |
255 |
[[ -f ${file##*/} ]] && rm -f ${file##*/} |
[[ -f ${file##*/} ]] && rm -f ${file##*/} |
269 |
mkdir -p ${DST_PREFIX}/${LIBDIR}/tls |
mkdir -p ${DST_PREFIX}/${LIBDIR}/tls |
270 |
pushd ${DST_PREFIX}/${LIBDIR}/tls &> /dev/null |
pushd ${DST_PREFIX}/${LIBDIR}/tls &> /dev/null |
271 |
# First remove old symlinks |
# First remove old symlinks |
272 |
for file in libGL{,core}.{a,so,la} |
for file in lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la} |
273 |
do |
do |
274 |
[[ -h ${file} ]] && rm -f ${file} |
[[ -h ${file} ]] && rm -f ${file} |
275 |
done |
done |
276 |
|
|
277 |
for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libGL{,core}.{so,a,la} |
for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la} |
278 |
do |
do |
279 |
[[ -f ${file} ]] || continue |
[[ -f ${file} ]] || continue |
280 |
[[ -f ${file##*/} ]] && rm -f ${file##*/} |
[[ -f ${file##*/} ]] && rm -f ${file##*/} |
303 |
mkdir -p ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions |
mkdir -p ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions |
304 |
pushd ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions &> /dev/null |
pushd ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions &> /dev/null |
305 |
# First remove old symlinks |
# First remove old symlinks |
306 |
for file in libglx.so libglx.a |
for file in lib{wfb,glx,dri,dri2}.{so,dylib,a} |
307 |
do |
do |
308 |
[[ -h ${file} ]] && rm -f ${file} |
[[ -h ${file} ]] && rm -f ${file} |
309 |
done |
done |
325 |
fi |
fi |
326 |
|
|
327 |
# Setup the includes |
# Setup the includes |
328 |
mkdir -p ${DST_PREFIX}/include/GL |
local -A headers |
329 |
pushd ${DST_PREFIX}/include/GL &> /dev/null |
headers[GL]="gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h glu.h glu_mangle.h" |
330 |
for file in gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h |
headers[GLES]="egl.h gl_extensions.h glext.h gl.h glplatform.h" |
331 |
do |
headers[GLES2]="gl2ext.h gl2.h gl2platform.h" |
332 |
# IMPORTANT |
headers[EGL]="eglext.h egl.h eglmesaext.h eglplatform.h" |
333 |
# It is preferable currently to use the standard glext.h file |
headers[KHR]="khrplatform.h" |
334 |
# however if an OpenGL provider must use a self produced glext.h |
headers[VG]="openvg.h vgext.h vgplatform.h vgu.h" |
335 |
# then it should be installed to ${GL_IMPLEM}/include and the user |
for incl_dir in EGL GL GLES GLES2 KHR VG |
336 |
# can add the --impl-headers option to select it. |
do |
337 |
|
mkdir -p ${DST_PREFIX}/include/${incl_dir} |
338 |
|
pushd ${DST_PREFIX}/include/${incl_dir} &> /dev/null |
339 |
|
for file in ${headers[${incl_dir}]} |
340 |
|
do |
341 |
|
# IMPORTANT |
342 |
|
# It is preferable currently to use the standard glext.h file |
343 |
|
# however if an OpenGL provider must use a self produced glext.h |
344 |
|
# then it should be installed to ${GL_IMPLEM}/include and the user |
345 |
|
# can add the --impl-headers option to select it. |
346 |
|
if [[ ${USE_PROFILE_HEADERS} = yes ]] |
347 |
|
then |
348 |
|
# Check the profile first. |
349 |
|
if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]] |
350 |
|
then |
351 |
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
352 |
|
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} |
353 |
|
fi |
354 |
|
continue |
355 |
|
fi |
356 |
|
|
357 |
if [[ ${USE_PROFILE_HEADERS} = yes ]] |
if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} ]] |
358 |
then |
then |
359 |
# Check the profile first. |
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
360 |
if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]] |
ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} |
361 |
|
elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]] |
362 |
|
then |
363 |
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
364 |
|
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} |
365 |
|
elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} ]] |
366 |
then |
then |
367 |
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
368 |
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} |
ln -s ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} |
369 |
fi |
fi |
370 |
continue |
done |
371 |
fi |
popd &> /dev/null |
372 |
|
done |
|
if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${file} ]] |
|
|
then |
|
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
|
|
ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${file} |
|
|
elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]] |
|
|
then |
|
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
|
|
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} |
|
|
elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg/include/${file} ]] |
|
|
then |
|
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
|
|
ln -s ${PREFIX}/${LIBDIR}/opengl/xorg/include/${file} |
|
|
fi |
|
|
done |
|
|
popd &> /dev/null |
|
373 |
|
|
374 |
# Setup the $LDPATH |
# Setup the $LDPATH |
375 |
ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib" |
ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib" |
376 |
|
|
377 |
done |
done |
378 |
|
|
379 |
echo "LDPATH=\"${ldpath}\"" > ${ENV_D} |
# put only one LDPATH per line! |
380 |
|
local i |
381 |
|
for i in $(echo ${ldpath} | sed "s:\::\ :g") |
382 |
|
do |
383 |
|
echo "LDPATH=\"${i}\"" >> ${ENV_D} |
384 |
|
done |
385 |
echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D} |
echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D} |
386 |
|
|
387 |
env-rebuild |
env-rebuild |
399 |
AVAIL_IMPLEMS=$(get_implementations) |
AVAIL_IMPLEMS=$(get_implementations) |
400 |
CURRENT_GL_IMPLEM=$(get_current_implem) |
CURRENT_GL_IMPLEM=$(get_current_implem) |
401 |
USE_PROFILE_HEADERS="no" |
USE_PROFILE_HEADERS="no" |
402 |
VERSION="2.2.4" |
VERSION="@@VERSION@@" |
403 |
|
|
404 |
parse_options ${@} |
parse_options ${@} |
405 |
|
|
415 |
;; |
;; |
416 |
|
|
417 |
old-implementation) |
old-implementation) |
418 |
set-new-implementation ${CURRENT_GL_IMPLEM} |
set_new_implementation ${CURRENT_GL_IMPLEM} |
419 |
exit $? |
exit $? |
420 |
;; |
;; |
421 |
|
|
422 |
set-implementation) |
set-implementation) |
423 |
if [[ -n ${NEW_GL_IMPLEM} ]] |
if [[ -n ${NEW_GL_IMPLEM} ]] |
424 |
then |
then |
425 |
set-new-implementation ${NEW_GL_IMPLEM} |
set_new_implementation ${NEW_GL_IMPLEM} |
426 |
exit $? |
exit $? |
427 |
else |
else |
428 |
print_usage |
print_usage |