1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/media-libs/mesa/mesa-7.11_rc1-r1.ebuild,v 1.1 2011/07/10 10:17:14 chithanh Exp $
7 EGIT_REPO_URI="git://anongit.freedesktop.org/mesa/mesa"
9 if [[ ${PV} = 9999* ]]; then
14 inherit base autotools multilib flag-o-matic python toolchain-funcs ${GIT_ECLASS}
19 MY_P="${MY_PN}-${PV/_/-}"
20 MY_SRC_P="${MY_PN}Lib-${PV/_/-}"
24 DESCRIPTION="OpenGL-like graphic library for Linux"
25 HOMEPAGE="http://mesa3d.sourceforge.net/"
27 #SRC_PATCHES="mirror://gentoo/${P}-gentoo-patches-01.tar.bz2"
28 if [[ $PV = 9999* ]]; then
29 SRC_URI="${SRC_PATCHES}"
31 SRC_URI="ftp://ftp.freedesktop.org/pub/mesa/${FOLDER}/${MY_SRC_P}.tar.bz2
35 LICENSE="LGPL-2 kilgard"
37 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sh ~sparc ~x86 ~x86-fbsd ~x86-freebsd ~amd64-linux ~ia64-linux ~x86-linux ~sparc-solaris ~x64-solaris ~x86-solaris"
41 VIDEO_CARDS="${INTEL_CARDS} ${RADEON_CARDS} mach64 mga nouveau r128 savage sis vmware tdfx via"
42 for card in ${VIDEO_CARDS}; do
43 IUSE_VIDEO_CARDS+=" video_cards_${card}"
46 IUSE="${IUSE_VIDEO_CARDS}
47 bindist +classic debug +egl +gallium gles +llvm motif +nptl openvg pic selinux shared-dricore +shared-glapi kernel_FreeBSD"
49 LIBDRM_DEPSTRING=">=x11-libs/libdrm-2.4.24"
50 # not a runtime dependency of this package, but dependency of packages which
51 # depend on this package, bug #342393
53 >=x11-proto/dri2proto-2.2
54 >=x11-proto/glproto-1.4.11
56 # keep correct libdrm and dri2proto dep
57 # keep blocks in rdepend for binpkg
58 RDEPEND="${EXTERNAL_DEPEND}
59 !<x11-base/xorg-server-1.7
60 !<=x11-proto/xf86driproto-2.0.3
61 classic? ( app-admin/eselect-mesa )
62 gallium? ( app-admin/eselect-mesa )
63 app-admin/eselect-opengl
65 dev-libs/libxml2[python]
67 >=x11-libs/libX11-1.3.99.901
73 motif? ( x11-libs/openmotif )
75 llvm? ( >=sys-devel/llvm-2.9 )
77 ${LIBDRM_DEPSTRING}[video_cards_nouveau?,video_cards_vmware?]
79 for card in ${INTEL_CARDS}; do
81 video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
85 for card in ${RADEON_CARDS}; do
87 video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] )
96 >=x11-proto/xextproto-7.0.99.1
97 x11-proto/xf86driproto
98 x11-proto/xf86vidmodeproto
101 S="${WORKDIR}/${MY_P}"
103 # It is slow without texrels, if someone wants slow
104 # mesa without texrels +pic use is worth the shot
105 QA_EXECSTACK="usr/lib*/opengl/xorg-x11/lib/libGL.so*"
106 QA_WX_LOAD="usr/lib*/opengl/xorg-x11/lib/libGL.so*"
108 # Think about: ggi, fbcon, no-X configs
111 # gcc 4.2 has buggy ivopts
112 if [[ $(gcc-version) = "4.2" ]]; then
113 append-flags -fno-ivopts
116 # recommended by upstream
117 append-flags -ffast-math
119 python_set_active_version 2
125 [[ $PV = 9999* ]] && git-2_src_unpack
130 if [[ ${PV} != 9999* && -n ${SRC_PATCHES} ]]; then
132 EPATCH_SOURCE="${WORKDIR}/patches" \
133 EPATCH_SUFFIX="patch" \
137 epatch "${FILESDIR}"/0001-i965-gen4-Fix-GPU-hangs-since-the-program-streaming-.patch
139 # fix for hardened, bug 240956
140 [[ ${PV} != 9999* ]] && epatch "${FILESDIR}"/glx_ro_text_segm.patch
142 # FreeBSD 6.* doesn't have posix_memalign().
143 if [[ ${CHOST} == *-freebsd6.* ]]; then
145 -e "s/-DHAVE_POSIX_MEMALIGN//" \
148 # Solaris needs some recent POSIX stuff in our case
149 if [[ ${CHOST} == *-solaris* ]] ; then
150 sed -i -e "s/-DSVR4/-D_POSIX_C_SOURCE=200112L/" configure.ac || die
151 sed -i -e 's/uint/unsigned int/g' src/egl/drivers/glx/egl_glx.c || die
154 # In order for mesa to complete it's build process we need to use a tool
155 # that it compiles. When we cross compile this clearly does not work
156 # so we require mesa to be built on the host system first. -solar
157 if tc-is-cross-compiler; then
158 sed -i -e "s#^GLSL_CL = .*\$#GLSL_CL = glsl_compiler#g" \
159 "${S}"/src/mesa/shader/slang/library/Makefile || die
162 # depend contains strange paths, we don't want them
163 echo "" > "${S}"/src/mesa/depend || die
174 # Configurable DRI drivers
176 driver_enable video_cards_intel i810 i915 i965
177 driver_enable video_cards_nouveau nouveau
178 driver_enable video_cards_mach64 mach64
179 driver_enable video_cards_mga mga
180 driver_enable video_cards_r128 r128
181 driver_enable video_cards_radeon radeon r200 r300 r600
182 driver_enable video_cards_savage savage
183 driver_enable video_cards_sis sis
184 driver_enable video_cards_tdfx tdfx
185 driver_enable video_cards_via unichrome
189 $(use_enable !bindist texture-float)
190 $(use_enable gles gles1)
191 $(use_enable gles gles2)
196 use shared-glapi || die "egl needs shared-glapi. Please either enable shared-glapi or disable the egl use flag ."
198 --with-egl-platforms=drm,x11
199 $(use_enable gallium gallium-egl)
203 if use !gallium && use !classic; then
204 ewarn "You enabled neither classic nor gallium USE flags. No hardware"
205 ewarn "drivers will be built."
209 --with-state-trackers=glx,dri$(use egl && echo ",egl")$(use openvg && echo ",vega")
210 $(use_enable llvm gallium-llvm)
212 gallium_enable swrast
213 gallium_enable video_cards_vmware svga
214 gallium_enable video_cards_nouveau nouveau
215 gallium_enable video_cards_intel i915 i965
216 gallium_enable video_cards_radeon r300 r600
219 # x86 hardened needs glx-rts, bug 240956
220 if use hardened; then
222 $(use_enable x86 glx-rts)
226 # --with-driver=dri|xlib|osmesa || do we need osmesa?
228 --disable-option-checking \
233 $(use_enable debug) \
234 $(use_enable motif glw) \
235 $(use_enable motif) \
236 $(use_enable nptl glx-tls) \
237 $(use_enable !pic asm) \
238 $(use_enable shared-dricore) \
239 $(use_enable shared-glapi) \
240 --with-dri-drivers=${DRI_DRIVERS} \
241 --with-gallium-drivers=${GALLIUM_DRIVERS} \
248 # Save the glsl-compiler for later use
249 if ! tc-is-cross-compiler; then
250 dobin "${S}"/src/glsl/glsl_compiler || die
252 # Remove redundant headers
254 rm -f "${ED}"/usr/include/GL/glut*.h || die "Removing glut include failed."
256 rm -f "${ED}"/usr/include/GL/{glew,glxew,wglew}.h \
257 || die "Removing glew includes failed."
259 # Install config file for eselect mesa
260 insinto /usr/share/mesa
261 newins "${FILESDIR}/eselect-mesa.conf.7.11" eselect-mesa.conf || die
263 # Move libGL and others from /usr/lib to /usr/lib/opengl/blah/lib
264 # because user can eselect desired GL provider.
265 ebegin "Moving libGL and friends for dynamic switching"
266 dodir /usr/$(get_libdir)/opengl/${OPENGL_DIR}/{lib,extensions,include}
268 for x in "${ED}"/usr/$(get_libdir)/libGL.{la,a,so*}; do
269 if [ -f ${x} -o -L ${x} ]; then
270 mv -f "${x}" "${ED}"/usr/$(get_libdir)/opengl/${OPENGL_DIR}/lib \
271 || die "Failed to move ${x}"
274 for x in "${ED}"/usr/include/GL/{gl.h,glx.h,glext.h,glxext.h}; do
275 if [ -f ${x} -o -L ${x} ]; then
276 mv -f "${x}" "${ED}"/usr/$(get_libdir)/opengl/${OPENGL_DIR}/include \
277 || die "Failed to move ${x}"
282 if use classic || use gallium; then
283 ebegin "Moving DRI/Gallium drivers for dynamic switching"
284 local gallium_drivers=( i915_dri.so i965_dri.so r300_dri.so r600_dri.so swrast_dri.so )
285 keepdir /usr/$(get_libdir)/dri
286 dodir /usr/$(get_libdir)/mesa
287 for x in ${gallium_drivers[@]}; do
288 if [ -f "${S}/$(get_libdir)/gallium/${x}" ]; then
289 mv -f "${ED}/usr/$(get_libdir)/dri/${x}" "${ED}/usr/$(get_libdir)/dri/${x/_dri.so/g_dri.so}" \
290 || die "Failed to move ${x}"
291 insinto "/usr/$(get_libdir)/dri/"
292 if [ -f "${S}/$(get_libdir)/${x}" ]; then
294 doins "${S}/$(get_libdir)/${x}" || die "failed to install ${x}"
298 for x in "${ED}"/usr/$(get_libdir)/dri/*.so; do
299 if [ -f ${x} -o -L ${x} ]; then
300 mv -f "${x}" "${x/dri/mesa}" \
301 || die "Failed to move ${x}"
304 pushd "${ED}"/usr/$(get_libdir)/dri || die "pushd failed"
305 ln -s ../mesa/*.so . || die "Creating symlink failed"
306 # remove symlinks to drivers known to eselect
307 for x in ${gallium_drivers[@]}; do
308 if [ -f ${x} -o -L ${x} ]; then
309 rm "${x}" || die "Failed to remove ${x}"
318 # Switch to the xorg implementation.
320 eselect opengl set --use-old ${OPENGL_DIR}
321 # Select classic/gallium drivers
322 if use classic || use gallium; then
323 eselect mesa set --auto
326 # warn about patent encumbered texture-float
327 if use !bindist; then
328 elog "USE=\"bindist\" was not set. Potentially patent encumbered code was"
333 # $1 - VIDEO_CARDS flag
334 # other args - names of DRI drivers to enable
335 # TODO: avoid code duplication for a more elegant implementation
338 # for enabling unconditionally
355 # for enabling unconditionally
357 GALLIUM_DRIVERS+=",$1"
363 GALLIUM_DRIVERS+=",${i}"