]> git.draconx.ca Git - gentoo-draconx.git/blob - media-libs/mesa/mesa-7.11_rc1-r1.ebuild
Add games-strategy/uplink.
[gentoo-draconx.git] / media-libs / mesa / mesa-7.11_rc1-r1.ebuild
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 $
4
5 EAPI=3
6
7 EGIT_REPO_URI="git://anongit.freedesktop.org/mesa/mesa"
8
9 if [[ ${PV} = 9999* ]]; then
10         GIT_ECLASS="git-2"
11         EXPERIMENTAL="true"
12 fi
13
14 inherit base autotools multilib flag-o-matic python toolchain-funcs ${GIT_ECLASS}
15
16 OPENGL_DIR="xorg-x11"
17
18 MY_PN="${PN/m/M}"
19 MY_P="${MY_PN}-${PV/_/-}"
20 MY_SRC_P="${MY_PN}Lib-${PV/_/-}"
21
22 FOLDER="${PV/_rc*/}"
23
24 DESCRIPTION="OpenGL-like graphic library for Linux"
25 HOMEPAGE="http://mesa3d.sourceforge.net/"
26
27 #SRC_PATCHES="mirror://gentoo/${P}-gentoo-patches-01.tar.bz2"
28 if [[ $PV = 9999* ]]; then
29         SRC_URI="${SRC_PATCHES}"
30 else
31         SRC_URI="ftp://ftp.freedesktop.org/pub/mesa/${FOLDER}/${MY_SRC_P}.tar.bz2
32                 ${SRC_PATCHES}"
33 fi
34
35 LICENSE="LGPL-2 kilgard"
36 SLOT="0"
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"
38
39 INTEL_CARDS="intel"
40 RADEON_CARDS="radeon"
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}"
44 done
45
46 IUSE="${IUSE_VIDEO_CARDS}
47         bindist +classic debug +egl +gallium gles +llvm motif +nptl openvg pic selinux shared-dricore +shared-glapi kernel_FreeBSD"
48
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
52 EXTERNAL_DEPEND="
53         >=x11-proto/dri2proto-2.2
54         >=x11-proto/glproto-1.4.11
55 "
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
64         dev-libs/expat
65         dev-libs/libxml2[python]
66         x11-libs/libICE
67         >=x11-libs/libX11-1.3.99.901
68         x11-libs/libXdamage
69         x11-libs/libXext
70         x11-libs/libXi
71         x11-libs/libXmu
72         x11-libs/libXxf86vm
73         motif? ( x11-libs/openmotif )
74         gallium? (
75                 llvm? ( >=sys-devel/llvm-2.9 )
76         )
77         ${LIBDRM_DEPSTRING}[video_cards_nouveau?,video_cards_vmware?]
78 "
79 for card in ${INTEL_CARDS}; do
80         RDEPEND="${RDEPEND}
81                 video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_intel] )
82         "
83 done
84
85 for card in ${RADEON_CARDS}; do
86         RDEPEND="${RDEPEND}
87                 video_cards_${card}? ( ${LIBDRM_DEPSTRING}[video_cards_radeon] )
88         "
89 done
90
91 DEPEND="${RDEPEND}
92         =dev-lang/python-2*
93         dev-util/pkgconfig
94         x11-misc/makedepend
95         x11-proto/inputproto
96         >=x11-proto/xextproto-7.0.99.1
97         x11-proto/xf86driproto
98         x11-proto/xf86vidmodeproto
99 "
100
101 S="${WORKDIR}/${MY_P}"
102
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*"
107
108 # Think about: ggi, fbcon, no-X configs
109
110 pkg_setup() {
111         # gcc 4.2 has buggy ivopts
112         if [[ $(gcc-version) = "4.2" ]]; then
113                 append-flags -fno-ivopts
114         fi
115
116         # recommended by upstream
117         append-flags -ffast-math
118
119         python_set_active_version 2
120         python_pkg_setup
121 }
122
123 src_unpack() {
124         default
125         [[ $PV = 9999* ]] && git-2_src_unpack
126 }
127
128 src_prepare() {
129         # apply patches
130         if [[ ${PV} != 9999* && -n ${SRC_PATCHES} ]]; then
131                 EPATCH_FORCE="yes" \
132                 EPATCH_SOURCE="${WORKDIR}/patches" \
133                 EPATCH_SUFFIX="patch" \
134                 epatch
135         fi
136
137         epatch "${FILESDIR}"/0001-i965-gen4-Fix-GPU-hangs-since-the-program-streaming-.patch
138
139         # fix for hardened, bug 240956
140         [[ ${PV} != 9999* ]] && epatch "${FILESDIR}"/glx_ro_text_segm.patch
141
142         # FreeBSD 6.* doesn't have posix_memalign().
143         if [[ ${CHOST} == *-freebsd6.* ]]; then
144                 sed -i \
145                         -e "s/-DHAVE_POSIX_MEMALIGN//" \
146                         configure.ac || die
147         fi
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
152         fi
153
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
160         fi
161
162         # depend contains strange paths, we don't want them
163         echo "" > "${S}"/src/mesa/depend || die
164
165         base_src_prepare
166
167         eautoreconf
168 }
169
170 src_configure() {
171         local myconf
172
173         if use classic; then
174         # Configurable DRI drivers
175                 driver_enable swrast
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
186         fi
187
188         myconf+="
189                 $(use_enable !bindist texture-float)
190                 $(use_enable gles gles1)
191                 $(use_enable gles gles2)
192                 $(use_enable egl)
193                 $(use_enable openvg)
194         "
195         if use egl; then
196                 use shared-glapi || die "egl needs shared-glapi. Please either enable shared-glapi or disable the egl use flag ."
197                 myconf+="
198                         --with-egl-platforms=drm,x11
199                         $(use_enable gallium gallium-egl)
200                 "
201         fi
202
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."
206         fi
207         if use gallium; then
208                 myconf+="
209                         --with-state-trackers=glx,dri$(use egl && echo ",egl")$(use openvg && echo ",vega")
210                         $(use_enable llvm gallium-llvm)
211                 "
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
217         fi
218
219         # x86 hardened needs glx-rts, bug 240956
220         if use hardened; then
221                 myconf+="
222                         $(use_enable x86 glx-rts)
223                 "
224         fi
225
226         # --with-driver=dri|xlib|osmesa || do we need osmesa?
227         econf \
228                 --disable-option-checking \
229                 --with-driver=dri \
230                 --disable-glut \
231                 --without-demos \
232                 --enable-xcb \
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} \
242                 ${myconf}
243 }
244
245 src_install() {
246         base_src_install
247
248         # Save the glsl-compiler for later use
249         if ! tc-is-cross-compiler; then
250                 dobin "${S}"/src/glsl/glsl_compiler || die
251         fi
252         # Remove redundant headers
253         # GLUT thing
254         rm -f "${ED}"/usr/include/GL/glut*.h || die "Removing glut include failed."
255         # Glew includes
256         rm -f "${ED}"/usr/include/GL/{glew,glxew,wglew}.h \
257                 || die "Removing glew includes failed."
258
259         # Install config file for eselect mesa
260         insinto /usr/share/mesa
261         newins "${FILESDIR}/eselect-mesa.conf.7.11" eselect-mesa.conf || die
262
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}
267                 local x
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}"
272                         fi
273                 done
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}"
278                         fi
279                 done
280         eend $?
281
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
293                                                 insopts -m0755
294                                                 doins "${S}/$(get_libdir)/${x}" || die "failed to install ${x}"
295                                         fi
296                                 fi
297                         done
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}"
302                                 fi
303                         done
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}"
310                                 fi
311                         done
312                         popd
313                 eend $?
314         fi
315 }
316
317 pkg_postinst() {
318         # Switch to the xorg implementation.
319         echo
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
324         fi
325
326         # warn about patent encumbered texture-float
327         if use !bindist; then
328                 elog "USE=\"bindist\" was not set. Potentially patent encumbered code was"
329                 elog "enabled."
330         fi
331 }
332
333 # $1 - VIDEO_CARDS flag
334 # other args - names of DRI drivers to enable
335 # TODO: avoid code duplication for a more elegant implementation
336 driver_enable() {
337         case $# in
338                 # for enabling unconditionally
339                 1)
340                         DRI_DRIVERS+=",$1"
341                         ;;
342                 *)
343                         if use $1; then
344                                 shift
345                                 for i in $@; do
346                                         DRI_DRIVERS+=",${i}"
347                                 done
348                         fi
349                         ;;
350         esac
351 }
352
353 gallium_enable() {
354         case $# in
355                 # for enabling unconditionally
356                 1)
357                         GALLIUM_DRIVERS+=",$1"
358                         ;;
359                 *)
360                         if use $1; then
361                                 shift
362                                 for i in $@; do
363                                         GALLIUM_DRIVERS+=",${i}"
364                                 done
365                         fi
366                         ;;
367         esac
368 }