logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

wine-wayland-9999.ebuild (13373B)


  1. # Copyright 1999-2023 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. MULTILIB_COMPAT=( abi_x86_{32,64} )
  5. # note: multilib+wrapper are not unused, currently a pkgcheck false positive
  6. inherit autotools flag-o-matic multilib multilib-build
  7. inherit prefix toolchain-funcs wrapper
  8. WINE_GECKO=2.47.4
  9. WINE_MONO=8.0.0
  10. if [[ ${PV} == *9999 ]]; then
  11. inherit git-r3
  12. EGIT_REPO_URI="https://gitlab.collabora.com/alf/wine.git"
  13. EGIT_BRANCH="wayland"
  14. else
  15. (( $(ver_cut 2) )) && WINE_SDIR=$(ver_cut 1).x || WINE_SDIR=$(ver_cut 1).0
  16. SRC_URI="https://dl.winehq.org/wine/source/${WINE_SDIR}/wine-${PV}.tar.xz"
  17. S="${WORKDIR}/wine-${PV}"
  18. KEYWORDS="-* ~amd64 ~x86"
  19. fi
  20. DESCRIPTION="Free implementation of Windows(tm) on Unix, collabora's wayland branch"
  21. HOMEPAGE="https://gitlab.collabora.com/alf/wine/"
  22. LICENSE="LGPL-2.1+ BSD-2 IJG MIT OPENLDAP ZLIB gsm libpng2 libtiff"
  23. SLOT="${PV}"
  24. IUSE="
  25. +X +abi_x86_32 +abi_x86_64 +alsa capi crossdev-mingw cups dos
  26. llvm-libunwind custom-cflags +fontconfig +gecko gphoto2 +gstreamer
  27. kerberos +mingw +mono netapi nls odbc opencl +opengl osmesa pcap
  28. perl pulseaudio samba scanner +sdl selinux smartcard +ssl +strip
  29. +truetype udev udisks +unwind usb v4l +vulkan wayland wow64
  30. +xcomposite xinerama"
  31. # bug #551124 for truetype
  32. # TODO: wow64 can be done without mingw if using clang (needs bug #912237)
  33. REQUIRED_USE="
  34. X? ( truetype )
  35. xinerama? ( X )
  36. xcomposite? ( X )
  37. wayland? ( truetype )
  38. crossdev-mingw? ( mingw )
  39. wow64? ( abi_x86_64 !abi_x86_32 mingw )"
  40. # tests are non-trivial to run, can hang easily, don't play well with
  41. # sandbox, and several need real opengl/vulkan or network access
  42. RESTRICT="test"
  43. # `grep WINE_CHECK_SONAME configure.ac` + if not directly linked
  44. WINE_DLOPEN_DEPEND="
  45. X? (
  46. x11-libs/libXcursor[${MULTILIB_USEDEP}]
  47. x11-libs/libXfixes[${MULTILIB_USEDEP}]
  48. x11-libs/libXi[${MULTILIB_USEDEP}]
  49. x11-libs/libXrandr[${MULTILIB_USEDEP}]
  50. x11-libs/libXrender[${MULTILIB_USEDEP}]
  51. x11-libs/libXxf86vm[${MULTILIB_USEDEP}]
  52. opengl? (
  53. media-libs/libglvnd[X,${MULTILIB_USEDEP}]
  54. osmesa? ( media-libs/mesa[osmesa,${MULTILIB_USEDEP}] )
  55. )
  56. xcomposite? ( x11-libs/libXcomposite[${MULTILIB_USEDEP}] )
  57. xinerama? ( x11-libs/libXinerama[${MULTILIB_USEDEP}] )
  58. )
  59. cups? ( net-print/cups[${MULTILIB_USEDEP}] )
  60. fontconfig? ( media-libs/fontconfig[${MULTILIB_USEDEP}] )
  61. kerberos? ( virtual/krb5[${MULTILIB_USEDEP}] )
  62. netapi? ( net-fs/samba[${MULTILIB_USEDEP}] )
  63. odbc? ( dev-db/unixODBC[${MULTILIB_USEDEP}] )
  64. sdl? ( media-libs/libsdl2[haptic,joystick,${MULTILIB_USEDEP}] )
  65. ssl? ( net-libs/gnutls:=[${MULTILIB_USEDEP}] )
  66. truetype? ( media-libs/freetype[${MULTILIB_USEDEP}] )
  67. udisks? ( sys-apps/dbus[${MULTILIB_USEDEP}] )
  68. v4l? ( media-libs/libv4l[${MULTILIB_USEDEP}] )
  69. vulkan? ( media-libs/vulkan-loader[${MULTILIB_USEDEP}] )"
  70. WINE_COMMON_DEPEND="
  71. ${WINE_DLOPEN_DEPEND}
  72. X? (
  73. x11-libs/libX11[${MULTILIB_USEDEP}]
  74. x11-libs/libXext[${MULTILIB_USEDEP}]
  75. )
  76. alsa? ( media-libs/alsa-lib[${MULTILIB_USEDEP}] )
  77. capi? ( net-libs/libcapi:=[${MULTILIB_USEDEP}] )
  78. gphoto2? ( media-libs/libgphoto2:=[${MULTILIB_USEDEP}] )
  79. gstreamer? (
  80. dev-libs/glib:2[${MULTILIB_USEDEP}]
  81. media-libs/gst-plugins-base:1.0[${MULTILIB_USEDEP}]
  82. media-libs/gstreamer:1.0[${MULTILIB_USEDEP}]
  83. )
  84. opencl? ( virtual/opencl[${MULTILIB_USEDEP}] )
  85. pcap? ( net-libs/libpcap[${MULTILIB_USEDEP}] )
  86. pulseaudio? ( media-libs/libpulse[${MULTILIB_USEDEP}] )
  87. scanner? ( media-gfx/sane-backends[${MULTILIB_USEDEP}] )
  88. smartcard? ( sys-apps/pcsc-lite[${MULTILIB_USEDEP}] )
  89. udev? ( virtual/libudev:=[${MULTILIB_USEDEP}] )
  90. unwind? (
  91. llvm-libunwind? ( sys-libs/llvm-libunwind[${MULTILIB_USEDEP}] )
  92. !llvm-libunwind? ( sys-libs/libunwind:=[${MULTILIB_USEDEP}] )
  93. )
  94. usb? ( dev-libs/libusb:1[${MULTILIB_USEDEP}] )
  95. wayland? ( dev-libs/wayland[${MULTILIB_USEDEP}] )"
  96. RDEPEND="
  97. ${WINE_COMMON_DEPEND}
  98. app-emulation/wine-desktop-common
  99. dos? (
  100. || (
  101. games-emulation/dosbox
  102. games-emulation/dosbox-staging
  103. )
  104. )
  105. gecko? (
  106. app-emulation/wine-gecko:${WINE_GECKO}[${MULTILIB_USEDEP}]
  107. wow64? ( app-emulation/wine-gecko[abi_x86_32] )
  108. )
  109. gstreamer? ( media-plugins/gst-plugins-meta:1.0[${MULTILIB_USEDEP}] )
  110. mono? ( app-emulation/wine-mono:${WINE_MONO} )
  111. perl? (
  112. dev-lang/perl
  113. dev-perl/XML-LibXML
  114. )
  115. samba? ( net-fs/samba[winbind] )
  116. selinux? ( sec-policy/selinux-wine )
  117. udisks? ( sys-fs/udisks:2 )"
  118. DEPEND="
  119. ${WINE_COMMON_DEPEND}
  120. sys-kernel/linux-headers
  121. X? ( x11-base/xorg-proto )
  122. wayland? ( dev-libs/wayland-protocols )"
  123. BDEPEND="
  124. || (
  125. sys-devel/binutils
  126. sys-devel/lld
  127. )
  128. dev-lang/perl
  129. sys-devel/bison
  130. sys-devel/flex
  131. virtual/pkgconfig
  132. mingw? ( !crossdev-mingw? (
  133. >=dev-util/mingw64-toolchain-10.0.0_p1-r2[${MULTILIB_USEDEP}]
  134. wow64? ( dev-util/mingw64-toolchain[abi_x86_32] )
  135. ) )
  136. nls? ( sys-devel/gettext )
  137. wayland? ( dev-util/wayland-scanner )"
  138. IDEPEND=">=app-eselect/eselect-wine-2"
  139. QA_CONFIG_IMPL_DECL_SKIP=(
  140. __clear_cache # unused on amd64+x86 (bug #900338)
  141. res_getservers # false positive
  142. )
  143. QA_TEXTRELS="usr/lib/*/wine/i386-unix/*.so" # uses -fno-PIC -Wl,-z,notext
  144. PATCHES=(
  145. "${FILESDIR}"/wine-vanilla-7.0-noexecstack.patch
  146. "${FILESDIR}"/wine-vanilla-7.20-unwind.patch
  147. "${FILESDIR}"/wine-vanilla-8.13-rpath.patch
  148. )
  149. pkg_pretend() {
  150. [[ ${MERGE_TYPE} == binary ]] && return
  151. if use crossdev-mingw && [[ ! -v MINGW_BYPASS ]]; then
  152. local mingw=-w64-mingw32
  153. for mingw in $(usev abi_x86_64 x86_64${mingw}) \
  154. $(use abi_x86_32 || use wow64 && echo i686${mingw}); do
  155. if ! type -P ${mingw}-gcc >/dev/null; then
  156. eerror "With USE=crossdev-mingw, you must prepare the MinGW toolchain"
  157. eerror "yourself by installing sys-devel/crossdev then running:"
  158. eerror
  159. eerror " crossdev --target ${mingw}"
  160. eerror
  161. eerror "For more information, please see: https://wiki.gentoo.org/wiki/Mingw"
  162. die "USE=crossdev-mingw is enabled, but ${mingw}-gcc was not found"
  163. fi
  164. done
  165. fi
  166. }
  167. src_prepare() {
  168. # sanity check, bumping these has a history of oversights
  169. local geckomono=$(sed -En '/^#define (GECKO|MONO)_VER/{s/[^0-9.]//gp}' \
  170. dlls/appwiz.cpl/addons.c || die)
  171. if [[ ${WINE_GECKO}$'\n'${WINE_MONO} != "${geckomono}" ]]; then
  172. local gmfatal=
  173. [[ ${PV} == *9999 ]] && gmfatal=nonfatal
  174. ${gmfatal} die -n "gecko/mono mismatch in ebuild, has: " ${geckomono} " (please file a bug)"
  175. fi
  176. default
  177. if tc-is-clang; then
  178. if use mingw; then
  179. # -mabi=ms was ignored by <clang:16 then turned error in :17
  180. # if used without --target *-windows, then gets used in install
  181. # phase despite USE=mingw, drop as a quick fix for now
  182. sed -i '/MSVCRTFLAGS=/s/-mabi=ms//' configure.ac || die
  183. else
  184. # fails in ./configure unless --enable-archs is passed, allow to
  185. # bypass with EXTRA_ECONF but is currently considered unsupported
  186. # (by Gentoo) as additional work is needed for (proper) support
  187. # note: also fails w/ :17, but unsure if safe to drop w/o mingw
  188. [[ ${EXTRA_ECONF} == *--enable-archs* ]] ||
  189. die "building ${PN} with clang is only supported with USE=mingw"
  190. fi
  191. fi
  192. # ensure .desktop calls this variant + slot
  193. sed -i "/^Exec=/s/wine /${P} /" loader/wine.desktop || die
  194. # datadir is not where wine-mono is installed, so prefixy alternate paths
  195. hprefixify -w /get_mono_path/ dlls/mscoree/metahost.c
  196. # always update for patches (including user's wrt #432348)
  197. eautoreconf
  198. tools/make_requests || die # perl
  199. }
  200. src_configure() {
  201. WINE_PREFIX=/usr/lib/${P}
  202. WINE_DATADIR=/usr/share/${P}
  203. local conf=(
  204. --prefix="${EPREFIX}"${WINE_PREFIX}
  205. --datadir="${EPREFIX}"${WINE_DATADIR}
  206. --includedir="${EPREFIX}"/usr/include/${P}
  207. --libdir="${EPREFIX}"${WINE_PREFIX}
  208. --mandir="${EPREFIX}"${WINE_DATADIR}/man
  209. $(usev wow64 --enable-archs=x86_64,i386)
  210. $(use_enable gecko mshtml)
  211. $(use_enable mono mscoree)
  212. --disable-tests
  213. $(use_with X x)
  214. $(use_with alsa)
  215. $(use_with capi)
  216. $(use_with cups)
  217. $(use_with fontconfig)
  218. $(use_with gphoto2 gphoto)
  219. $(use_with gstreamer)
  220. $(use_with kerberos gssapi)
  221. $(use_with kerberos krb5)
  222. $(use_with mingw)
  223. $(use_with netapi)
  224. $(use_with nls gettext)
  225. $(use_with opencl)
  226. $(use_with opengl)
  227. $(use_with osmesa)
  228. --without-oss # media-sound/oss is not packaged (OSSv4)
  229. $(use_with pcap)
  230. $(use_with pulseaudio pulse)
  231. $(use_with scanner sane)
  232. $(use_with sdl)
  233. $(use_with smartcard pcsclite)
  234. $(use_with ssl gnutls)
  235. $(use_with truetype freetype)
  236. $(use_with udev)
  237. $(use_with udisks dbus) # dbus is only used for udisks
  238. $(use_with unwind)
  239. $(use_with usb)
  240. $(use_with v4l v4l2)
  241. $(use_with vulkan)
  242. $(use_with wayland)
  243. $(use_with xcomposite)
  244. $(use_with xinerama)
  245. $(usev !odbc ac_cv_lib_soname_odbc=)
  246. )
  247. filter-lto # build failure
  248. use custom-cflags || strip-flags # can break in obscure ways at runtime
  249. # wine uses linker tricks unlikely to work with non-bfd/lld (bug #867097)
  250. # (do self test until https://github.com/gentoo/gentoo/pull/28355)
  251. if [[ $(LC_ALL=C $(tc-getCC) ${LDFLAGS} -Wl,--version 2>/dev/null) != @(LLD|GNU\ ld)* ]]
  252. then
  253. has_version -b sys-devel/binutils &&
  254. append-ldflags -fuse-ld=bfd ||
  255. append-ldflags -fuse-ld=lld
  256. strip-unsupported-flags
  257. fi
  258. if use mingw; then
  259. use crossdev-mingw || PATH=${BROOT}/usr/lib/mingw64-toolchain/bin:${PATH}
  260. filter-flags -fno-plt # build failure
  261. # CROSSCC was formerly recognized by wine, thus been using similar
  262. # variables (subject to change, esp. if ever make a mingw.eclass).
  263. local mingwcc_amd64=${CROSSCC:-${CROSSCC_amd64:-x86_64-w64-mingw32-gcc}}
  264. local mingwcc_x86=${CROSSCC:-${CROSSCC_x86:-i686-w64-mingw32-gcc}}
  265. local -n mingwcc=mingwcc_$(usex abi_x86_64 amd64 x86)
  266. conf+=(
  267. ac_cv_prog_x86_64_CC="${mingwcc_amd64}"
  268. ac_cv_prog_i386_CC="${mingwcc_x86}"
  269. CROSSCFLAGS="${CROSSCFLAGS:-$(
  270. filter-flags '-fstack-protector*' #870136
  271. filter-flags '-mfunction-return=thunk*' #878849
  272. # -mavx with mingw-gcc has a history of obscure issues and
  273. # disabling is seen as safer, e.g. `WINEARCH=win32 winecfg`
  274. # crashes with -march=skylake >=wine-8.10, similar issues with
  275. # znver4: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273
  276. append-cflags -mno-avx #912268
  277. CC=${mingwcc} test-flags-CC ${CFLAGS:--O2}
  278. )}"
  279. CROSSLDFLAGS="${CROSSLDFLAGS:-$(
  280. filter-flags '-fuse-ld=*'
  281. CC=${mingwcc} test-flags-CCLD ${LDFLAGS}
  282. )}"
  283. )
  284. fi
  285. # order matters with multilib: configure+compile 64->32, install 32->64
  286. local -i bits
  287. for bits in $(usev abi_x86_64 64) $(usev abi_x86_32 32); do
  288. (
  289. einfo "Configuring ${PN} for ${bits}bits in ${WORKDIR}/build${bits} ..."
  290. mkdir ../build${bits} || die
  291. cd ../build${bits} || die
  292. if (( bits == 64 )); then
  293. conf+=( --enable-win64 )
  294. elif use amd64; then
  295. conf+=(
  296. $(usev abi_x86_64 --with-wine64=../build64)
  297. TARGETFLAGS=-m32 # for widl
  298. )
  299. # _setup is optional, but use over Wine's auto-detect (+#472038)
  300. multilib_toolchain_setup x86
  301. fi
  302. ECONF_SOURCE=${S} econf "${conf[@]}"
  303. )
  304. done
  305. }
  306. src_compile() {
  307. use abi_x86_64 && emake -C ../build64 # do first
  308. use abi_x86_32 && emake -C ../build32
  309. }
  310. src_install() {
  311. use abi_x86_32 && emake DESTDIR="${D}" -C ../build32 install
  312. use abi_x86_64 && emake DESTDIR="${D}" -C ../build64 install # do last
  313. # Ensure both wine64 and wine are available if USE=abi_x86_64 (wow64,
  314. # -abi_x86_32, and/or EXTRA_ECONF could cause varying scenarios where
  315. # one or the other could be missing and that is unexpected for users
  316. # and some tools like winetricks)
  317. if use abi_x86_64; then
  318. if [[ -e ${ED}${WINE_PREFIX}/bin/wine64 && ! -e ${ED}${WINE_PREFIX}/bin/wine ]]; then
  319. dosym wine64 ${WINE_PREFIX}/bin/wine
  320. dosym wine64-preloader ${WINE_PREFIX}/bin/wine-preloader
  321. # also install wine(1) man pages (incl. translations)
  322. local man
  323. for man in ../build64/loader/wine.*man; do
  324. : "${man##*/wine}"
  325. : "${_%.*}"
  326. insinto ${WINE_DATADIR}/man/${_:+${_#.}/}man1
  327. newins ${man} wine.1
  328. done
  329. elif [[ ! -e ${ED}${WINE_PREFIX}/bin/wine64 && -e ${ED}${WINE_PREFIX}/bin/wine ]]; then
  330. dosym wine ${WINE_PREFIX}/bin/wine64
  331. dosym wine-preloader ${WINE_PREFIX}/bin/wine64-preloader
  332. fi
  333. fi
  334. use perl || rm "${ED}"${WINE_DATADIR}/man/man1/wine{dump,maker}.1 \
  335. "${ED}"${WINE_PREFIX}/bin/{function_grep.pl,wine{dump,maker}} || die
  336. # create variant wrappers for eselect-wine
  337. local bin
  338. for bin in "${ED}"${WINE_PREFIX}/bin/*; do
  339. make_wrapper "${bin##*/}-${P#wine-}" "${bin#"${ED}"}"
  340. done
  341. if use mingw; then
  342. # don't let portage try to strip PE files with the wrong
  343. # strip executable and instead handle it here (saves ~120MB)
  344. dostrip -x ${WINE_PREFIX}/wine/{i386,x86_64}-windows
  345. if use strip; then
  346. ebegin "Stripping Windows (PE) binaries"
  347. find "${ED}"${WINE_PREFIX}/wine/*-windows -regex '.*\.\(a\|dll\|exe\)' \
  348. -exec $(usex abi_x86_64 x86_64 i686)-w64-mingw32-strip --strip-unneeded {} +
  349. eend ${?} || die
  350. fi
  351. fi
  352. dodoc ANNOUNCE AUTHORS README* documentation/README*
  353. }
  354. pkg_postinst() {
  355. if use !abi_x86_32 && use !wow64; then
  356. ewarn "32bit support is disabled. While 64bit applications themselves will"
  357. ewarn "work, be warned that it is not unusual that installers or other helpers"
  358. ewarn "will attempt to use 32bit and fail. If do not want full USE=abi_x86_32,"
  359. ewarn "note the experimental/WIP USE=wow64 can allow 32bit without multilib."
  360. fi
  361. eselect wine update --if-unset || die
  362. }
  363. pkg_postrm() {
  364. eselect wine update --if-unset || die
  365. }