--- trunk/opengl-update/opengl-update.sh 2007/11/14 18:15:35 618 +++ trunk/opengl-update/opengl-update.in 2012/12/31 15:14:19 2003 @@ -1,7 +1,7 @@ #!/bin/bash # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $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 $ # Author: Martin Schlemmer # Further modifications by Donnie Berkholz # Further modifications based off submissions to bug #54984 @@ -11,8 +11,6 @@ # # -. /etc/init.d/functions - hasq() { local x @@ -67,8 +65,8 @@ for dir in ${PREFIX}/lib{,32,64}/opengl/* do if [[ -d ${dir} ]] && - [[ ${dir##*/} != global ]] - && ! hasq ${dir##*/} ${implems} + [[ ${dir##*/} != global ]] && + ! hasq ${dir##*/} ${implems} then implems=${implems:+${implems} }${dir##*/} fi @@ -102,11 +100,13 @@ Usage: ${0##*/} [] Set the opengl implementation. Valid options: + --help|-h|-?: Prints this help. + --version: Shows the version of this utility. --use-old: If an implementation is already set, use that one. --prefix=: Set the source prefix (default: /usr) --dst-prefix=: Set the destination prefix (default: /usr) --impl-headers: Use headers provided by this implementation to - override golbal ones provided by opengl-update. + override global ones provided by opengl-update. Usage: ${0##*/} --get-implementation Print the current implementaion @@ -197,7 +197,7 @@ done } -set-new-implementation() +set_new_implementation() { local GL_IMPLEM=${1} local GL_LOCAL @@ -227,7 +227,7 @@ [[ -d ${PREFIX}/${LIBDIR}/opengl ]] || continue else [[ -d ${PREFIX}/${LIBDIR}/opengl ]] && - ! -h ${PREFIX}/${LIBDIR} ]] || continue + [[ ! -h ${PREFIX}/${LIBDIR} ]] || continue fi # Fallback on xorg if we don't have this implementation for this LIBDIR. @@ -241,15 +241,17 @@ mkdir -p ${DST_PREFIX}/${LIBDIR} pushd ${DST_PREFIX}/${LIBDIR} &> /dev/null # First remove old symlinks - for file in libGL{,core}.{a,so,la} + for file in lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la} do + # exclude libGLU + [[ ${file} = libGLU.so ]] && continue [[ -h ${file} ]] && rm -f ${file} done # Note that we don't do .so*, just .so on purpose. The # loader knows to look in the profile dir, and the # linked just needs the .so - 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} do [[ -f ${file} ]] || continue [[ -f ${file##*/} ]] && rm -f ${file##*/} @@ -269,12 +271,14 @@ mkdir -p ${DST_PREFIX}/${LIBDIR}/tls pushd ${DST_PREFIX}/${LIBDIR}/tls &> /dev/null # First remove old symlinks - for file in libGL{,core}.{a,so,la} + for file in lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a,la} do + # exclude libGLU + [[ ${file} = libGLU.so ]] && continue [[ -h ${file} ]] && rm -f ${file} done - 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} do [[ -f ${file} ]] || continue [[ -f ${file##*/} ]] && rm -f ${file##*/} @@ -303,7 +307,7 @@ mkdir -p ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions pushd ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions &> /dev/null # First remove old symlinks - for file in libglx.so libglx.a + for file in lib{wfb,glx,dri,dri2}.{so,dylib,a} do [[ -h ${file} ]] && rm -f ${file} done @@ -325,49 +329,63 @@ fi # Setup the includes - mkdir -p ${DST_PREFIX}/include/GL - pushd ${DST_PREFIX}/include/GL &> /dev/null - for file in gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h - do - # IMPORTANT - # It is preferable currently to use the standard glext.h file - # however if an OpenGL provider must use a self produced glext.h - # then it should be installed to ${GL_IMPLEM}/include and the user - # can add the --impl-headers option to select it. + local -A headers + headers[GL]="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" + headers[GLES2]="gl2ext.h gl2.h gl2platform.h" + headers[EGL]="eglext.h egl.h eglmesaext.h eglplatform.h" + headers[KHR]="khrplatform.h" + headers[VG]="openvg.h vgext.h vgplatform.h vgu.h" + for incl_dir in EGL GL GLES GLES2 KHR VG + do + mkdir -p ${DST_PREFIX}/include/${incl_dir} + pushd ${DST_PREFIX}/include/${incl_dir} &> /dev/null + for file in ${headers[${incl_dir}]} + do + # IMPORTANT + # It is preferable currently to use the standard glext.h file + # however if an OpenGL provider must use a self produced glext.h + # then it should be installed to ${GL_IMPLEM}/include and the user + # can add the --impl-headers option to select it. + if [[ ${USE_PROFILE_HEADERS} = yes ]] + then + # Check the profile first. + if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]] + then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} + fi + continue + fi - if [[ ${USE_PROFILE_HEADERS} = yes ]] - then - # Check the profile first. - if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]] + if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} ]] + then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${incl_dir}/${file} + elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} ]] + then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${incl_dir}/${file} + elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} ]] then [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} - ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/xorg/include/${incl_dir}/${file} fi - continue - fi - - 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 + done + popd &> /dev/null + done # Setup the $LDPATH ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib" done - echo "LDPATH=\"${ldpath}\"" > ${ENV_D} + # put only one LDPATH per line! + local i + for i in $(echo ${ldpath} | sed "s:\::\ :g") + do + echo "LDPATH=\"${i}\"" >> ${ENV_D} + done echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D} env-rebuild @@ -385,7 +403,7 @@ AVAIL_IMPLEMS=$(get_implementations) CURRENT_GL_IMPLEM=$(get_current_implem) USE_PROFILE_HEADERS="no" -VERSION="2.2.4" +VERSION="@@VERSION@@" parse_options ${@} @@ -401,14 +419,14 @@ ;; old-implementation) - set-new-implementation ${CURRENT_GL_IMPLEM} + set_new_implementation ${CURRENT_GL_IMPLEM} exit $? ;; set-implementation) if [[ -n ${NEW_GL_IMPLEM} ]] then - set-new-implementation ${NEW_GL_IMPLEM} + set_new_implementation ${NEW_GL_IMPLEM} exit $? else print_usage