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 (-198 / +97 lines)
Lines 96-103 examples: Link Here
96
FOO
96
FOO
97
	exit 1
97
	exit 1
98
}
98
}
99
99
100
# It needs to be before 04multilib
101
[ -f "/etc/env.d/09opengl" ] && mv /etc/env.d/09opengl /etc/env.d/03opengl
102
100
need_version
103
need_version
101
104
102
if [ "$#" -ne 1 -a "$#" -ne 2 ] || \
105
if [ "$#" -ne 1 -a "$#" -ne 2 ] || \
103
	[ "$#" -eq 2 -a "$1" != "--use-old" ]
106
	[ "$#" -eq 2 -a "$1" != "--use-old" ]
Lines 108-123 fi Link Here
108
GL_IMPLEM=""
111
GL_IMPLEM=""
109
112
110
# Discover GL implementation if it exists
113
# Discover GL implementation if it exists
111
get_implem() {
114
get_implem() {
112
	if [ -f /etc/env.d/09opengl ]
115
	if [ -f /etc/env.d/03opengl ]
113
	then
116
	then
114
		source /etc/env.d/09opengl
117
		source /etc/env.d/03opengl
115
		if [ -n "${LDPATH}" ]
118
		if [ -n "${LDPATH}" ]
116
		then
119
		then
117
			GL_IMPLEM="${LDPATH/:\*/}"
120
			GL_IMPLEM="${LDPATH%%:*}"
118
			GL_IMPLEM="${GL_IMPLEM/\/usr\/lib\/opengl\/}"
121
			GL_IMPLEM="${GL_IMPLEM##*opengl/}"
119
			GL_IMPLEM="${GL_IMPLEM/\/lib}"
122
			GL_IMPLEM="${GL_IMPLEM%/lib*}"
120
			unset LDPATH
123
			unset LDPATH
121
		fi
124
		fi
122
	fi
125
	fi
123
}
126
}
Lines 166-379 then Link Here
166
	usage
169
	usage
167
fi
170
fi
168
171
169
ebegin "Switching to ${GL_IMPLEM} OpenGL interface"
172
ebegin "Switching to ${GL_IMPLEM} OpenGL interface"
173
	rm -f /etc/env.d/03opengl &> /dev/null
170
174
171
	# Provide the right libnvidia-tls depending on ntpl or not
175
	LIBDIRS="lib lib32 lib64"
172
	if [ "${GL_IMPLEM}" = "nvidia" ]
176
	for LIBDIR in ${LIBDIRS}; do
173
	then
177
		[ -d "/usr/${LIBDIR}" -a ! -h "/usr/${LIBDIR}" ] || continue
174
		if [ -e /usr/lib/opengl/${GL_IMPLEM}/lib/tls ]
178
		# System wide tls stuff
175
		then
179
		[ -h "/usr/${LIBDIR}/tls" ] && rm -f /usr/${LIBDIR}/tls
176
			rm -f /usr/lib/opengl/${GL_IMPLEM}/lib/tls
180
		[ -d "/usr/${LIBDIR}/tls" ] || mkdir -p /usr/${LIBDIR}/tls
177
		fi
178
		
179
#		This was the nvidia approach but it seems to not work, new method
180
#		as suggested on various bug reports, #64927, #70545
181
#		/usr/lib/misc/tls_test /usr/lib/misc/tls_test_dso.so 2>/dev/null
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
190
		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
215
	# System wide tls stuff
216
	if [ -h /usr/lib/tls ]
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
181
227
	LIBDIRS="lib lib32"
182
		# Fallback on xorg-x11 if we don't have this implementation for this LIBDIR.
228
	for LIBDIR in ${LIBDIRS}
183
		if [ ! -d /usr/${LIBDIR}/opengl/"${GL_IMPLEM}" ]; then
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
234
			GL_LOCAL="xorg-x11"
184
			GL_LOCAL="xorg-x11"
235
		else
185
		else
236
			GL_LOCAL="${GL_IMPLEM}"
186
			GL_LOCAL="${GL_IMPLEM}"
237
		fi
187
		fi
238
		
188
		
239
		#setup the /usr/lib/libGL.so symlink
189
		# Provide the right libnvidia-tls depending on ntpl or not
240
		if [ -e /usr/${LIBDIR}/libGL.so ]
190
		if [ "${GL_LOCAL}" = "nvidia" ]; then
241
		then
191
			if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls" ]; then
242
			rm -f /usr/${LIBDIR}/libGL.so
192
				rm -f /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls
243
		fi
193
			fi
244
		if [ -e /usr/${LIBDIR}/libGL.so.1 ]
194
		
245
		then
195
			if getconf GNU_LIBPTHREAD_VERSION | grep -i nptl; then
246
			rm -f /usr/${LIBDIR}/libGL.so.1
196
				ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/tls /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/tls
247
		fi
197
				ldpath="${ldpath:+${ldpath}:}/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls"
248
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL.so ]
198
			fi
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
257
		# Setup the /usr/lib/libGLcore.so symlink
258
		if [ -e /usr/${LIBDIR}/libGLcore.so ]
259
		then
260
			rm -f /usr/${LIBDIR}/libGLcore.so
