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 618 by niro, Wed Nov 14 18:15:35 2007 UTC trunk/opengl-update/opengl-update.in revision 2003 by niro, Mon Dec 31 15:14:19 2012 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.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>
# 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[EGL]="eglext.h egl.h eglmesaext.h eglplatform.h"
337   # It is preferable currently to use the standard glext.h file   headers[KHR]="khrplatform.h"
338   # however if an OpenGL provider must use a self produced glext.h   headers[VG]="openvg.h vgext.h vgplatform.h vgu.h"
339   # then it should be installed to ${GL_IMPLEM}/include and the user   for incl_dir in EGL GL GLES GLES2 KHR VG
340   # can add the --impl-headers option to select it.   do
341     mkdir -p ${DST_PREFIX}/include/${incl_dir}
342     pushd ${DST_PREFIX}/include/${incl_dir} &> /dev/null
343     for file in ${headers[${incl_dir}]}
344     do
345     # IMPORTANT
346     # It is preferable currently to use the standard glext.h file
347     # however if an OpenGL provider must use a self produced glext.h
348     # then it should be installed to ${GL_IMPLEM}/include and the user
349     # can add the --impl-headers option to select it.
350     if [[ ${USE_PROFILE_HEADERS} = yes ]]
351     then
352     # Check the profile first.
353     if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]]
354     then
355     [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
356     ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file}
357     fi
358     continue
359     fi
360    
361   if [[ ${USE_PROFILE_HEADERS} = yes ]]   if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} ]]
362   then   then
363   # Check the profile first.   [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
364   if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]]   ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file}
365     elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]]
366     then
367     [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
368     ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file}
369     elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} ]]
370   then   then
371   [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}   [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file}
372   ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file}   ln -s ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file}
373   fi   fi
374   continue   done
375   fi   popd &> /dev/null
376     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  
377    
378   # Setup the $LDPATH   # Setup the $LDPATH
379   ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib"   ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib"
380    
381   done   done
382    
383   echo "LDPATH=\"${ldpath}\"" > ${ENV_D}   # put only one LDPATH per line!
384     local i
385     for i in $(echo ${ldpath} | sed "s:\::\ :g")
386     do
387     echo "LDPATH=\"${i}\"" >> ${ENV_D}
388     done
389   echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D}   echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D}
390    
391   env-rebuild   env-rebuild
# Line 385  DST_PREFIX="/usr" Line 403  DST_PREFIX="/usr"
403  AVAIL_IMPLEMS=$(get_implementations)  AVAIL_IMPLEMS=$(get_implementations)
404  CURRENT_GL_IMPLEM=$(get_current_implem)  CURRENT_GL_IMPLEM=$(get_current_implem)
405  USE_PROFILE_HEADERS="no"  USE_PROFILE_HEADERS="no"
406  VERSION="2.2.4"  VERSION="@@VERSION@@"
407    
408  parse_options ${@}  parse_options ${@}
409    
# Line 401  case ${ACTION} in Line 419  case ${ACTION} in
419   ;;   ;;
420    
421   old-implementation)   old-implementation)
422   set-new-implementation ${CURRENT_GL_IMPLEM}   set_new_implementation ${CURRENT_GL_IMPLEM}
423   exit $?   exit $?
424   ;;   ;;
425    
426   set-implementation)   set-implementation)
427   if [[ -n ${NEW_GL_IMPLEM} ]]   if [[ -n ${NEW_GL_IMPLEM} ]]
428   then   then
429   set-new-implementation ${NEW_GL_IMPLEM}   set_new_implementation ${NEW_GL_IMPLEM}
430   exit $?   exit $?
431   else   else
432   print_usage   print_usage

Legend:
Removed from v.618  
changed lines
  Added in v.2003