Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 78475 | Differences between
and this patch

Collapse All | Expand All

(-)opengl-update-2.0_pre4 (-195 / +95 lines)
Lines 113-123 get_implem() { Link Here
113
	then
113
	then
114
		source /etc/env.d/09opengl
114
		source /etc/env.d/09opengl
115
		if [ -n "${LDPATH}" ]
115
		if [ -n "${LDPATH}" ]
116
		then
116
		then
117
			GL_IMPLEM="${LDPATH/:\*/}"
117
			GL_IMPLEM="${LDPATH%%:*}"
118
			GL_IMPLEM="${GL_IMPLEM/\/usr\/lib\/opengl\/}"
118
			GL_IMPLEM="${GL_IMPLEM##*opengl/}"
119
			GL_IMPLEM="${GL_IMPLEM/\/lib}"
119
			GL_IMPLEM="${GL_IMPLEM%/lib*}"
120
			unset LDPATH
120
			unset LDPATH
121
		fi
121
		fi
122
	fi
122
	fi
123
}
123
}
Lines 166-379 then Link Here
166
	usage
166
	usage
167
fi
167
fi
168
168
169
ebegin "Switching to ${GL_IMPLEM} OpenGL interface"
169
ebegin "Switching to ${GL_IMPLEM} OpenGL interface"
170
	rm -f /etc/env.d/09opengl &> /dev/null
170
171
171
	# Provide the right libnvidia-tls depending on ntpl or not
172
	LIBDIRS="lib lib32 lib64"
172
	if [ "${GL_IMPLEM}" = "nvidia" ]
173
	for LIBDIR in ${LIBDIRS}; do
173
	then
174
		[ -d "/usr/${LIBDIR}" ] || continue
174
		if [ -e /usr/lib/opengl/${GL_IMPLEM}/lib/tls ]
175
		# Provide the right libnvidia-tls depending on ntpl or not
176
		if [ "${GL_IMPLEM}" = "nvidia" ]
175
		then
177
		then
176
			rm -f /usr/lib/opengl/${GL_IMPLEM}/lib/tls
178
			if [ -e "/usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/tls" ]; then
177
		fi
179
				rm -f /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/tls
180
			fi
178
		
181
		
179
#		This was the nvidia approach but it seems to not work, new method
182
			if getconf GNU_LIBPTHREAD_VERSION | grep -i nptl; then
180
#		as suggested on various bug reports, #64927, #70545
183
				ln -sf /usr/${LIBDIR}/opengl/${GL_IMPLEM}/tls /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/tls
181
#		/usr/lib/misc/tls_test /usr/lib/misc/tls_test_dso.so 2>/dev/null
184
				ldpath="${ldpath:+${ldpath}:}/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls"
182
		getconf GNU_LIBPTHREAD_VERSION | grep -i nptl > /dev/null
183
		if [ ${?} = 0 ]
184
		then
185
			ln -sf /usr/lib/opengl/${GL_IMPLEM}/tls /usr/lib/opengl/${GL_IMPLEM}/lib/tls
186
			if [ -d /usr/lib32/opengl/${GL_IMPLEM} ]
187
			then
188
				ln -sf /usr/lib32/opengl/${GL_IMPLEM}/tls /usr/lib32/opengl/${GL_IMPLEM}/lib/tls
189
			fi
185
			fi
190
		fi
186
		fi
191
	fi
192
	
193
	# Setup the $LDPATH
194
	echo "LDPATH=/usr/lib/opengl/${GL_IMPLEM}/lib" > /etc/env.d/09opengl
195
	# Check if we need 32 bit compatibility
196
	if [ -d /usr/lib32/opengl/${GL_IMPLEM} ]
197
	then
198
		source /etc/env.d/09opengl
199
		echo "LDPATH=${LDPATH}:/usr/lib32/opengl/${GL_IMPLEM}/lib" > /etc/env.d/09opengl
200
		unset LDPATH
201
202
		# We also need to make TLS directories now aswell, make 32bit one here
203
		lib32="$(readlink /usr/lib32)"
204
		if [ -h ${lib32}/tls ]
205
		then
206
			rm -f ${lib32}/tls
207
		fi
208
		if [ ! -d ${lib32}/tls ]
209
		then
210
			mkdir -p ${lib32}/tls
211
		fi
212
			
213
	fi
214
187
215
	# System wide tls stuff
188
		# System wide tls stuff
216
	if [ -h /usr/lib/tls ]
189
		[ -h "/usr/${LIBDIR}/tls" ] && rm -f /usr/${LIBDIR}/tls
217
	then
190
		[ -d "/usr/${LIBDIR}/tls" ] || mkdir -p /usr/${LIBDIR}/tls
218
		rm -f /usr/lib/tls
219
	fi
220
	if [ ! -d /usr/lib/tls ] 
221
	then
222
		mkdir -p /usr/lib/tls
223
	fi
224
	
225
	/usr/sbin/env-update &>/dev/null
226
191
227
	LIBDIRS="lib lib32"
