# Contributor: Johannes Matheis <jomat+alpinebuild@jmt.gr>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=xdm
pkgver=1.1.16
pkgrel=1
pkgdesc="X Display Manager"
options="!check" # No testsuite
url="https://xorg.freedesktop.org/wiki/"
arch="all"
license="MIT"
depends="sessreg"
makedepends="linux-pam-dev libxmu-dev libxaw-dev libxft-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="
	https://xorg.freedesktop.org/releases/individual/app/xdm-$pkgver.tar.xz
	Xsession-loginshell.patch

	$pkgname.initd
	$pkgname.confd
	Xresources.alpinelinux
	Xresources.alpinelinux_old
	alpinelinux_old_blue_black.xpm
	alpinelinux_white_blue.xpm
"

build() {
	# Use more sensible system/user path values.
	# The default includes /usr/ucb, which Alpine doesn't use.
	export DEF_SYSTEM_PATH=/usr/local/bin:/usr/bin:/bin
	export DEF_USER_PATH=/usr/local/bin:/usr/bin:/bin

	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-ipv6 \
		--with-xdmconfigdir=/etc/X11/$pkgname \
		--with-xft \
		--with-pam
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname

	install -D -m644 "$srcdir"/Xresources.alpinelinux \
		"$pkgdir"/etc/X11/$pkgname/Xresources.alpinelinux
	install -D -m644 "$srcdir"/Xresources.alpinelinux_old \
		"$pkgdir"/etc/X11/$pkgname/Xresources.alpinelinux_old
	install -D -m644 "$srcdir"/alpinelinux_old_blue_black.xpm \
		"$pkgdir"/etc/X11/$pkgname/pixmaps/alpinelinux_old_blue_black.xpm
	install -D -m644 "$srcdir"/alpinelinux_white_blue.xpm \
		"$pkgdir"/etc/X11/$pkgname/pixmaps/alpinelinux_white_blue.xpm
}

sha512sums="
a7e0aca67b770b3939aee2c12feac3c0f5efa531ec4a6045ab8b53d9c35b701ab5533447feb39b7cbe0df74ff8483ee1637314b847b37a6c3f7e9c8fdf5e172d  xdm-1.1.16.tar.xz
c9f5c20c298de4bb412c7df94adaf601e7d88fc9bd889540c32e9948be3aacc19074aae201ad4f1695f97483d4564b04c0720eacdb61cf9b97bc3394b781054e  Xsession-loginshell.patch
58097e6df43f8942eaa99961ba1692bf4b9c5b8209eeed2735088f3c3ccada3528bca0e931ae32feb25fab6f933f2c0ce4c1c186ad423a411e493f60c47f2111  xdm.initd
9d08ee82afeb85e7d9e0a1013226a44bdbef8d6da227f5fef7734524861c41f0cdc9ba4616b2faaf3a8d4b16134115ed004bf0a5fcf71be7c6e13506fbcda95b  xdm.confd
2a9db579323d680b6b3d7a0377ea1140c8570870c4f06f2ecc5e0ec73233b3621e46823ff3f694d8fa296a4de83b4fd62c2635c3c6b413b613ebe83cba4cf033  Xresources.alpinelinux
5d667541fdb39bdbd637da45e05a243736af32b7aa75ce27f2bbf097bce2fad87932619b372ab03add29b0bef7dd8816eb89875fbf2426eba83978d720687d90  Xresources.alpinelinux_old
b55424fd9ea0970fdbecd11c1abecf41cad1a7ede03f38011f666ae4eed2a88def5ac364bdf4ebcac09fa66963ed534e85faff74fcd01e9f040229d999382472  alpinelinux_old_blue_black.xpm
3872c54ad6fd6aa6c893f5f950801ae079bb7b6d375a05ef2262eb244a96ea3e949ab3cd962e005acf957c9ad4d30caee4c3935d7864a196625e8bfed9bc5adf  alpinelinux_white_blue.xpm
"
