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.7 2007-11-14 18:45:26 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 |
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 |
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 |
headers[GL]="gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h" |
329 |
pushd ${DST_PREFIX}/include/GL &> /dev/null |
headers[GLES]="egl.h gl_extensions.h glext.h gl.h glplatform.h" |
330 |
for file in gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h |
headers[GLES2]="gl2ext.h gl2.h gl2platform.h" |
331 |
do |
headers[EGL]="eglext.h egl.h eglplatform.h" |
332 |
# IMPORTANT |
headers[KHR]="khrplatform.h" |
333 |
# It is preferable currently to use the standard glext.h file |
headers[VG]="openvg.h vgext.h vgplatform.h vgu.h" |
334 |
# however if an OpenGL provider must use a self produced glext.h |
for incl_dir in EGL GL GLES GLES2 KHR VG |
335 |
# then it should be installed to ${GL_IMPLEM}/include and the user |
do |
336 |
# can add the --impl-headers option to select it. |
mkdir -p ${DST_PREFIX}/include/${incl_dir} |
337 |
|
pushd ${DST_PREFIX}/include/${incl_dir} &> /dev/null |
338 |
|
for file in ${headers[${incl_dir}]} |
339 |
|
do |
340 |
|
# IMPORTANT |
341 |
|
# It is preferable currently to use the standard glext.h file |
342 |
|
# however if an OpenGL provider must use a self produced glext.h |
343 |
|
# then it should be installed to ${GL_IMPLEM}/include and the user |
344 |
|
# can add the --impl-headers option to select it. |
345 |
|
if [[ ${USE_PROFILE_HEADERS} = yes ]] |
346 |
|
then |
347 |
|
# Check the profile first. |
348 |
|
if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]] |
349 |
|
then |
350 |
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
351 |
|
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} |
352 |
|
fi |
353 |
|
continue |
354 |
|
fi |
355 |
|
|
356 |
if [[ ${USE_PROFILE_HEADERS} = yes ]] |
if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} ]] |
357 |
then |
then |
358 |
# Check the profile first. |
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
359 |
if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]] |
ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} |
360 |
|
elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]] |
361 |
|
then |
362 |
|
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
363 |
|
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} |
364 |
|
elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} ]] |
365 |
then |
then |
366 |
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
[[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} |
367 |
ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} |
ln -s ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} |
368 |
fi |
fi |
369 |
continue |
done |
370 |
fi |
popd &> /dev/null |
371 |
|
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 |
|
372 |
|
|
373 |
# Setup the $LDPATH |
# Setup the $LDPATH |
374 |
ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib" |
ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib" |