app-emulation/xen: revbumps; add xsa-156 patches in 4.5 4.5.2-r1, 4.6.0-r2
[gentoo.git] / app-emulation / wine / wine-1.7.50.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 AUTOTOOLS_AUTORECONF=1
8 PLOCALES="ar bg ca cs da de el en en_US eo es fa fi fr he hi hr hu it ja ko lt ml nb_NO nl or pa pl pt_BR pt_PT rm ro ru sk sl sr_RS@cyrillic sr_RS@latin sv te th tr uk wa zh_CN zh_TW"
9 PLOCALE_BACKUP="en"
10
11 inherit autotools-utils eutils fdo-mime flag-o-matic gnome2-utils l10n multilib multilib-minimal pax-utils toolchain-funcs virtualx
12
13 if [[ ${PV} == "9999" ]] ; then
14         EGIT_REPO_URI="git://source.winehq.org/git/wine.git http://source.winehq.org/git/wine.git"
15         EGIT_BRANCH="master"
16         inherit git-r3
17         SRC_URI=""
18         #KEYWORDS=""
19 else
20         MY_P="${PN}-${PV/_/-}"
21         SRC_URI="mirror://sourceforge/${PN}/Source/${MY_P}.tar.bz2"
22         KEYWORDS="-* ~amd64 ~x86 ~x86-fbsd"
23         S=${WORKDIR}/${MY_P}
24 fi
25
26 GV="2.40"
27 MV="4.5.6"
28 STAGING_P="wine-staging-${PV}"
29 STAGING_DIR="${WORKDIR}/${STAGING_P}"
30 WINE_GENTOO="wine-gentoo-2015.03.07"
31 GST_P="wine-1.7.34-gstreamer-v5"
32 DESCRIPTION="Free implementation of Windows(tm) on Unix"
33 HOMEPAGE="http://www.winehq.org/"
34 SRC_URI="${SRC_URI}
35         gecko? (
36                 abi_x86_32? ( mirror://sourceforge/${PN}/Wine%20Gecko/${GV}/wine_gecko-${GV}-x86.msi )
37                 abi_x86_64? ( mirror://sourceforge/${PN}/Wine%20Gecko/${GV}/wine_gecko-${GV}-x86_64.msi )
38         )
39         mono? ( mirror://sourceforge/${PN}/Wine%20Mono/${MV}/wine-mono-${MV}.msi )
40         gstreamer? ( https://dev.gentoo.org/~tetromino/distfiles/${PN}/${GST_P}.patch.bz2 )
41         https://dev.gentoo.org/~tetromino/distfiles/${PN}/${WINE_GENTOO}.tar.bz2"
42
43 if [[ ${PV} == "9999" ]] ; then
44         STAGING_EGIT_REPO_URI="git://github.com/wine-compholio/wine-staging.git"
45 else
46         SRC_URI="${SRC_URI}
47         staging? ( https://github.com/wine-compholio/wine-staging/archive/v${PV}.tar.gz -> ${STAGING_P}.tar.gz )
48         pulseaudio? ( https://github.com/wine-compholio/wine-staging/archive/v${PV}.tar.gz -> ${STAGING_P}.tar.gz )"
49 fi
50
51 LICENSE="LGPL-2.1"
52 SLOT="0"
53 IUSE="+abi_x86_32 +abi_x86_64 +alsa capi cups custom-cflags dos elibc_glibc +fontconfig +gecko gphoto2 gsm gstreamer +jpeg +lcms ldap +mono mp3 ncurses netapi nls odbc openal opencl +opengl osmesa oss +perl pcap pipelight +png +prelink pulseaudio +realtime +run-exes s3tc samba scanner selinux +ssl staging test +threads +truetype +udisks v4l vaapi +X +xcomposite xinerama +xml"
54 REQUIRED_USE="|| ( abi_x86_32 abi_x86_64 )
55         test? ( abi_x86_32 )
56         elibc_glibc? ( threads )
57         mono? ( abi_x86_32 )
58         pipelight? ( staging )
59         s3tc? ( staging )
60         vaapi? ( staging )
61         ?? ( gstreamer staging )
62         osmesa? ( opengl )" #286560
63
64 # FIXME: the test suite is unsuitable for us; many tests require net access
65 # or fail due to Xvfb's opengl limitations.
66 RESTRICT="test"
67
68 COMMON_DEPEND="
69         truetype? ( >=media-libs/freetype-2.0.0[${MULTILIB_USEDEP}] )
70         capi? ( net-dialup/capi4k-utils )
71         ncurses? ( >=sys-libs/ncurses-5.2:0=[${MULTILIB_USEDEP}] )
72         udisks? ( sys-apps/dbus[${MULTILIB_USEDEP}] )
73         fontconfig? ( media-libs/fontconfig:=[${MULTILIB_USEDEP}] )
74         gphoto2? ( media-libs/libgphoto2:=[${MULTILIB_USEDEP}] )
75         openal? ( media-libs/openal:=[${MULTILIB_USEDEP}] )
76         gstreamer? (
77                 media-libs/gstreamer:0.10[${MULTILIB_USEDEP}]
78                 media-libs/gst-plugins-base:0.10[${MULTILIB_USEDEP}]
79         )
80         X? (
81                 x11-libs/libXcursor[${MULTILIB_USEDEP}]
82                 x11-libs/libXext[${MULTILIB_USEDEP}]
83                 x11-libs/libXrandr[${MULTILIB_USEDEP}]
84                 x11-libs/libXi[${MULTILIB_USEDEP}]
85                 x11-libs/libXxf86vm[${MULTILIB_USEDEP}]
86         )
87         xinerama? ( x11-libs/libXinerama[${MULTILIB_USEDEP}] )
88         alsa? ( media-libs/alsa-lib[${MULTILIB_USEDEP}] )
89         cups? ( net-print/cups:=[${MULTILIB_USEDEP}] )
90         opencl? ( virtual/opencl[${MULTILIB_USEDEP}] )
91         opengl? (
92                 virtual/glu[${MULTILIB_USEDEP}]
93                 virtual/opengl[${MULTILIB_USEDEP}]
94         )
95         gsm? ( media-sound/gsm:=[${MULTILIB_USEDEP}] )
96         jpeg? ( virtual/jpeg:0=[${MULTILIB_USEDEP}] )
97         ldap? ( net-nds/openldap:=[${MULTILIB_USEDEP}] )
98         lcms? ( media-libs/lcms:2=[${MULTILIB_USEDEP}] )
99         mp3? ( >=media-sound/mpg123-1.5.0[${MULTILIB_USEDEP}] )
100         netapi? ( net-fs/samba[netapi(+),${MULTILIB_USEDEP}] )
101         nls? ( sys-devel/gettext[${MULTILIB_USEDEP}] )
102         odbc? ( dev-db/unixODBC:=[${MULTILIB_USEDEP}] )
103         osmesa? ( media-libs/mesa[osmesa,${MULTILIB_USEDEP}] )
104         pcap? ( net-libs/libpcap[${MULTILIB_USEDEP}] )
105         pulseaudio? ( media-sound/pulseaudio[${MULTILIB_USEDEP}] )
106         staging? ( sys-apps/attr[${MULTILIB_USEDEP}] )
107         xml? (
108                 dev-libs/libxml2[${MULTILIB_USEDEP}]
109                 dev-libs/libxslt[${MULTILIB_USEDEP}]
110         )
111         scanner? ( media-gfx/sane-backends:=[${MULTILIB_USEDEP}] )
112         ssl? ( net-libs/gnutls:=[${MULTILIB_USEDEP}] )
113         png? ( media-libs/libpng:0=[${MULTILIB_USEDEP}] )
114         v4l? ( media-libs/libv4l[${MULTILIB_USEDEP}] )
115         vaapi? ( x11-libs/libva[X,${MULTILIB_USEDEP}] )
116         xcomposite? ( x11-libs/libXcomposite[${MULTILIB_USEDEP}] )
117         abi_x86_32? (
118                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
119                 !<app-emulation/emul-linux-x86-baselibs-20140508-r14
120                 !app-emulation/emul-linux-x86-db[-abi_x86_32(-)]
121                 !<app-emulation/emul-linux-x86-db-20140508-r3
122                 !app-emulation/emul-linux-x86-medialibs[-abi_x86_32(-)]
123                 !<app-emulation/emul-linux-x86-medialibs-20140508-r6
124                 !app-emulation/emul-linux-x86-opengl[-abi_x86_32(-)]
125                 !<app-emulation/emul-linux-x86-opengl-20140508-r1
126                 !app-emulation/emul-linux-x86-sdl[-abi_x86_32(-)]
127                 !<app-emulation/emul-linux-x86-sdl-20140508-r1
128                 !app-emulation/emul-linux-x86-soundlibs[-abi_x86_32(-)]
129                 !<app-emulation/emul-linux-x86-soundlibs-20140508
130                 !app-emulation/emul-linux-x86-xlibs[-abi_x86_32(-)]
131                 !<app-emulation/emul-linux-x86-xlibs-20140508
132         )"
133
134 RDEPEND="${COMMON_DEPEND}
135         dos? ( games-emulation/dosbox )
136         perl? ( dev-lang/perl dev-perl/XML-Simple )
137         s3tc? ( >=media-libs/libtxc_dxtn-1.0.1-r1[${MULTILIB_USEDEP}] )
138         samba? ( >=net-fs/samba-3.0.25 )
139         selinux? ( sec-policy/selinux-wine )
140         udisks? ( sys-fs/udisks:2 )
141         pulseaudio? ( realtime? ( sys-auth/rtkit ) )"
142
143 # tools/make_requests requires perl
144 DEPEND="${COMMON_DEPEND}
145         staging? ( dev-lang/perl dev-perl/XML-Simple )
146         X? (
147                 x11-proto/inputproto
148                 x11-proto/xextproto
149                 x11-proto/xf86vidmodeproto
150         )
151         xinerama? ( x11-proto/xineramaproto )
152         prelink? ( sys-devel/prelink )
153         >=sys-kernel/linux-headers-2.6
154         virtual/pkgconfig
155         virtual/yacc
156         sys-devel/flex"
157
158 # These use a non-standard "Wine" category, which is provided by
159 # /etc/xdg/applications-merged/wine.menu
160 QA_DESKTOP_FILE="usr/share/applications/wine-browsedrive.desktop
161 usr/share/applications/wine-notepad.desktop
162 usr/share/applications/wine-uninstaller.desktop
163 usr/share/applications/wine-winecfg.desktop"
164
165 wine_build_environment_check() {
166         [[ ${MERGE_TYPE} = "binary" ]] && return 0
167
168         # bug #549768
169         if use abi_x86_64 && [[ $(gcc-major-version) = 5 && $(gcc-minor-version) -le 2 ]]; then
170                 einfo "Checking for gcc-5 ms_abi compiler bug ..."
171                 $(tc-getCC) -O2 "${FILESDIR}"/pr66838.c -o "${T}"/pr66838 || die
172                 # Run in subshell to prevent "Aborted" message
173                 if ! ( "${T}"/pr66838 || false ) >/dev/null 2>&1; then
174                         eerror "64-bit wine cannot be built with gcc-5.1 or initial patchset of 5.2.0"
175                         eerror "due to compiler bugs; please re-emerge the latest gcc-5.2.x ebuild,"
176                         eerror "or use gcc-config to select a different compiler version."
177                         eerror "See https://bugs.gentoo.org/549768"
178                         eerror
179                         return 1
180                 fi
181         fi
182
183         if use abi_x86_64 && [[ $(( $(gcc-major-version) * 100 + $(gcc-minor-version) )) -lt 404 ]]; then
184                 eerror "You need gcc-4.4+ to build 64-bit wine"
185                 eerror
186                 return 1
187         fi
188
189         if use abi_x86_32 && use opencl && [[ x$(eselect opencl show 2> /dev/null) = "xintel" ]]; then
190                 eerror "You cannot build wine with USE=opencl because intel-ocl-sdk is 64-bit only."
191                 eerror "See https://bugs.gentoo.org/487864 for more details."
192                 eerror
193                 return 1
194         fi
195 }
196
197 pkg_pretend() {
198         wine_build_environment_check || die
199 }
200
201 pkg_setup() {
202         wine_build_environment_check || die
203 }
204
205 src_unpack() {
206         if [[ ${PV} == "9999" ]] ; then
207                 git-r3_src_unpack
208                 if use staging || use pulseaudio; then
209                         EGIT_REPO_URI=${STAGING_EGIT_REPO_URI}
210                         unset ${PN}_LIVE_REPO;
211                         EGIT_CHECKOUT_DIR=${STAGING_DIR} git-r3_src_unpack
212                 fi
213         else
214                 unpack ${MY_P}.tar.bz2
215                 use staging || use pulseaudio && unpack "${STAGING_P}.tar.gz"
216         fi
217
218         unpack "${WINE_GENTOO}.tar.bz2"
219         use gstreamer && unpack "${GST_P}.patch.bz2"
220
221         l10n_find_plocales_changes "${S}/po" "" ".po"
222 }
223
224 src_prepare() {
225         local md5="$(md5sum server/protocol.def)"
226         local PATCHES=(
227                 "${FILESDIR}"/${PN}-1.5.26-winegcc.patch #260726
228                 "${FILESDIR}"/${PN}-1.4_rc2-multilib-portage.patch #395615
229                 "${FILESDIR}"/${PN}-1.7.12-osmesa-check.patch #429386
230                 "${FILESDIR}"/${PN}-1.6-memset-O3.patch #480508
231         )
232         if use gstreamer; then
233                 # See http://bugs.winehq.org/show_bug.cgi?id=30557
234                 ewarn "Applying experimental patch to fix GStreamer support. Note that"
235                 ewarn "this patch has been reported to cause crashes in certain games."
236
237                 # Wine-Staging 1.7.38 "ntdll: Fix race-condition when threads are killed
238                 # during shutdown" patch and "Added patch to implement shared memory
239                 # wineserver communication for various user32 functions" prevents the
240                 # gstreamer patch from applying cleanly.
241                 # So undo the staging patch, apply gstreamer, then re-apply rebased staging
242                 # patch on top.
243                 if use staging; then
244                         PATCHES+=(
245                                 "${FILESDIR}/${PN}-1.7.39-gstreamer-v5-staging-pre.patch"
246                                 "${WORKDIR}/${GST_P}.patch"
247                                 "${FILESDIR}/${PN}-1.7.39-gstreamer-v5-staging-post.patch" )
248                 else
249                         PATCHES+=( "${WORKDIR}/${GST_P}.patch" )
250                 fi
251         fi
252         if use staging; then
253                 ewarn "Applying the unofficial Wine-Staging patchset which is unsupported"
254                 ewarn "by Wine developers. Please don't report bugs to Wine bugzilla"
255                 ewarn "unless you can reproduce them with USE=-staging"
256
257                 local STAGING_EXCLUDE=""
258                 use pipelight || STAGING_EXCLUDE="${STAGING_EXCLUDE} -W Pipelight"
259
260                 # Launch wine-staging patcher in a subshell, using epatch as a backend, and gitapply.sh as a backend for binary patches
261                 ebegin "Running Wine-Staging patch installer"
262                 (
263                         set -- DESTDIR="${S}" --backend=epatch --no-autoconf --all ${STAGING_EXCLUDE}
264                         cd "${STAGING_DIR}/patches"
265                         source "${STAGING_DIR}/patches/patchinstall.sh"
266                 )
267                 eend $?
268         elif use pulseaudio; then
269                 PATCHES+=( "${STAGING_DIR}/patches/winepulse-PulseAudio_Support"/*.patch )
270         fi
271         autotools-utils_src_prepare
272
273         # Modification of the server protocol requires regenerating the server requests
274         if [[ "$(md5sum server/protocol.def)" != "${md5}" ]]; then
275                 einfo "server/protocol.def was patched; running tools/make_requests"
276                 tools/make_requests || die #432348
277         fi
278         sed -i '/^UPDATE_DESKTOP_DATABASE/s:=.*:=true:' tools/Makefile.in || die
279         if ! use run-exes; then
280                 sed -i '/^MimeType/d' tools/wine.desktop || die #117785
281         fi
282
283         # hi-res default icon, #472990, http://bugs.winehq.org/show_bug.cgi?id=24652
284         cp "${WORKDIR}"/${WINE_GENTOO}/icons/oic_winlogo.ico dlls/user32/resources/ || die
285
286         l10n_get_locales > po/LINGUAS # otherwise wine doesn't respect LINGUAS
287 }
288
289 src_configure() {
290         export LDCONFIG=/bin/true
291         use custom-cflags || strip-flags
292
293         multilib-minimal_src_configure
294 }
295
296 multilib_src_configure() {
297         local myconf=(
298                 --sysconfdir=/etc/wine
299                 $(use_with alsa)
300                 $(use_with capi)
301                 $(use_with lcms cms)
302                 $(use_with cups)
303                 $(use_with ncurses curses)
304                 $(use_with udisks dbus)
305                 $(use_with fontconfig)
306                 $(use_with ssl gnutls)
307                 $(use_enable gecko mshtml)
308                 $(use_with gphoto2 gphoto)
309                 $(use_with gsm)
310                 $(use_with gstreamer)
311                 --without-hal
312                 $(use_with jpeg)
313                 $(use_with ldap)
314                 $(use_enable mono mscoree)
315                 $(use_with mp3 mpg123)
316                 $(use_with netapi)
317                 $(use_with nls gettext)
318                 $(use_with openal)
319                 $(use_with opencl)
320                 $(use_with opengl)
321                 $(use_with osmesa)
322                 $(use_with oss)
323                 $(use_with pcap)
324                 $(use_with png)
325                 $(use_with threads pthread)
326                 $(use_with scanner sane)
327                 $(use_enable test tests)
328                 $(use_with truetype freetype)
329                 $(use_with v4l)
330                 $(use_with X x)
331                 $(use_with xcomposite)
332                 $(use_with xinerama)
333                 $(use_with xml)
334                 $(use_with xml xslt)
335         )
336
337         if use pulseaudio || use staging; then
338                 myconf+=( $(use_with pulseaudio pulse) )
339         fi
340         use staging && myconf+=(
341                 --with-xattr
342                 $(use_with vaapi va)
343         )
344
345         local PKG_CONFIG AR RANLIB
346         # Avoid crossdev's i686-pc-linux-gnu-pkg-config if building wine32 on amd64; #472038
347         # set AR and RANLIB to make QA scripts happy; #483342
348         tc-export PKG_CONFIG AR RANLIB
349
350         if use amd64; then
351                 if [[ ${ABI} == amd64 ]]; then
352                         myconf+=( --enable-win64 )
353                 else
354                         myconf+=( --disable-win64 )
355                 fi
356
357                 # Note: using --with-wine64 results in problems with multilib.eclass
358                 # CC/LD hackery. We're using separate tools instead.
359         fi
360
361         ECONF_SOURCE=${S} \
362         econf "${myconf[@]}"
363         emake depend
364 }
365
366 multilib_src_test() {
367         # FIXME: win32-only; wine64 tests fail with "could not find the Wine loader"
368         if [[ ${ABI} == x86 ]]; then
369                 if [[ $(id -u) == 0 ]]; then
370                         ewarn "Skipping tests since they cannot be run under the root user."
371                         ewarn "To run the test ${PN} suite, add userpriv to FEATURES in make.conf"
372                         return
373                 fi
374
375                 WINEPREFIX="${T}/.wine-${ABI}" \
376                 Xemake test
377         fi
378 }
379
380 multilib_src_install_all() {
381         local DOCS=( ANNOUNCE AUTHORS README )
382         local l
383         add_locale_docs() {
384                 local locale_doc="documentation/README.$1"
385                 [[ ! -e ${locale_doc} ]] || DOCS+=( ${locale_doc} )
386         }
387         l10n_for_each_locale_do add_locale_docs
388
389         einstalldocs
390         prune_libtool_files --all
391
392         emake -C "../${WINE_GENTOO}" install DESTDIR="${D}" EPREFIX="${EPREFIX}"
393         if use gecko ; then
394                 insinto /usr/share/wine/gecko
395                 use abi_x86_32 && doins "${DISTDIR}"/wine_gecko-${GV}-x86.msi
396                 use abi_x86_64 && doins "${DISTDIR}"/wine_gecko-${GV}-x86_64.msi
397         fi
398         if use mono ; then
399                 insinto /usr/share/wine/mono
400                 doins "${DISTDIR}"/wine-mono-${MV}.msi
401         fi
402         if ! use perl ; then # winedump calls function_grep.pl, and winemaker is a perl script
403                 rm "${D}"usr/bin/{wine{dump,maker},function_grep.pl} "${D}"usr/share/man/man1/wine{dump,maker}.1 || die
404         fi
405
406         use abi_x86_32 && pax-mark psmr "${D}"usr/bin/wine{,-preloader} #255055
407         use abi_x86_64 && pax-mark psmr "${D}"usr/bin/wine64{,-preloader}
408
409         if use abi_x86_64 && ! use abi_x86_32; then
410                 dosym /usr/bin/wine{64,} # 404331
411                 dosym /usr/bin/wine{64,}-preloader
412         fi
413
414         # respect LINGUAS when installing man pages, #469418
415         for l in de fr pl; do
416                 use linguas_${l} || rm -r "${D}"usr/share/man/${l}*
417         done
418 }
419
420 pkg_preinst() {
421         gnome2_icon_savelist
422 }
423
424 pkg_postinst() {
425         gnome2_icon_cache_update
426         fdo-mime_desktop_database_update
427
428         if ! use gecko; then
429                 ewarn "Without Wine Gecko, wine prefixes will not have a default"
430                 ewarn "implementation of iexplore.  Many older windows applications"
431                 ewarn "rely upon the existence of an iexplore implementation, so"
432                 ewarn "you will likely need to install an external one, like via winetricks"
433         fi
434         if ! use mono; then
435                 ewarn "Without Wine Mono, wine prefixes will not have a default"
436                 ewarn "implementation of .NET.  Many windows applications rely upon"
437                 ewarn "the existence of a .NET implementation, so you will likely need"
438                 ewarn "to install an external one, like via winetricks"
439         fi
440 }
441
442 pkg_postrm() {
443         gnome2_icon_cache_update
444         fdo-mime_desktop_database_update
445 }