description="The Xorg Server is the core of the X Window system."
url="http://xorg.freedesktop.org"

packager="Tnut <tnut@nutyx.org>"
contributors="Pierre,Greg,Tnut,Spiky"

makedepends=(nettle xorgproto xorg-xkbcomp xorg-font-util xcb-util-keysyms libxcvt \
libepoxy xcb-util-image xcb-util-renderutil xcb-util-wm mesa xorg-glu \
xorg-pixman xorg-libdmx xorg-libxres xorg-libxfont2 xorg-xkeyboard-config wayland)

name=xorg-server
version=21.1.7

source=(consolidate.patch
	https://ftp.x.org/pub/individual/xserver/$name-$version.tar.xz)

prepare() {
  cd $name-$version
  patch -Np1 -i ../consolidate.patch
}
build() {

cd $name-$version

sed -i 's/malloc(pScreen/calloc(1, pScreen/' dix/pixmap.c

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
--with-xkb-output=/var/lib/xkb \
--enable-glamor \
--with-fontrootdir=/usr/share/fonts \
--enable-install-setuid \
--disable-systemd-logind \
--enable-suid-wrapper
make
make DESTDIR=$PKG install

install -m755 $PKG/usr/bin/Xvfb $PKG/usr/bin/xvfb-run

rm -rf $PKG/var
rm $PKG/usr/lib/xorg/modules/{libexa,libfbdevhw,libglamoregl,\
libint10,libshadow,libshadowfb,libvgahw,libwfb}.la
rm $PKG/usr/lib/xorg/modules/drivers/modesetting_drv.la
rm $PKG/usr/lib/xorg/modules/extensions/libglx.la
}
