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 (-186 / +92 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%/*}"
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
				if [ -d "/usr/${LIBDIR}/opengl/${GL_IMPLEM}" ]; then
182
		getconf GNU_LIBPTHREAD_VERSION | grep -i nptl > /dev/null
185
					ln -sf /usr/${LIBDIR}/opengl/${GL_IMPLEM}/tls /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/tls
183
		if [ ${?} = 0 ]
186
				fi
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
187
			fi
190
		fi
188
		fi
191
	fi
189
192
	
190
		# System wide tls stuff
193
	# Setup the $LDPATH
191
		if [ -h /usr/${LIBDIR}/tls ]
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
192
		then
206
			rm -f ${lib32}/tls
193
			rm -f /usr/${LIBDIR}/tls
207
		fi
194
		fi
208
		if [ ! -d ${lib32}/tls ]
195
		if [ ! -d /usr/${LIBDIR}/tls ] 
209
		then
196
		then
210
			mkdir -p ${lib32}/tls
197
			mkdir -p /usr/${LIBDIR}/tls
211
		fi
198
		fi
212
			
213
	fi
214
199
215
	# System wide tls stuff
200
		# Fallback on xorg-x11 if we don't have this implementation for this LIBDIR.
216
	if [ -h /usr/lib/tls ]
201
		if [ ! -d /usr/${LIBDIR}/opengl/"${GL_IMPLEM}" ]
217
	then
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
227
	LIBDIRS="lib lib32"
228
	for LIBDIR in ${LIBDIRS}
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
202
		then
234
			GL_LOCAL="xorg-x11"
203
			GL_LOCAL="xorg-x11"
235
		else
204
		else
236
			GL_LOCAL="${GL_IMPLEM}"
205
			GL_LOCAL="${GL_IMPLEM}"
237
		fi
206
		fi
238
		
207
		
239
		#setup the /usr/lib/libGL.so symlink
208
		# Setup the $LDPATH
240
		if [ -e /usr/${LIBDIR}/libGL.so ]
241
		then
242
			rm -f /usr/${LIBDIR}/libGL.so
243
		fi
244
		if [ -e /usr/${LIBDIR}/libGL.so.1 ]
245
		then
246
			rm -f /usr/${LIBDIR}/libGL.so.1
247
		fi
248
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL.so ]
249
		then
250
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL.so)"
251
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
252
				/usr/${LIBDIR}/libGL.so
253
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
254
				/usr/${LIBDIR}/libGL.so.1
255
		fi
256
209
257
		# Setup the /usr/lib/libGLcore.so symlink
210
		pushd /usr/${LIBDIR}
258
		if [ -e /usr/${LIBDIR}/libGLcore.so ]
211
			# First remove old symlinks
259
		then
212
			for file in libGL.so* libGLcore.so* libnvidia-tls.so* libMesaGL.so* tls/*; do
260
			rm -f /usr/${LIBDIR}/libGLcore.so
213
				rm -f ${file}
261
		fi
214
			done
262
		if [ -e /usr/${LIBDIR}/libGLcore.so.1 ]
215
263
		then
216
			for file in opengl/${GL_LOCAL}/lib/*.{so,a,la}; do
264
			rm -f /usr/${LIBDIR}/libGLcore.so.1
217
				[ -f "${file}" ] || continue
265
		fi
218
				rm -f $(basename ${file})
266
		if [ -e /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/libGLcore.so ]
219
				ln -s ${file}
267
		then
220
			done
268
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/libGLcore.so)"
269
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
270
				/usr/${LIBDIR}/libGLcore.so
271
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
272
				/usr/${LIBDIR}/libGLcore.so.1
273
		fi
274
275
		# Now setup the TLS library links
276
		if [ -e /usr/${LIBDIR}/libnvidia-tls.so ]
277
		then
278
			rm -f /usr/${LIBDIR}/libnvidia-tls.so
279
		fi
280
		if [ -e /usr/${LIBDIR}/libnvidia-tls.so.1 ]
281
		then
282
			rm -f /usr/${LIBDIR}/libnvidia-tls.so.1
283
		fi
284
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libnvidia-tls.so.1 ]
285
		then
286
			realtls="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libnvidia-tls.so.1)"
287
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/${realtls} \
288
				/usr/${LIBDIR}/tls/libnvidia-tls.so
289
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/${realtls} \
290
				/usr/${LIBDIR}/tls/libnvidia-tls.so.1
291
		fi
292
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libnvidia-tls.so.1 ]
293
		then
294
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libnvidia-tls.so.1)"
295
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
296
				/usr/${LIBDIR}/libnvidia-tls.so
297
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
298
				/usr/${LIBDIR}/libnvidia-tls.so.1
299
		fi
300
	done
301
221
302
	# Setup the /usr/lib/libMesaGL.so symlink
222
			ln -s opengl/${GL_LOCAL}/lib/libGL.so libMesaGL.so
303
	if [ -e /usr/lib/libMesaGL.so ]
304
	then
305
		rm -f /usr/lib/libMesaGL.so
306
	fi
307
	realname="$(readlink /usr/lib/opengl/${GL_IMPLEM}/lib/libGL.so)"
308
	ln -sf /usr/lib/opengl/${GL_IMPLEM}/lib/${realname} \
309
		/usr/lib/libMesaGL.so
310
	
311
	# Setup the /usr/lib/libGL.la symlink
312
	if [ -e /usr/lib/libGL.la ]
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
223
322
	# Fix libtool archives (#48297)
224
			# Fix libtool archives (#48297)
323
	CURDIR="$(pwd)"
225
			if [ "`grep -l /usr/lib/opengl *.la`" ]
324
	cd /usr/lib
226
			then
325
	if [ "`grep -l /usr/lib/opengl *.la`" ]
227
				sed -i "s:/usr/${LIBDIR}/opengl/[^/]*/lib/libGL.la:/usr/${LIBDIR}/libGL.la:" \
326
	then
228
					`grep -l /usr/lib/opengl *.la`
327
		sed -i 's:/usr/lib/opengl/[^/]*/lib/libGL.la:/usr/lib/libGL.la:' \
229
			fi
328
			`grep -l /usr/lib/opengl *.la`
230
		popd
329
	fi
330
	cd ${CURDIR}
331
231
332
	# Setup the /usr/lib/modules/extensions/libglx.so symlink
232
		if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls" ]; then
333
	if [ -e /usr/lib/modules/extensions/libglx.so ]
233
			pushd /usr/${LIBDIR}/tls
334
	then
234
				for file in ../opengl/${GL_LOCAL}/lib/tls/*.{so,a,la}; do
335
		rm -f /usr/lib/modules/extensions/libglx.so
235
					[ -f "${file}" ] || continue
336
	fi
236
					rm -f $(basename ${file})
337
	if [ -e /usr/lib/opengl/${GL_IMPLEM}/extensions/libglx.so ]
237
					ln -s ${file}
338
	then
238
				done
339
		ln -sf /usr/lib/opengl/${GL_IMPLEM}/extensions/libglx.so \
239
			popd
340
			/usr/lib/modules/extensions/libglx.so
240
		fi
341
	fi
241
242
		if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/modules/extensions" ]; then
243
			mkdir -p /usr/${LIBDIR}/modules/extensions
244
			pushd /usr/${LIBDIR}/modules/extensions
245
				for file in ../../opengl/${GL_LOCAL}/lib/extensions/*.{so,a,la}; do
246
					[ -f "${file}" ] || continue
247
					rm -f $(basename ${file})
248
					ln -s ${file}
249
				done
250
			popd
251
		fi
252
253
		ldpath="${ldpath:+${ldpath}:}/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib"
254
255
		# Setup the includes
256
		if [ -d "/usr/${LIBDIR}/opengl/${GL_IMPLEM}/include" ]; then
257
			for x in gl.h glx.h glxtokens.h glext.h; do
258
				if [ -e /usr/X11R6/include/GL/${x} ]; then
259
					rm -f /usr/X11R6/include/GL/${x}
260
				fi
261
262
				# IMPORTANT
263
				# It is preferable currently to use the standard glext.h file
264
				# however if an OpenGL provider must use a self produced glext.h
265
				# then it should be installed to ${GL_IMPLEM}/include
266
267
				if [ -e /usr/lib/opengl/${GL_IMPLEM}/include/${x} ]; then
268
					ln -sf /usr/lib/opengl/${GL_IMPLEM}/include/${x} \
269
						/usr/X11R6/include/GL/${x}
270
				else
271
					ln -sf /usr/lib/opengl/global/include/${x} \
272
						/usr/X11R6/include/GL/${x}
273
				fi
274
			done
275
		fi
342
276
343
	#setup the /usr/lib/modules/extensions/libglx.a symlink
277
	done &> /dev/null
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
278
354
	#setup the includes
279
	echo "LDPATH=\"${ldpath}\"" > /etc/env.d/09opengl
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
280
362
		# IMPORTANT
281
	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
282
377
eend 0
283
eend 0
378
284
379
# vim:ts=4
285
# vim:ts=4

Return to bug 78475