192
		# Fallback on xorg-x11 if we don't have this implementation for this LIBDIR.
228
	for LIBDIR in ${LIBDIRS}
193
		if [ ! -d /usr/${LIBDIR}/opengl/"${GL_IMPLEM}" ]
229
	do
230
		# If there is a 32 bit compatibility implementation we shall use it
231
		# Otherwise we want to have some compatibility GL, use xorg-x11.
232
		if [ "${LIBDIR}" = "lib32" ] && [ ! -d /usr/lib32/opengl/"${GL_IMPLEM}" ]
233
		then
194
		then
234
			GL_LOCAL="xorg-x11"
195
			GL_LOCAL="xorg-x11"
235
		else
196
		else
236
			GL_LOCAL="${GL_IMPLEM}"
197
			GL_LOCAL="${GL_IMPLEM}"
237
		fi
198
		fi
238
		
199
		
239
		#setup the /usr/lib/libGL.so symlink
200
		pushd /usr/${LIBDIR}
240
		if [ -e /usr/${LIBDIR}/libGL.so ]
201
			# First remove old symlinks
241
		then
202
			for file in libGL.so* libGLcore.so* libnvidia-tls.so* libMesaGL.so* tls/*; do
242
			rm -f /usr/${LIBDIR}/libGL.so
203
				rm -f ${file}
243
		fi
204
			done
244
		if [ -e /usr/${LIBDIR}/libGL.so.1 ]
205
245
		then
206
			# Note that we don't do .so*, just .so on purpose.  The
246
			rm -f /usr/${LIBDIR}/libGL.so.1
207
			# loaded knows to look in the profile dir, and the
247
		fi
208
			# linked just needs the .so
248
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL.so ]
209
			for file in opengl/${GL_LOCAL}/lib/*.{so,a,la}; do
249
		then
210
				[ -f "${file}" ] || continue
250
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL.so)"
211
				rm -f $(basename ${file})
251
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
212
				ln -s ${file}
252
				/usr/${LIBDIR}/libGL.so
213
253
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
214
				# Fix libtool archives (#48297)
254
				/usr/${LIBDIR}/libGL.so.1
215
				if [ "${file%.la}" != "${file}" ]; then
255
		fi
216
					sed -i "s:/usr/[^/]*/opengl/[^/]*/lib/:/usr/${LIBDIR}/:g" ${file}
256
217
				fi
257
		# Setup the /usr/lib/libGLcore.so symlink
218
			done
258
		if [ -e /usr/${LIBDIR}/libGLcore.so ]
219
259
		then
220
			ln -s opengl/${GL_LOCAL}/lib/libGL.so libMesaGL.so
260
			rm -f /usr/${LIBDIR}/libGLcore.so
221
		popd
261
		fi
222
262
		if [ -e /usr/${LIBDIR}/libGLcore.so.1 ]
223
		if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls" ]; then
263
		then
224
			pushd /usr/${LIBDIR}/tls
264
			rm -f /usr/${LIBDIR}/libGLcore.so.1
