#
# (C) Michael 'Mickey' Lauer <mickey@Vanille.de>
#

DEPENDS += "virtual/libsdl libsdl-mixer libsdl-image"

APPDESKTOP ?= "${WORKDIR}/${PN}.desktop"
APPNAME ?= "${PN}"
APPIMAGE ?= "${WORKDIR}/${PN}.png"

export SDL_CONFIG = "${STAGING_BINDIR_CROSS}/sdl-config"

sdl_do_sdl_install() {
	install -d ${D}${datadir}/applications
	install -d ${D}${datadir}/pixmaps

	install -m 0644 ${APPIMAGE} ${D}${datadir}/pixmaps/${PN}.png

	if [ -e "${APPDESKTOP}" ]
	then
		echo ${APPDESKTOP} present, using it...
		install -m 0644 ${APPDESKTOP} ${D}${datadir}/applications/
	else
		echo ${APPDESKTOP} not present, creating one on-the-fly...
		cat >${D}${datadir}/applications/${PN}.desktop <<EOF
[Desktop Entry]
Name=${PN}
Comment=${DESCRIPTION}
Note=Auto Generated by OE SDL bbclass
Exec=${APPNAME}
Icon=${PN}.png
Type=Application
Categories=Games
EOF
	fi
}

EXPORT_FUNCTIONS do_sdl_install
addtask sdl_install after do_install before do_package

#SECTION = "x11/games"
#SECTION_${PN}-opie = "opie/games"

#PACKAGES += "${PN}-opie"
#RDEPENDS_${PN}-opie += "${PN}"
#FILES_${PN}-opie = "${palmtopdir}"