PKGNAME=wine
PKGSEC=utils
PKGDEP="desktop-file-utils fontconfig freetype gettext glu x11-lib libpcap \
        alsa-lib alsa-plugins gnutls giflib cups lcms2 pulseaudio openldap \
        libjpeg-turbo libxml2 libxslt mpg123 ncurses openal-soft v4l-utils \
        samba libcl gtk-3 libgphoto2 sane-backends vulkan vkd3d ffmpeg \
        llvm-runtime"
PKGDEP__RETRO=" \
        desktop-file-utils fontconfig freetype gettext glu x11-lib libpcap \
        alsa-lib gnutls giflib cups lcms2 openldap libjpeg-turbo libxml2 \
        libxslt mpg123 ncurses openal-soft v4l-utils samba libgphoto2 \
        sane-backends"
PKGDEP__I486="${PKGDEP__RETRO}"
PKGRECOM="ntsync-enablement"
PKGSUG="noto-fonts noto-cjk-fonts"
PKGSUG__RETRO=""
PKGSUG__I486="${PKGSUG__RETRO}"
BUILDDEP="chrpath dos2unix llvm opencl-registry-api wayland-protocols"

# Note: AMD64 build requires MingW-w64.
#
# See https://bugs.winehq.org/show_bug.cgi?id=49436#c27.
BUILDDEP__AMD64="${BUILDDEP} gcc+w64 binutils+w64 mingw+w64"

BUILDDEP__RETRO="chrpath dos2unix"
BUILDDEP__I486="${BUILDDEP__RETRO}"
PKGDES="Runtime/Compatibility Layer for running programs designed for Microsoft Windows"

# Note: Wine seems to prefer Clang.
USECLANG=1

# FIXME: /usr/bin/ld: /tmp/cc2aPEVj.ltrans0.ltrans.o: in function `_start':
# <artificial>:(.text+0x12): undefined reference to `thread_data'
# /usr/bin/ld: <artificial>:(.text+0x2a): undefined reference to `wld_start'
# collect2: error: ld returned 1 exit status
NOLTO=1

# Note: --disable-win16, only enable this for 32-bit x86 builds.
# Note: --without-capi, what is the point of using CAPI (ISDN) with Wine?
AUTOTOOLS_AFTER=(
    '--disable-win16'
    '--disable-win64'
    '--enable-largefile'
    '--enable-year2038'
    '--with-alsa'
    '--without-capi'
    '--without-coreaudio'
    '--with-cups'
    '--with-dbus'
    '--with-ffmpeg'
    '--with-fontconfig'
    '--with-freetype'
    '--with-gettext'
    '--without-gettextpo'
    '--with-gphoto'
    '--with-gnutls'
    '--with-gssapi'
    '--without-gstreamer'
    '--with-inotify'
    '--with-krb5'
    '--with-netapi'
    '--with-opencl'
    '--with-opengl'
    '--without-oss'
    '--with-pcap'
    '--with-pcsclite'
    '--with-pthread'
    '--with-pulse'
    '--with-sane'
    '--with-sdl'
    '--with-udev'
    '--with-unwind'
    '--with-usb'
    '--with-v4l2'
    '--with-vulkan'
    '--with-wayland'
    '--with-xcomposite'
    '--with-xcursor'
    '--with-xfixes'
    '--with-xinerama'
    '--with-xinput'
    '--with-xinput2'
    '--with-xrandr'
    '--with-xrender'
    '--with-xshape'
    '--with-xshm'
    '--with-xxf86vm'
    '--with-x'
    '--with-dbus'
    '--with-pulse'
    '--with-vulkan'
    '--with-mingw'
)
AUTOTOOLS_AFTER__AMD64=(
    "${AUTOTOOLS_AFTER[@]}"
    '--enable-archs=x86_64,i386'
)
AUTOTOOLS_AFTER__ARM64=(
    "${AUTOTOOLS_AFTER[@]}"
    '--enable-archs=arm64ec,aarch64,x86_64,i386'
)
AUTOTOOLS_AFTER__I486=(
    "${AUTOTOOLS_AFTER[@]}"
    '--without-gtk3'
    '--without-pulse'
    '--without-vulkan'
    '--without-mingw'
)

# Wine is currently not available for Loongson and POWER.
FAIL_ARCH="!(amd64|arm64|i486)"

PKGEPOCH=3
