--- opengl.eselect.save 2010-07-28 18:33:43.566634518 +0200 +++ opengl.eselect.fixed 2010-07-28 19:09:31.656571205 +0200 @@ -134,6 +134,7 @@ set_new_implementation() { local gl_implem=${1} local avail_implems=$(get_implementations) local libdir + local gl_dir local gl_local local moduledir @@ -145,66 +146,70 @@ set_new_implementation() { fi echo -n "Switching to ${gl_implem} OpenGL interface..." - if [[ -f ${ENV_FILE} ]] ; then - rm -f "${ENV_FILE}" || die -q "Failed to remove ${ENV_FILE}" - fi + if [[ -f ${ENV_FILE} ]] ; then + rm -f "${ENV_FILE}" || die -q "Failed to remove ${ENV_FILE}" + fi - for libdir in $(list_libdirs); do - # Set libdir correctly to EROOT - [[ ${ROOT} != / ]] && libdir=${libdir//${ROOT}} - - # First make sure we have an opengl directory and this - # is a real lib dir, not a symlink - [[ -d ${PREFIX}/${libdir}/opengl && ! -h ${PREFIX}/${libdir} ]] || continue - - # Set moduledir - # only xorg module is used now can change to case when we add other - # implementations. - moduledir="xorg/modules" - - # Check if opengl implementation directory exists and - # use xorg-x11 as fallback (mesa) - # If even mesa is not around then simply die - if [[ -d "${PREFIX}/${libdir}/opengl/${gl_implem}" ]] ; then - gl_local="${gl_implem}" - else - if [[ -d "${PREFIX}/${libdir}/opengl/xorg-x11" ]]; then - gl_local="xorg-x11" - else - # bail out, no implementation around - die -q "No proper ${gl_implem} or xorg-x11 opengl implementation found" - fi + for libdir in $(list_libdirs); do + # Set libdir correctly to EROOT + [[ ${ROOT} != / ]] && libdir=${libdir//${ROOT}} + + # First make sure we have an opengl directory and this + # is a real lib dir, not a symlink + [[ -d ${PREFIX}/${libdir}/opengl && ! -h ${PREFIX}/${libdir} ]] || continue + + # Set moduledir + # only xorg module is used now can change to case when we add other + # implementations. + moduledir="xorg/modules" + + # Check if opengl implementation directory exists and + # use xorg-x11 as fallback (mesa) + # If even mesa is not around then simply die + if [[ -d "${PREFIX}/${libdir}/opengl/${gl_implem}" ]] ; then + gl_local="${gl_implem}" + gl_dir="${libdir}" + else + if [[ -d "${PREFIX}/${libdir}/opengl/xorg-x11" ]]; then + gl_local="xorg-x11" + gl_dir="${libdir}" fi + fi + done + + if [[ ! -n "${gl_dir}" ]] ; then + # bail out, no implementation around + die -q "No proper ${gl_implem} or xorg-x11 opengl implementation found" + fi + + setup_lib_symlinks \ + "${PREFIX}/${gl_dir}/opengl/${gl_local}/lib" \ + "${DST_PREFIX}/${gl_dir}" + + # check if the implementation has TLS libs around + # and install those if around + [[ -e ${PREFIX}/${gl_dir}/opengl/${gl_local}/lib/tls ]] && \ + setup_lib_symlinks \ + "${PREFIX}/${gl_dir}/opengl/${gl_local}/lib/tls" \ + "${DST_PREFIX}/${gl_dir}/tls" + + setup_extensions_symlinks \ + "${PREFIX}/${gl_dir}/opengl/${gl_local}/extensions" \ + "${DST_PREFIX}/${gl_dir}/${moduledir}/extensions" + + setup_includes_symlinks \ + "${DST_PREFIX}/include/GL" \ + "${PREFIX}/${gl_dir}/opengl/${gl_implem}/include/" \ + "${PREFIX}/${gl_dir}/opengl/global/include/" \ + "${PREFIX}/${gl_dir}/opengl/xorg-x11/include/" - setup_lib_symlinks \ - "${PREFIX}/${libdir}/opengl/${gl_local}/lib" \ - "${DST_PREFIX}/${libdir}" - - # check if the implementation has TLS libs around - # and install those if around - [[ -e ${PREFIX}/${libdir}/opengl/${gl_local}/lib/tls ]] && \ - setup_lib_symlinks \ - "${PREFIX}/${libdir}/opengl/${gl_local}/lib/tls" \ - "${DST_PREFIX}/${libdir}/tls" - - setup_extensions_symlinks \ - "${PREFIX}/${libdir}/opengl/${gl_local}/extensions" \ - "${DST_PREFIX}/${libdir}/${moduledir}/extensions" - - setup_includes_symlinks \ - "${DST_PREFIX}/include/GL" \ - "${PREFIX}/${libdir}/opengl/${gl_implem}/include/" \ - "${PREFIX}/${libdir}/opengl/global/include/" \ - "${PREFIX}/${libdir}/opengl/xorg-x11/include/" - - # Setup the $LDPATH - ldpath="${ldpath:+${ldpath}:}${PREFIX}/${libdir}/opengl/${gl_local}/lib" - done + # Setup the $LDPATH + ldpath="${ldpath:+${ldpath}:}${PREFIX}/${gl_dir}/opengl/${gl_local}/lib" - store_config ${ENV_FILE} LDPATH "${ldpath}" - store_config ${ENV_FILE} OPENGL_PROFILE "${gl_implem}" + store_config ${ENV_FILE} LDPATH "${ldpath}" + store_config ${ENV_FILE} OPENGL_PROFILE "${gl_implem}" - do_action env update &> /dev/null + do_action env update &> /dev/null echo " done" }