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