TERMUX_PKG_HOMEPAGE=https://xorg.freedesktop.org/wiki/
TERMUX_PKG_DESCRIPTION="Wayland X11 server"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=22.1.0
TERMUX_PKG_REVISION=14
TERMUX_PKG_SRCURL=https://gitlab.freedesktop.org/xorg/xserver/-/archive/xwayland-${TERMUX_PKG_VERSION}/xserver-xwayland-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=972d5456445049855a669c1418f20ecbc290c85b1b59602a01c6afa199203389
TERMUX_PKG_DEPENDS="libandroid-shmem, libdrm, libpciaccess, libpixman, libx11, libxau, libxfont2, libxinerama, libxkbfile, libxshmfence, mesa, openssl, xkeyboard-config, xorg-xkbcomp, libwayland, libwayland-protocols, libepoxy, libxcvt, libtirpc"

TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dmitshm=true
-Dxres=true
-Dxv=true
-Dscreensaver=true
-Dxdmcp=true
-Dglx=false
-Ddri3=false
-Dxinerama=true
-Dxace=true
-Dxcsecurity=true
-Dxf86bigfont=true
-Dsecure-rpc=false
-Dinput_thread=false
-Ddrm=true
-Dglamor=false
-Dxvfb=false
-Dsha1=libcrypto
-Ddefault_font_path=${TERMUX_PREFIX}/share/fonts
-Dxkb_dir=${TERMUX_PREFIX}/share/X11/xkb
"

# Remove files conflicting with xorg-server:
TERMUX_PKG_RM_AFTER_INSTALL="
share/X11/xkb/compiled
share/man/man1/Xserver.1
"

termux_step_pre_configure() {
	CFLAGS+=" -fcommon -fPIC -DFNDELAY=O_NDELAY -Wno-int-to-pointer-cast"
	CPPFLAGS+=" -fcommon -fPIC -I${TERMUX_PREFIX}/include/libdrm"

	if [ "${TERMUX_DEBUG_BUILD}" = "true" ]; then
		TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --enable-debug"
	fi
}