261
		fi
262
		if [ -e /usr/${LIBDIR}/libGLcore.so.1 ]
263
		then
264
			rm -f /usr/${LIBDIR}/libGLcore.so.1
265
		fi
266
		if [ -e /usr/${LIBDIR}/opengl/${GL_IMPLEM}/lib/libGLcore.so ]
267
		then
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
199
		fi
274
200
275
		# Now setup the TLS library links
201
		pushd /usr/${LIBDIR}
276
		if [ -e /usr/${LIBDIR}/libnvidia-tls.so ]
202
			# First remove old symlinks
277
		then
203
			for file in libGL.so* libGLcore.so* libnvidia-tls.so* libMesaGL.so* tls/*; do
278
			rm -f /usr/${LIBDIR}/libnvidia-tls.so
204
				rm -f ${file}
279
		fi
205
			done
280
		if [ -e /usr/${LIBDIR}/libnvidia-tls.so.1 ]
206
281
		then
207
			# Note that we don't do .so*, just .so on purpose.  The
282
			rm -f /usr/${LIBDIR}/libnvidia-tls.so.1
208
			# loaded knows to look in the profile dir, and the
283
		fi
209
			# linked just needs the .so
284
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libnvidia-tls.so.1 ]
210
			for file in opengl/${GL_LOCAL}/lib/*.{so,a,la}; do
285
		then
211
				[ -f "${file}" ] || continue
286
			realtls="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libnvidia-tls.so.1)"
212
				rm -f $(basename ${file})
287
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/${realtls} \
213
				ln -s ${file}
288
				/usr/${LIBDIR}/tls/libnvidia-tls.so
214
289
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/${realtls} \
215
				# Fix libtool archives (#48297)
290
				/usr/${LIBDIR}/tls/libnvidia-tls.so.1
216
				if [ "${file%.la}" != "${file}" ]; then
291
		fi
217
					sed -i "s:/usr/[^/]*/opengl/[^/]*/lib/:/usr/${LIBDIR}/:g" ${file}
292
		if [ -e /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libnvidia-tls.so.1 ]
218
				fi
293
		then
219
			done
294
			realname="$(readlink /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/libnvidia-tls.so.1)"
220
295
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
221
			ln -s opengl/${GL_LOCAL}/lib/libGL.so libMesaGL.so
296
				/usr/${LIBDIR}/libnvidia-tls.so
222
		popd
297
			ln -sf /usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/${realname} \
223
298
				/usr/${LIBDIR}/libnvidia-tls.so.1
224
		if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls" ]; then
225
			pushd /usr/${LIBDIR}/tls
226
				for file in ../opengl/${GL_LOCAL}/lib/tls/*.{so,a,la}; do
227
					[ -f "${file}" ] || continue
228
					rm -f $(basename ${file})
229
					ln -s ${file}
230
				done
231
			popd
232
		fi
233
234
		if [ -e "/usr/${LIBDIR}/opengl/${GL_LOCAL}/modules/extensions" ]; then
235
			mkdir -p /usr/${LIBDIR}/modules/extensions
236
			pushd /usr/${LIBDIR}/modules/extensions
237
				for file in ../../opengl/${GL_LOCAL}/lib/extensions/*.{so,a,la}; do
238
					[ -f "${file}" ] || continue
239
					rm -f $(basename ${file})
240
					ln -s ${file}
241
				done
242
			popd
243
		fi
244
245
		# Setup the $LDPATH
246
		ldpath="${ldpath:+${ldpath}:}/usr/${LIBDIR}/opengl/${GL_LOCAL}/lib"
247
248
		# Setup the includes
249
		if [ -d "/usr/${LIBDIR}/opengl/${GL_IMPLEM}/include" ]; then
250
			for x in gl.h glx.h glxtokens.h glext.h; do
251
				if [ -e /usr/X11R6/include/GL/${x} ]; then
252
					rm -f /usr/X11R6/include/GL/${x}
253
				fi
254
255
				# IMPORTANT
256
				# It is preferable currently to use the standard glext.h file
257
				# however if an OpenGL provider must use a self produced glext.h
258
				# then it should be installed to ${GL_IMPLEM}/include
259
260
				if [ -e /usr/lib/opengl/${GL_IMPLEM}/include/${x} ]; then
261
					ln -sf /usr/lib/opengl/${GL_IMPLEM}/include/${x} \
262
						/usr/X11R6/include/GL/${x}
263
				else
264
					ln -sf /usr/lib/opengl/global/include/${x} \
265
						/usr/X11R6/include/GL/${x}
266
				fi
267
			done
299
		fi
268
		fi
300
	done
301
302
	# Setup the /usr/lib/libMesaGL.so symlink
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
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
269
332
	# Setup the /usr/lib/modules/extensions/libglx.so symlink
270
	done &> /dev/null
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
271
343
	#setup the /usr/lib/modules/extensions/libglx.a symlink
272
	echo "LDPATH=\"${ldpath}\"" > /etc/env.d/03opengl
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
273
362
		# IMPORTANT
274
	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
275
377
eend 0
276
eend 0
378
277
379
# vim:ts=4
278
# vim:ts=4

Return to bug 78475