# Template file for 'cegui07'
pkgname=cegui07
version=0.7.9
revision=8
wrksrc="CEGUI-${version}"
build_style=gnu-configure
configure_args="--disable-samples"
make_build_args="all html"
hostmakedepends="automake dejavu-fonts-ttf doxygen glm graphviz libtool
 pkg-config python"
makedepends="boost-devel devil-devel freeimage-devel freetype-devel
 fribidi-devel glfw-devel libxml2-devel lua51-devel minizip-devel ois-devel
 pcre-devel silly-devel tinyxml-devel toluapp-devel
 $(vopt_if irrlicht 'irrlicht-devel')
 $(vopt_if python 'python-devel')"
depends="cegui07-data"
short_desc="Crazy Eddie's Graphical User Interface (0.7.x)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="http://cegui.org.uk/"
distfiles="${SOURCEFORGE_SITE}/crayzedsgui/CEGUI%20Mk-2/${version}/CEGUI-${version}.tar.gz"
checksum=7c3b264def08b46de749c2acaba363e907479d924612436f3bd09da2e474bb8c

build_options="irrlicht python"
desc_option_irrlicht="Enable support for Irrlicht"
build_options_default="irrlicht"

if [ -z "$CROSS_BUILD" ]; then
	# XXX: boost-python is not available when cross building
	build_options_default+=" python"
fi

# Make configure find python and freetype2
CFLAGS="-I${XBPS_CROSS_BASE}/usr/include/python2.7"

pre_configure() {
	# Silence doxygen
	sed -i doc/doxygen/Makefile.am \
		-e 's;$(DOXYGEN) doxyfile;& >/dev/null 2>&1;'

	# Modernize Makefile.am files
	find . -name Makefile.am -exec sed -i "{}" \
		-e "1i ACLOCAL_AMFLAGS = -I m4" \
		-e "s;INCLUDES;AM_CXXFLAGS;g" \;

	# Set AM_CPPFLAGS for the C source in tolua++
	sed -i cegui/src/ScriptingModules/LuaScriptModule/support/tolua++/Makefile.am \
		-e "s;AM_CXXFLAGS;AM_CFLAGS;"

	# Modernize configure.ac (enable subdir-objects)
	sed -i configure.ac \
		-e "s;dist-zip tar-ustar;& subdir-objects;" \
		-e "/^AM_INIT_AUTOMAKE.*/a AC_CONFIG_MACRO_DIRS([m4])"

	mkdir -p m4
	cp doc/COPYING doc/README .
	touch NEWS AUTHORS ChangeLog
	autoreconf -if
}
post_install() {
	vlicense COPYING
	vdoc doc/README
	vdoc doc/GLEW-LICENSE
	vdoc doc/PCRE-LICENSE
	vdoc doc/TinyXML-License
	vdoc doc/stringencoders-license
}

cegui07-data_package() {
	short_desc+=" - data files"
	pkg_install() {
		vmove usr/share/CEGUI
	}
}
cegui07-doc_package() {
	short_desc+=" - documentation"
	pkg_install() {
		vmkdir usr/share/doc/${sourcepkg}
		vcopy ${wrksrc}/doc/doxygen/html usr/share/doc/${sourcepkg}
	}
}
cegui07-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		# Move only the symlink *.so files
		find ${DESTDIR}/usr/lib/ -type l -exec mv "{}" ${PKGDESTDIR}/usr/lib \;
	}
}
