# Template file for 'motif'
pkgname=motif
version=2.3.8
revision=1
build_style=gnu-configure
build_helper=qemu
configure_args="--disable-jpeg --disable-png --enable-xft --disable-demos"
hostmakedepends="pkg-config automake libtool flex"
makedepends="libX11-devel libXft-devel libXt-devel libXpm-devel libXext-devel xbitmaps"
short_desc="User interface component toolkit"
maintainer="Andrew Benson <abenson+void@gmail.com>"
license="LGPL-2.1-only"
homepage="https://sourceforge.net/projects/motif/"
distfiles="${SOURCEFORGE_SITE}/motif/Motif%20${version}%20Source%20Code/motif-${version}.tar.gz"
checksum=859b723666eeac7df018209d66045c9853b50b4218cecadb794e2359619ebce7
replaces="lesstif>=0"

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" $makedepends"
fi

post_patch() {
	if [ "$CROSS_BUILD" ]; then
		vsed -i lib/Xm/Makefile.am -e 's|$(top_builddir)/config/util/makestr|/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static &|'
		vsed -i tools/wml/Makefile.am -e 's|\./wmluiltok|/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static &|'
		vsed -i tools/wml/Makefile.am -e 's|\./wml |/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static &|'
		vsed -i tools/wml/Makefile.am -e '/motif.wmd:/a	\\tsed -i "s|      exec|& /usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static |" wmldbcreate'
	fi
	touch NEWS AUTHORS
	autoreconf -fi
	vsed -i tools/wml/wmluiltok.l -e '1i %option main'
}

motif-devel_package() {
	short_desc+=" - development files"
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	replaces="lesstif-devel>=0"
	pkg_install() {
		vmove usr/bin/uil
		vmove usr/share/man/man3
		vmove usr/share/man/man1/uil.1
		vmove usr/share/man/man5
		vmove usr/include
		vmove "usr/lib/*.so"
	}
}

motif-mwm_package() {
	short_desce="Motif window manager"
	depends="${sourcepkg}>=${version}_${revision}"
	replaces="lesstif-mwm>=0"
	pkg_install() {
		vmove usr/bin/mwm
		vmove usr/share/man/man1/mwm.1
		vmove usr/share/man/man4/mwmrc.4
		vmove usr/lib/X11/system.mwmrc
	}
}

motif-xmbind_package() {
	short_desc="Configures the virtual key bindings of Motif applications"
	replaces="lesstif-xmbind>=0"
	pkg_install() {
		vmove usr/bin/xmbind
		vmove usr/share/man/man1/xmbind.1
	}
}
