Magellan Linux

Diff of /tags/openglupdate-2_3_14/opengl-update.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/opengl-update/opengl-update.sh revision 619 by niro, Wed Nov 14 18:16:28 2007 UTC trunk/opengl-update/opengl-update.in revision 2069 by niro, Fri Mar 8 14:09:44 2013 UTC
# Line 1  Line 1 
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.4 2007-11-14 18:16:28 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>
# Line 11  Line 11 
11  # <niro@magellan-linux.de>  # <niro@magellan-linux.de>
12  #  #
13    
 . /etc/init.d/functions  
   
14  hasq()  hasq()
15  {  {
16   local x   local x
# Line 67  get_implementations() Line 65  get_implementations()
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
# Line 102  print_usage() Line 100  print_usage()
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
# Line 197  parse_options() Line 197  parse_options()
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
# Line 227  set-new-implementation() Line 227  set-new-implementation()
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.
# Line 241  set-new-implementation() Line 241  set-new-implementation()
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     # exclude libGLU
247     [[ ${file} = libGLU.so ]] && continue
248   [[ -h ${file} ]] && rm -f ${file}   [[ -h ${file} ]] && rm -f ${file}
249   done   done
250    
251   # Note that we don't do .so*, just .so on purpose.  The   # Note that we don't do .so*, just .so on purpose.  The
252   # loader knows to look in the profile dir, and the   # loader knows to look in the profile dir, and the
253   # linked just needs the .so   # linked just needs the .so
254   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}
255   do   do
256   [[ -f ${file} ]] || continue   [[ -f ${file} ]] || continue
257   [[ -f ${file##*/} ]] && rm -f ${file##*/}   [[ -f ${file##*/} ]] && rm -f ${file##*/}
# Line 269  set-new-implementation() Line 271  set-new-implementation()
271   mkdir -p ${DST_PREFIX}/${LIBDIR}/tls   mkdir -p ${DST_PREFIX}/${LIBDIR}/tls
272   pushd ${DST_PREFIX}/${LIBDIR}/tls &> /dev/null   pushd ${DST_PREFIX}/${LIBDIR}/tls &> /dev/null
273   # First remove old symlinks   # First remove old symlinks
274   for file in libGL{,core}.{a,so,la}   for file in lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la}
275   do   do
276     # exclude libGLU
277     [[ ${file} = libGLU.so ]] && continue
278   [[ -h ${file} ]] && rm -f ${file}   [[ -h ${file} ]] && rm -f ${file}
279   done   done
280    
281   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}
282   do   do
283   [[ -f ${file} ]] || continue   [[ -f ${file} ]] || continue
284   [[ -f ${file##*/} ]] && rm -f ${file##*/}   [[ -f ${file##*/} ]] && rm -f ${file##*/}
# Line 303  set-new-implementation() Line 307  set-new-implementation()
307   mkdir -p ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions   mkdir -p ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions
308   pushd ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions &> /dev/null   pushd ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions &> /dev/null
309   # First remove old symlinks   # First remove old symlinks
310   for file in libglx.so libglx.a   for file in lib{wfb,glx,dri,dri2}.{so,dylib,a}
311   do   do
312   [[ -h ${file} ]] && rm -f ${file}   [[ -h ${file} ]] && rm -f ${file}
313   done   done
# Line 325  set-new-implementation() Line 329  set-new-implementation()
329   fi   fi
330    
331   # Setup the includes   # Setup the includes
332   mkdir -p ${DST_PREFIX}/include/GL   local -A headers
333   pushd ${DST_PREFIX}/include/GL &> /dev/null   headers[GL]="gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h"
334   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"
335   do   headers[GLES2]="gl2ext.h gl2.h gl2platform.h"
336   # IMPORTANT   headers[GLES3]="gl3ext.h gl3.h gl3platform.h"
337   # It is preferable currently to use the standard glext.h file   headers[EGL]="eglext.h egl.h eglmesaext.h eglplatform.h"
338   # however if an OpenGL provider must use a self produced glext.h   headers[KHR]="khrplatform.h"
339   # then it should be installed to ${GL_IMPLEM}/include and the user   headers[VG]="openvg.h vgext.h vgplatform.h vgu.h"
340   # can add the --impl-headers option to select it.   for incl_dir in EGL GL GLES GLES2 GLES3 KHR VG
341     do
342     mkdir -p ${DST_PREFIX}/include/${incl_dir}
343     pushd ${DST_PREFIX}/include/${incl_dir} &> /dev/null
344     for file in ${headers[${incl_dir}]}
345     do
346     # IMPORTANT
347     # It is preferable currently to use the standard glext.h file
348     # however if an OpenGL provider must use a self produced glext.h
349     # then it should be installed to ${GL_IMPLEM}/include and the user
350     # can add the --impl-headers option to select it.
351     if [[ ${USE_PROFILE_HEADERS} = yes ]]
352     then
353     # Check the profile first.
354     if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]]
355     then
356     [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
357     ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file}
358     fi
359     continue
360     fi
361    
362   if [[ ${USE_PROFILE_HEADERS} = yes ]]   if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} ]]
363   then   then
364   # Check the profile first.   [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
365   if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]]   ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file}
366     elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]]
367     then
368     [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
369     ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file}
370     elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} ]]
371   then   then
372   [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}   [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
373   ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file}   ln -s ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file}
374   fi   fi
375   continue   done
376   fi   popd &> /dev/null
377     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  
378    
379   # Setup the $LDPATH   # Setup the $LDPATH
380   ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib"   ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib"
381    
382   done   done
383    
384   echo "LDPATH=\"${ldpath}\"" > ${ENV_D}   # put only one LDPATH per line!
385     local i
386     for i in $(echo ${ldpath} | sed "s:\::\ :g")
387     do
388     echo "LDPATH=\"${i}\"" >> ${ENV_D}
389     done
390   echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D}   echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D}
391    
392   env-rebuild   env-rebuild
# Line 401  case ${ACTION} in Line 420  case ${ACTION} in
420   ;;   ;;
421    
422   old-implementation)   old-implementation)
423   set-new-implementation ${CURRENT_GL_IMPLEM}   set_new_implementation ${CURRENT_GL_IMPLEM}
424   exit $?   exit $?
425   ;;   ;;
426    
427   set-implementation)   set-implementation)
428   if [[ -n ${NEW_GL_IMPLEM} ]]   if [[ -n ${NEW_GL_IMPLEM} ]]
429   then   then
430   set-new-implementation ${NEW_GL_IMPLEM}   set_new_implementation ${NEW_GL_IMPLEM}
431   exit $?   exit $?
432   else   else
433   print_usage   print_usage

Legend:
Removed from v.619  
changed lines
  Added in v.2069