1ca4f55540c554fbd84d49cf582c72bdc8e39e1e
[gentoo.git] / app-emulation / wine-staging / wine-staging-9999.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PLOCALES="ar ast 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 si sk sl sr_RS@cyrillic sr_RS@latin sv ta te th tr uk wa zh_CN zh_TW"
7 PLOCALE_BACKUP="en"
8
9 inherit autotools eapi7-ver estack eutils flag-o-matic gnome2-utils l10n ltprune multilib multilib-minimal pax-utils toolchain-funcs virtualx xdg-utils
10
11 MY_PN="${PN%%-*}"
12 MY_P="${MY_PN}-${PV}"
13
14 if [[ ${PV} == "9999" ]] ; then
15         EGIT_REPO_URI="https://source.winehq.org/git/wine.git"
16         EGIT_BRANCH="master"
17         inherit git-r3
18         SRC_URI=""
19         #KEYWORDS=""
20 else
21         MAJOR_V=$(ver_cut 1)
22         SRC_URI="https://dl.winehq.org/wine/source/${MAJOR_V}.x/${MY_P}.tar.xz"
23         KEYWORDS="-* ~amd64 ~x86"
24 fi
25 S="${WORKDIR}/${MY_P}"
26
27 STAGING_P="wine-staging-${PV}"
28 STAGING_DIR="${WORKDIR}/${STAGING_P}"
29 GWP_V="20191222"
30 PATCHDIR="${WORKDIR}/gentoo-wine-patches"
31
32 DESCRIPTION="Free implementation of Windows(tm) on Unix, with Wine-Staging patchset"
33 HOMEPAGE="https://www.winehq.org/"
34 SRC_URI="${SRC_URI}
35         https://dev.gentoo.org/~sarnex/distfiles/wine/gentoo-wine-patches-${GWP_V}.tar.xz
36 "
37
38 if [[ ${PV} == "9999" ]] ; then
39         STAGING_EGIT_REPO_URI="https://github.com/wine-staging/wine-staging.git"
40 else
41         SRC_URI="${SRC_URI}
42         staging? ( https://github.com/wine-staging/wine-staging/archive/v${PV}.tar.gz -> ${STAGING_P}.tar.gz )"
43 fi
44
45 LICENSE="LGPL-2.1"
46 SLOT="${PV}"
47 IUSE="+abi_x86_32 +abi_x86_64 +alsa capi cups custom-cflags dos elibc_glibc +faudio +fontconfig +gecko gphoto2 gsm gssapi gstreamer +jpeg kerberos kernel_FreeBSD +lcms ldap +mono mp3 ncurses netapi nls odbc openal opencl +opengl osmesa oss +perl pcap pipelight +png prelink pulseaudio +realtime +run-exes samba scanner sdl selinux +ssl staging test themes +threads +truetype udev +udisks v4l vaapi vkd3d vulkan +X +xcomposite xinerama +xml"
48 REQUIRED_USE="|| ( abi_x86_32 abi_x86_64 )
49         X? ( truetype )
50         elibc_glibc? ( threads )
51         osmesa? ( opengl )
52         pipelight? ( staging )
53         test? ( abi_x86_32 )
54         themes? ( staging )
55         vaapi? ( staging )
56         vkd3d? ( vulkan )" # osmesa-opengl #286560 # X-truetype #551124
57
58 # FIXME: the test suite is unsuitable for us; many tests require net access
59 # or fail due to Xvfb's opengl limitations.
60 RESTRICT="test"
61
62 COMMON_DEPEND="
63         X? (
64                 x11-libs/libXcursor[${MULTILIB_USEDEP}]
65                 x11-libs/libXext[${MULTILIB_USEDEP}]
66                 x11-libs/libXfixes[${MULTILIB_USEDEP}]
67                 x11-libs/libXrandr[${MULTILIB_USEDEP}]
68                 x11-libs/libXi[${MULTILIB_USEDEP}]
69                 x11-libs/libXxf86vm[${MULTILIB_USEDEP}]
70         )
71         alsa? ( media-libs/alsa-lib[${MULTILIB_USEDEP}] )
72         capi? ( net-libs/libcapi[${MULTILIB_USEDEP}] )
73         cups? ( net-print/cups:=[${MULTILIB_USEDEP}] )
74         faudio? ( app-emulation/faudio:=[${MULTILIB_USEDEP}] )
75         fontconfig? ( media-libs/fontconfig:=[${MULTILIB_USEDEP}] )
76         gphoto2? ( media-libs/libgphoto2:=[${MULTILIB_USEDEP}] )
77         gsm? ( media-sound/gsm:=[${MULTILIB_USEDEP}] )
78         gssapi? ( virtual/krb5[${MULTILIB_USEDEP}] )
79         gstreamer? (
80                 media-libs/gstreamer:1.0[${MULTILIB_USEDEP}]
81                 media-plugins/gst-plugins-meta:1.0[${MULTILIB_USEDEP}]
82         )
83         jpeg? ( virtual/jpeg:0=[${MULTILIB_USEDEP}] )
84         kerberos? ( virtual/krb5:0=[${MULTILIB_USEDEP}] )
85         lcms? ( media-libs/lcms:2=[${MULTILIB_USEDEP}] )
86         ldap? ( net-nds/openldap:=[${MULTILIB_USEDEP}] )
87         mp3? ( >=media-sound/mpg123-1.5.0[${MULTILIB_USEDEP}] )
88         ncurses? ( >=sys-libs/ncurses-5.2:0=[${MULTILIB_USEDEP}] )
89         netapi? ( net-fs/samba[netapi(+),${MULTILIB_USEDEP}] )
90         nls? ( sys-devel/gettext[${MULTILIB_USEDEP}] )
91         odbc? ( dev-db/unixODBC:=[${MULTILIB_USEDEP}] )
92         openal? ( media-libs/openal:=[${MULTILIB_USEDEP}] )
93         opencl? ( virtual/opencl[${MULTILIB_USEDEP}] )
94         opengl? (
95                 virtual/glu[${MULTILIB_USEDEP}]
96                 virtual/opengl[${MULTILIB_USEDEP}]
97         )
98         osmesa? ( >=media-libs/mesa-13[osmesa,${MULTILIB_USEDEP}] )
99         pcap? ( net-libs/libpcap[${MULTILIB_USEDEP}] )
100         png? ( media-libs/libpng:0=[${MULTILIB_USEDEP}] )
101         pulseaudio? ( media-sound/pulseaudio[${MULTILIB_USEDEP}] )
102         scanner? ( media-gfx/sane-backends:=[${MULTILIB_USEDEP}] )
103         sdl? ( media-libs/libsdl2:=[haptic,joystick,${MULTILIB_USEDEP}] )
104         ssl? ( net-libs/gnutls:=[${MULTILIB_USEDEP}] )
105         staging? ( sys-apps/attr[${MULTILIB_USEDEP}] )
106         themes? (
107                 dev-libs/glib:2[${MULTILIB_USEDEP}]
108                 x11-libs/cairo[${MULTILIB_USEDEP}]
109                 x11-libs/gtk+:3[${MULTILIB_USEDEP}]
110         )
111         truetype? ( >=media-libs/freetype-2.0.0[${MULTILIB_USEDEP}] )
112         udev? ( virtual/libudev:=[${MULTILIB_USEDEP}] )
113         udisks? ( sys-apps/dbus[${MULTILIB_USEDEP}] )
114         v4l? ( media-libs/libv4l[${MULTILIB_USEDEP}] )
115         vaapi? ( x11-libs/libva[X,${MULTILIB_USEDEP}] )
116         vkd3d? ( app-emulation/vkd3d[${MULTILIB_USEDEP}] )
117         vulkan? ( media-libs/vulkan-loader[${MULTILIB_USEDEP}] )
118         xcomposite? ( x11-libs/libXcomposite[${MULTILIB_USEDEP}] )
119         xinerama? ( x11-libs/libXinerama[${MULTILIB_USEDEP}] )
120         xml? (
121                 dev-libs/libxml2[${MULTILIB_USEDEP}]
122                 dev-libs/libxslt[${MULTILIB_USEDEP}]
123         )"
124
125 RDEPEND="${COMMON_DEPEND}
126         app-emulation/wine-desktop-common
127         >app-eselect/eselect-wine-0.3
128         !app-emulation/wine:0
129         dos? ( >=games-emulation/dosbox-0.74_p20160629 )
130         gecko? ( app-emulation/wine-gecko:2.47.1[abi_x86_32?,abi_x86_64?] )
131         mono? ( app-emulation/wine-mono:4.9.4 )
132         perl? (
133                 dev-lang/perl
134                 dev-perl/XML-Simple
135         )
136         pulseaudio? (
137                 realtime? ( sys-auth/rtkit )
138         )
139         samba? ( >=net-fs/samba-3.0.25[winbind] )
140         selinux? ( sec-policy/selinux-wine )
141         udisks? ( sys-fs/udisks:2 )"
142
143 # tools/make_requests requires perl
144 DEPEND="${COMMON_DEPEND}
145         sys-devel/flex
146         >=sys-kernel/linux-headers-2.6
147         virtual/pkgconfig
148         virtual/yacc
149         X? ( x11-base/xorg-proto )
150         prelink? ( sys-devel/prelink )
151         staging? (
152                 dev-lang/perl
153                 dev-perl/XML-Simple
154         )
155         xinerama? ( x11-base/xorg-proto )"
156
157 # These use a non-standard "Wine" category, which is provided by
158 # /etc/xdg/applications-merged/wine.menu
159 QA_DESKTOP_FILE="usr/share/applications/wine-browsedrive.desktop
160 usr/share/applications/wine-notepad.desktop
161 usr/share/applications/wine-uninstaller.desktop
162 usr/share/applications/wine-winecfg.desktop"
163
164 PATCHES=(
165         "${PATCHDIR}/patches/${MY_PN}-5.0-winegcc.patch" #260726
166         "${PATCHDIR}/patches/${MY_PN}-4.7-multilib-portage.patch" #395615
167         "${PATCHDIR}/patches/${MY_PN}-5.0-memset-O3.patch" #480508
168         "${PATCHDIR}/patches/${MY_PN}-2.0-multislot-apploader.patch" #310611
169 )
170 PATCHES_BIN=()
171
172 # https://bugs.gentoo.org/show_bug.cgi?id=635222
173 if [[ ${#PATCHES_BIN[@]} -ge 1 ]] || [[ ${PV} == 9999 ]]; then
174         DEPEND+=" dev-util/patchbin"
175 fi
176
177 wine_compiler_check() {
178         [[ ${MERGE_TYPE} = "binary" ]] && return 0
179
180         # GCC-specific bugs
181         if tc-is-gcc; then
182                 # bug #549768
183                 if use abi_x86_64 && [[ $(gcc-major-version) = 5 && $(gcc-minor-version) -le 2 ]]; then
184                         ebegin "Checking for gcc-5 ms_abi compiler bug"
185                         $(tc-getCC) -O2 "${PATCHDIR}/files/pr66838.c" -o "${T}"/pr66838 || die
186                         # Run in subshell to prevent "Aborted" message
187                         ( "${T}"/pr66838 || false ) >/dev/null 2>&1
188                         if ! eend $?; then
189                                 eerror "64-bit wine cannot be built with gcc-5.1 or initial patchset of 5.2.0"
190                                 eerror "due to compiler bugs; please re-emerge the latest gcc-5.2.x ebuild,"
191                                 eerror "or use gcc-config to select a different compiler version."
192                                 eerror "See https://bugs.gentoo.org/549768"
193                                 eerror
194                                 return 1
195                         fi
196                 fi
197                 # bug #574044
198                 if use abi_x86_64 && [[ $(gcc-major-version) = 5 && $(gcc-minor-version) = 3 ]]; then
199                         ebegin "Checking for gcc-5-3 stack realignment compiler bug"
200                         # Compile in subshell to prevent "Aborted" message
201                         ( $(tc-getCC) -O2 -mincoming-stack-boundary=3 "${PATCHDIR}/files/pr69140.c" -o "${T}"/pr69140 ) >/dev/null 2>&1
202                         if ! eend $?; then
203                                 eerror "Wine cannot be built with this version of gcc-5.3"
204                                 eerror "due to compiler bugs; please re-emerge the latest gcc-5.3.x ebuild,"
205                                 eerror "or use gcc-config to select a different compiler version."
206                                 eerror "See https://bugs.gentoo.org/574044"
207                                 eerror
208                                 return 1
209                         fi
210                 fi
211         fi
212
213         # Ensure compiler support
214         if use abi_x86_64; then
215                 ebegin "Checking for 64-bit compiler with builtin_ms_va_list support"
216                 # Compile in subshell to prevent "Aborted" message
217                 ( $(tc-getCC) -O2 "${PATCHDIR}/files/builtin_ms_va_list.c" -o "${T}"/builtin_ms_va_list >/dev/null 2>&1)
218                 if ! eend $?; then
219                         eerror "This version of $(tc-getCC) does not support builtin_ms_va_list, can't enable 64-bit wine"
220                         eerror
221                         eerror "You need gcc-4.4+ or clang 3.8+ to build 64-bit wine"
222                         eerror
223                         return 1
224                 fi
225         fi
226 }
227
228 wine_build_environment_check() {
229         [[ ${MERGE_TYPE} = "binary" ]] && return 0
230
231         if use abi_x86_64; then
232                 if tc-is-gcc && [[ $(gcc-major-version) -lt 4 || ( $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 4 ) ]]; then
233                         eerror "You need gcc-4.4+ to compile 64-bit wine"
234                         die
235                 elif tc-is-clang && [[ $(clang-major-version) -lt 3 || ( $(clang-major-version) -eq 3 && $(clang-minor-version) -lt 8 ) ]]; then
236                         eerror "You need clang-3.8+ to compile 64-bit wine"
237                         die
238                 fi
239         fi
240         if tc-is-gcc && [[ $(gcc-major-version) -eq 5 && $(gcc-minor-version) -le 3 ]]; then
241                 ewarn "GCC-5.0-5.3 suffered from compiler bugs and are no longer supported by"
242                 ewarn "Gentoo's Toolchain Team. If your ebuild fails the compiler checks in"
243                 ewarn "the configure phase, either update your compiler or switch to <5.0 || >=5.4"
244         fi
245         if tc-is-gcc && [[ $(gcc-major-version) -eq 5 && $(gcc-minor-version) -eq 4 ]]; then
246                 if has "-march=i686" ${CFLAGS} && ! has "-mtune=generic" ${CFLAGS}; then
247                         ewarn "Compilation can hang with CFLAGS=\"-march=i686\".  You can temporarily work"
248                         ewarn "around this by adding \"-mtune=generic\" to your CFLAGS for wine."
249                         ewarn "See package.env in man 5 portage for more information on how to do this."
250                         ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=613128 for more details"
251                 fi
252         fi
253
254         if use abi_x86_32 && use opencl && [[ "$(eselect opencl show 2> /dev/null)" == "intel" ]]; then
255                 eerror "You cannot build wine with USE=opencl because intel-ocl-sdk is 64-bit only."
256                 eerror "See https://bugs.gentoo.org/487864 for more details."
257                 eerror
258                 return 1
259         fi
260 }
261
262 wine_env_vcs_vars() {
263         local pn_live_var="${PN//[-+]/_}_LIVE_COMMIT"
264         local pn_live_val="${pn_live_var}"
265         eval pn_live_val='$'${pn_live_val}
266         if [[ ! -z ${pn_live_val} ]]; then
267                 if use staging; then
268                         eerror "Because of the multi-repo nature of ${MY_PN}, ${pn_live_var}"
269                         eerror "cannot be used to set the commit. Instead, you may use the"
270                         eerror "environment variables:"
271                         eerror "  EGIT_OVERRIDE_COMMIT_WINE"
272                         eerror "  EGIT_OVERRIDE_COMMIT_WINE_STAGING_WINE_STAGING"
273                         eerror
274                         return 1
275                 fi
276         fi
277         if [[ ! -z ${EGIT_COMMIT} ]]; then
278                 eerror "Commits must now be specified using the environment variables:"
279                 eerror "  EGIT_OVERRIDE_COMMIT_WINE"
280                 eerror "  EGIT_OVERRIDE_COMMIT_WINE_STAGING_WINE_STAGING"
281                 eerror
282                 return 1
283         fi
284 }
285
286 pkg_pretend() {
287         wine_build_environment_check || die
288
289         # Verify OSS support
290         if use oss && ! use kernel_FreeBSD; then
291                 if ! has_version ">=media-sound/oss-4"; then
292                         eerror "You cannot build wine with USE=oss without having support from a"
293                         eerror "FreeBSD kernel or >=media-sound/oss-4 (only available through external repos)"
294                         eerror
295                         die
296                 fi
297         fi
298 }
299
300 pkg_setup() {
301         wine_build_environment_check || die
302         wine_env_vcs_vars || die
303
304         WINE_VARIANT="${PN#wine}-${PV}"
305         WINE_VARIANT="${WINE_VARIANT#-}"
306
307         MY_PREFIX="${EPREFIX}/usr/lib/wine-${WINE_VARIANT}"
308         MY_DATAROOTDIR="${EPREFIX}/usr/share/wine-${WINE_VARIANT}"
309         MY_DATADIR="${MY_DATAROOTDIR}"
310         MY_DOCDIR="${EPREFIX}/usr/share/doc/${PF}"
311         MY_INCLUDEDIR="${EPREFIX}/usr/include/wine-${WINE_VARIANT}"
312         MY_LIBEXECDIR="${EPREFIX}/usr/libexec/wine-${WINE_VARIANT}"
313         MY_LOCALSTATEDIR="${EPREFIX}/var/wine-${WINE_VARIANT}"
314         MY_MANDIR="${MY_DATADIR}/man"
315 }
316
317 src_unpack() {
318         if [[ ${PV} == "9999" ]] ; then
319                 EGIT_CHECKOUT_DIR="${S}" git-r3_src_unpack
320                 if use staging; then
321                         local CURRENT_WINE_COMMIT=${EGIT_VERSION}
322
323                         EGIT_CHECKOUT_DIR="${STAGING_DIR}" EGIT_REPO_URI="${STAGING_EGIT_REPO_URI}" git-r3_src_unpack
324
325                         local COMPAT_WINE_COMMIT=$("${STAGING_DIR}/patches/patchinstall.sh" --upstream-commit) || die
326
327                         if [[ "${CURRENT_WINE_COMMIT}" != "${COMPAT_WINE_COMMIT}" ]]; then
328                                 einfo "The current Staging patchset is not guaranteed to apply on this WINE commit."
329                                 einfo "If src_prepare fails, try emerging with the env var WINE_COMMIT."
330                                 einfo "Example: EGIT_OVERRIDE_COMMIT_WINE=${COMPAT_WINE_COMMIT} emerge -1 wine"
331                         fi
332                 fi
333         fi
334
335         default
336
337         l10n_find_plocales_changes "${S}/po" "" ".po"
338 }
339
340 src_prepare() {
341
342         eapply_bin(){
343                 local patch
344                 for patch in ${PATCHES_BIN[@]}; do
345                         patchbin --nogit < "${patch}" || die
346                 done
347         }
348
349         local md5="$(md5sum server/protocol.def)"
350
351         if use staging; then
352                 ewarn "Applying the Wine-Staging patchset. Any bug reports to the"
353                 ewarn "Wine bugzilla should explicitly state that staging was used."
354
355                 local STAGING_EXCLUDE=""
356                 use pipelight || STAGING_EXCLUDE="${STAGING_EXCLUDE} -W Pipelight"
357
358                 # Launch wine-staging patcher in a subshell, using eapply as a backend, and gitapply.sh as a backend for binary patches
359                 ebegin "Running Wine-Staging patch installer"
360                 (
361                         set -- DESTDIR="${S}" --backend=eapply --no-autoconf --all ${STAGING_EXCLUDE}
362                         cd "${STAGING_DIR}/patches"
363                         source "${STAGING_DIR}/patches/patchinstall.sh"
364                 )
365                 eend $? || die "Failed to apply Wine-Staging patches"
366         fi
367
368         default
369         eapply_bin
370         eautoreconf
371
372         # Modification of the server protocol requires regenerating the server requests
373         if [[ "$(md5sum server/protocol.def)" != "${md5}" ]]; then
374                 einfo "server/protocol.def was patched; running tools/make_requests"
375                 tools/make_requests || die #432348
376         fi
377         sed -i '/^UPDATE_DESKTOP_DATABASE/s:=.*:=true:' tools/Makefile.in || die
378         if ! use run-exes; then
379                 sed -i '/^MimeType/d' loader/wine.desktop || die #117785
380         fi
381
382         # Edit wine.desktop to work for specific variant
383         sed -e "/^Exec=/s/wine /wine-${WINE_VARIANT} /" -i loader/wine.desktop || die
384
385         # hi-res default icon, #472990, https://bugs.winehq.org/show_bug.cgi?id=24652
386         cp "${PATCHDIR}/files/oic_winlogo.ico" dlls/user32/resources/ || die
387
388         l10n_get_locales > po/LINGUAS || die # otherwise wine doesn't respect LINGUAS
389
390         # Fix manpage generation for locales #469418 and abi_x86_64 #617864
391
392         # Duplicate manpages input files for wine64
393         local f
394         for f in loader/*.man.in; do
395                 cp ${f} ${f/wine/wine64} || die
396         done
397         # Add wine64 manpages to Makefile
398         if use abi_x86_64; then
399                 sed -i "/wine.man.in/i \
400                         \\\twine64.man.in \\\\" loader/Makefile.in || die
401                 sed -i -E 's/(.*wine)(.*\.UTF-8\.man\.in.*)/&\
402 \164\2/' loader/Makefile.in || die
403         fi
404
405         rm_man_file(){
406                 local file="${1}"
407                 loc=${2}
408                 sed -i "/${loc}\.UTF-8\.man\.in/d" "${file}" || die
409         }
410
411         while read f; do
412                 l10n_for_each_disabled_locale_do rm_man_file "${f}"
413         done < <(find -name "Makefile.in" -exec grep -q "UTF-8.man.in" "{}" \; -print)
414 }
415
416 src_configure() {
417         wine_compiler_check || die
418
419         export LDCONFIG=/bin/true
420         use custom-cflags || strip-flags
421
422         multilib-minimal_src_configure
423 }
424
425 multilib_src_configure() {
426         local myconf=(
427                 --prefix="${MY_PREFIX}"
428                 --datarootdir="${MY_DATAROOTDIR}"
429                 --datadir="${MY_DATADIR}"
430                 --docdir="${MY_DOCDIR}"
431                 --includedir="${MY_INCLUDEDIR}"
432                 --libdir="${EPREFIX}/usr/$(get_libdir)/wine-${WINE_VARIANT}"
433                 --libexecdir="${MY_LIBEXECDIR}"
434                 --localstatedir="${MY_LOCALSTATEDIR}"
435                 --mandir="${MY_MANDIR}"
436                 --sysconfdir="${EPREFIX}/etc/wine"
437                 $(use_with alsa)
438                 $(use_with capi)
439                 $(use_with lcms cms)
440                 $(use_with cups)
441                 $(use_with ncurses curses)
442                 $(use_with udisks dbus)
443                 $(use_with faudio)
444                 $(use_with fontconfig)
445                 $(use_with ssl gnutls)
446                 $(use_enable gecko mshtml)
447                 $(use_with gphoto2 gphoto)
448                 $(use_with gsm)
449                 $(use_with gssapi)
450                 $(use_with gstreamer)
451                 --without-hal
452                 $(use_with jpeg)
453                 $(use_with kerberos krb5)
454                 $(use_with ldap)
455                 --without-mingw # linux LDFLAGS leak in mingw32: bug #685172
456                 $(use_enable mono mscoree)
457                 $(use_with mp3 mpg123)
458                 $(use_with netapi)
459                 $(use_with nls gettext)
460                 $(use_with openal)
461                 $(use_with opencl)
462                 $(use_with opengl)
463                 $(use_with osmesa)
464                 $(use_with oss)
465                 $(use_with pcap)
466                 $(use_with png)
467                 $(use_with pulseaudio pulse)
468                 $(use_with threads pthread)
469                 $(use_with scanner sane)
470                 $(use_with sdl)
471                 $(use_enable test tests)
472                 $(use_with truetype freetype)
473                 $(use_with udev)
474                 $(use_with v4l v4l2)
475                 $(use_with vkd3d)
476                 $(use_with vulkan)
477                 $(use_with X x)
478                 $(use_with X xfixes)
479                 $(use_with xcomposite)
480                 $(use_with xinerama)
481                 $(use_with xml)
482                 $(use_with xml xslt)
483         )
484
485         use staging && myconf+=(
486                 --with-xattr
487                 $(use_with themes gtk3)
488                 $(use_with vaapi va)
489         )
490
491         local PKG_CONFIG AR RANLIB
492         # Avoid crossdev's i686-pc-linux-gnu-pkg-config if building wine32 on amd64; #472038
493         # set AR and RANLIB to make QA scripts happy; #483342
494         tc-export PKG_CONFIG AR RANLIB
495
496         if use amd64; then
497                 if [[ ${ABI} == amd64 ]]; then
498                         myconf+=( --enable-win64 )
499                 else
500                         myconf+=( --disable-win64 )
501                 fi
502
503                 # Note: using --with-wine64 results in problems with multilib.eclass
504                 # CC/LD hackery. We're using separate tools instead.
505         fi
506
507         ECONF_SOURCE=${S} \
508         econf "${myconf[@]}"
509         emake depend
510 }
511
512 multilib_src_test() {
513         # FIXME: win32-only; wine64 tests fail with "could not find the Wine loader"
514         if [[ ${ABI} == x86 ]]; then
515                 if [[ $(id -u) == 0 ]]; then
516                         ewarn "Skipping tests since they cannot be run under the root user."
517                         ewarn "To run the test ${MY_PN} suite, add userpriv to FEATURES in make.conf"
518                         return
519                 fi
520
521                 WINEPREFIX="${T}/.wine-${ABI}" \
522                 Xemake test
523         fi
524 }
525
526 multilib_src_install_all() {
527         local DOCS=( ANNOUNCE AUTHORS README )
528         add_locale_docs() {
529                 local locale_doc="documentation/README.$1"
530                 [[ ! -e ${locale_doc} ]] || DOCS+=( ${locale_doc} )
531         }
532         l10n_for_each_locale_do add_locale_docs
533
534         einstalldocs
535         prune_libtool_files --all
536
537         if ! use perl ; then # winedump calls function_grep.pl, and winemaker is a perl script
538                 rm "${D%/}${MY_PREFIX}"/bin/{wine{dump,maker},function_grep.pl} \
539                         "${D%/}${MY_MANDIR}"/man1/wine{dump,maker}.1 || die
540         fi
541
542         # Remove wineconsole if neither backend is installed #551124
543         if ! use X && ! use ncurses; then
544                 rm "${D%/}${MY_PREFIX}"/bin/wineconsole* || die
545                 rm "${D%/}${MY_MANDIR}"/man1/wineconsole* || die
546                 rm_wineconsole() {
547                         rm "${D%/}${MY_PREFIX}/$(get_libdir)"/wine/{,fakedlls/}wineconsole.exe* || die
548                 }
549                 multilib_foreach_abi rm_wineconsole
550         fi
551
552         use abi_x86_32 && pax-mark psmr "${D%/}${MY_PREFIX}"/bin/wine{,-preloader} #255055
553         use abi_x86_64 && pax-mark psmr "${D%/}${MY_PREFIX}"/bin/wine64{,-preloader}
554
555         # Avoid double prefix from dosym and make_wrapper
556         MY_PREFIX=${MY_PREFIX#${EPREFIX}}
557
558         if use abi_x86_64 && ! use abi_x86_32; then
559                 dosym wine64 "${MY_PREFIX}"/bin/wine # 404331
560                 dosym wine64-preloader "${MY_PREFIX}"/bin/wine-preloader
561         fi
562
563         # Failglob for binloops, shouldn't be necessary, but including to stay safe
564         eshopts_push -s failglob #615218
565         # Make wrappers for binaries for handling multiple variants
566         # Note: wrappers instead of symlinks because some are shell which use basename
567         local b
568         for b in "${ED%/}${MY_PREFIX}"/bin/*; do
569                 make_wrapper "${b##*/}-${WINE_VARIANT}" "${MY_PREFIX}/bin/${b##*/}"
570         done
571         eshopts_pop
572 }
573
574 pkg_postinst() {
575         eselect wine register ${P}
576         if [[ ${PN} == "wine-vanilla" ]]; then
577                 eselect wine register --vanilla ${P} || die
578         else
579                 if use staging; then
580                         eselect wine register --staging ${P} || die
581                 fi
582         fi
583
584         eselect wine update --all --if-unset || die
585
586         xdg_desktop_database_update
587
588         if ! use gecko; then
589                 ewarn "Without Wine Gecko, wine prefixes will not have a default"
590                 ewarn "implementation of iexplore.  Many older windows applications"
591                 ewarn "rely upon the existence of an iexplore implementation, so"
592                 ewarn "you will likely need to install an external one, like via winetricks"
593         fi
594         if ! use mono; then
595                 ewarn "Without Wine Mono, wine prefixes will not have a default"
596                 ewarn "implementation of .NET.  Many windows applications rely upon"
597                 ewarn "the existence of a .NET implementation, so you will likely need"
598                 ewarn "to install an external one, like via winetricks"
599         fi
600 }
601
602 pkg_prerm() {
603         eselect wine deregister ${P}
604         if [[ ${PN} == "wine-vanilla" ]]; then
605                 eselect wine deregister --vanilla ${P} || die
606         else
607                 if use staging; then
608                         eselect wine deregister --staging ${P} || die
609                 fi
610         fi
611
612         eselect wine update --all --if-unset || die
613 }
614
615 pkg_postrm() {
616         xdg_desktop_database_update
617 }