225
				for file in ../opengl/${GL_LOCAL}/lib/tls/*.{so,a,la}; do
265
		fi
226
					[ -f "${file}" ] || continue
266
		if [ -e /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/libGLcore.so ]
227
					rm -f $(basename ${file})
267
		then
228
					ln -s ${file}
268
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/libGLcore.so)"
229
				done
269
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
230
			popd
270
				/usr/${LIBDIR}/libGLcore.so
231
		fi
271
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
232
272
				/usr/${LIBDIR}/libGLcore.so.1
233
		if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/modules/extensions" ]; then
273
		fi
234
			mkdir -p /usr/${LIBDIR}/modules/extensions
274
235
			pushd /usr/${LIBDIR}/modules/extensions
275
		# Now setup the TLS library links
236
				for file in ../../opengl/${GL_LOCAL}/lib/extensions/*.{so,a,la}; do
276
		if [ -e /usr/${LIBDIR}/libnvidia-tls.so ]
237
					[ -f "${file}" ] || continue
277
		then
238
					rm -f $(basename ${file})
278
			rm -f /usr/${LIBDIR}/libnvidia-tls.so
239
					ln -s ${file}
279
		fi
240
				done
280
		if [ -e /usr/${LIBDIR}/libnvidia-tls.so.1 ]
241
			popd
281
		then
242
		fi
282
			rm -f /usr/${LIBDIR}/libnvidia-tls.so.1
243
283
		fi
244
		# Setup the $LDPATH
284
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libnvidia-tls.so.1 ]
245
		ldpath="${ldpath:+${ldpath}:}/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib"
285
		then
246
286
			realtls="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libnvidia-tls.so.1)"
247
		# Setup the includes
287
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/${realtls} \
248
		if [ -d "/usr/${LIBDIR}/opengl/${GL_IMPLEM}/include" ]; then
288
				/usr/${LIBDIR}/tls/libnvidia-tls.so
249
			for x in gl.h glx.h glxtokens.h glext.h; do
289
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/${realtls} \
250
				if [ -e /usr/X11R6/include/GL/${x} ]; then
290
				/usr/${LIBDIR}/tls/libnvidia-tls.so.1
251
					rm -f /usr/X11R6/include/GL/${x}
291
		fi
252
				fi
292
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libnvidia-tls.so.1 ]
253
293
		then
254
				# IMPORTANT
294
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libnvidia-tls.so.1)"
255
				# It is preferable currently to use the standard glext.h file
295
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
256
				# however if an OpenGL provider must use a self produced glext.h
296
				/usr/${LIBDIR}/libnvidia-tls.so
257
				# then it should be installed to ${GL_IMPLEM}/include
297
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
258
298
				/usr/${LIBDIR}/libnvidia-tls.so.1
259
				if [ -e /usr/lib/opengl/${GL_IMPLEM}/include/${x} ]; then
299
		fi
260
					ln -sf /usr/lib/opengl/${GL_IMPLEM}/include/${x} \
300
	done
261
						/usr/X11R6/include/GL/${x}
301
262
				else
302
	# Setup the /usr/lib/libMesaGL.so symlink
263
					ln -sf /usr/lib/opengl/global/include/${x} \
303
	if [ -e /usr/lib/libMesaGL.so ]
264
						/usr/X11R6/include/GL/${x}
304
	then
265
				fi
305
		rm -f /usr/lib/libMesaGL.so
266
			done
306
	fi
267
		fi
307
	realname="$(readlink /usr/lib/opengl/${GL_IMPLEM}/lib/libGL.so)"
268
308
	ln -sf /usr/lib/opengl/${GL_IMPLEM}/lib/${realname} \
269
	done &> /dev/null
309
		/usr/lib/libMesaGL.so
270
310
	
271
	# It needs to be before 04multilib
311
	# Setup the /usr/lib/libGL.la symlink
272
	[ -f "/etc/env.d/09opengl" ] && rm /etc/env.d/09opengl
312
	if [ -e /usr/lib/libGL.la ]
273
	echo "LDPATH=\"${ldpath}\"" > /etc/env.d/03opengl
313
	then
314
		rm -f /usr/lib/libGL.la
315
	fi
316
	if [ -e /usr/lib/opengl/${GL_IMPLEM}/lib/libGL.la ]
317
	then
318
		ln -sf /usr/lib/opengl/${GL_IMPLEM}/lib/libGL.la \
319
			/usr/lib/libGL.la
320
	fi
321
322
	# Fix libtool archives (#48297)
323
	CURDIR="$(pwd)"
324
	cd /usr/lib
325
	if [ "`grep -l /usr/lib/opengl *.la`" ]
326
	then
327
		sed -i 's:/usr/lib/opengl/[^/]*/lib/libGL.la:/usr/lib/libGL.la:' \
328
			`grep -l /usr/lib/opengl *.la`
329
	fi
330
	cd ${CURDIR}
331
332
	# Setup the /usr/lib/modules/extensions/libglx.so symlink
333
	if [ -e /usr/lib/modules/extensions/libglx.so ]
334
	then
335
		rm -f /usr/lib/modules/extensions/libglx.so
336
	fi
337
	if [ -e /usr/lib/opengl/${GL_IMPLEM}/extensions/libglx.so ]
338
	then
339
		ln -sf /usr/lib/opengl/${GL_IMPLEM}/extensions/libglx.so \
340
			/usr/lib/modules/extensions/libglx.so
341
	fi
342
343
	#setup the /usr/lib/modules/extensions/libglx.a symlink
344
	if [ -e /usr/lib/modules/extensions/libglx.a ]
345
	then
346
		rm -f /usr/lib/modules/extensions/libglx.a
347
	fi
348
	if [ -e /usr/lib/opengl/${GL_IMPLEM}/extensions/libglx.a ]
349
	then
350
		ln -sf /usr/lib/opengl/${GL_IMPLEM}/extensions/libglx.a \
351
			/usr/lib/modules/extensions/libglx.a
352
	fi
353
354
	#setup the includes
355
	for x in gl.h glx.h glxtokens.h glext.h
356
	do
357
		if [ -e /usr/X11R6/include/GL/${x} ]
358
		then
359
			rm -f /usr/X11R6/include/GL/${x}
360
		fi
361
274
362
		# IMPORTANT
275
	env-update
363
		# It is preferable currently to use the standard glext.h file
364
		# however if an OpenGL provider must use a self produced glext.h
365
		# then it should be installed to ${GL_IMPLEM}/include
366
		
367
		if [ -e /usr/lib/opengl/${GL_IMPLEM}/include/${x} ]
368
		then
369
			ln -sf /usr/lib/opengl/${GL_IMPLEM}/include/${x} \
370
				/usr/X11R6/include/GL/${x}
371
		else
372
			ln -sf /usr/lib/opengl/global/include/${x} \
373
				/usr/X11R6/include/GL/${x}
374
		fi
375
	done
376
276
377
eend 0
277
eend 0
378
278
379
# vim:ts=4
279
# vim:ts=4

Return to bug 78475