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