DESCRIPTION = "A flightcomputer application using Qt4 under X11"
SECTION = "x11/applications"
PRIORITY = "optional"
LICENSE = "GPL"
APPTYPE = "binary"
APPNAME = "cumulus"
APPDESKTOP = "${S}"
PR = "r1"

SRC_URI = "http://www.kflog.org/fileadmin/user_upload/cumulus_snapshots/CumulusQt4-snapshot.tbz"
#SRC_URI = "svn://svn.kflog.org/svn/repos/cumulus/qt4/trunk;module=cumulus;proto=https"
S = "${WORKDIR}/CumulusQt4"

# Todo:
#   use Makefile's install
#   Use a script for bindir/cumulus that can chdir to /opt/cumulus so it loads everything properly.
#   include a cumulus-qt4.desktop in /usr/share/applications

inherit qt4x11

#Overrride do_configure from qt4x11 class.
# According to how qt4x11 class is written, we should be able to just define the following here:
#    QMAKE_PROFILES = "cumulus/cumulusX11.pro gpsClient/gpsClientX11.pro nmeaSimulator/simuX11.pro"
# but that doesnt work because the qmake command it builds doesnt accept multiple .pro files.
do_configure() {
	${OE_QMAKE_QMAKE} -makefile -spec ${QMAKESPEC} -o cumulus/Makefile cumulus/cumulusX11.pro
	${OE_QMAKE_QMAKE} -makefile -spec ${QMAKESPEC} -o gpsClient/Makefile gpsClient/gpsClientX11.pro
	${OE_QMAKE_QMAKE} -makefile -spec ${QMAKESPEC} -o nmeaSimulator/Makefile nmeaSimulator/simuX11.pro
}

#now building the supplied Makefile will call the 3 Makesfiles built by qmake
do_compile() {
	make -f Makefile.X11
}


INSTALL_ROOT = "${D}/opt/cumulus"
BUILD_ROOT = "${S}"

PACKAGES = "${PN}"

# Hurl everything into /opt/cumulus, but not the .debug that gets put in /opt/cumulus/bin/
FILES_${PN} = "\
      ${bindir}/cumulus \
      ${bindir}/gpsClient \
      ${bindir}/nmeaSimu \
      opt/cumulus/bin/cumulus \
      opt/cumulus/bin/gpsClient \
      opt/cumulus/bin/nmeaSimu \
      opt/cumulus/etc \
      opt/cumulus/help \
      opt/cumulus/icons \
      opt/cumulus/locale \
      opt/cumulus/maps \
      opt/cumulus/sounds \
      "

# Copy files individually for now (we should be able to use the makefile's install here)
do_install() {
	install -d ${D}/opt
	install -d ${D}/opt/cumulus
        install -d ${INSTALL_ROOT}/bin
        install -d ${INSTALL_ROOT}/etc
        install -d ${INSTALL_ROOT}/help/de
        install -d ${INSTALL_ROOT}/help/en
        install -d ${INSTALL_ROOT}/icons
        install -d ${INSTALL_ROOT}/icons/small
        install -d ${INSTALL_ROOT}/icons/windarrows
        install -d ${INSTALL_ROOT}/locale
        install -d ${INSTALL_ROOT}/sounds
        install -d ${INSTALL_ROOT}/maps/airfields
        install -d ${INSTALL_ROOT}/maps/airspaces
        install -d ${INSTALL_ROOT}/maps/landscape
        install --mode=755 ${BUILD_ROOT}/cumulus/cumulus ${INSTALL_ROOT}/bin
	install --mode=755 ${BUILD_ROOT}/gpsClient/gpsClient ${INSTALL_ROOT}/bin
	install --mode=755 ${BUILD_ROOT}/nmeaSimulator/nmeaSimu ${INSTALL_ROOT}/bin
        install --mode=644 ${BUILD_ROOT}/etc/glider.pol ${INSTALL_ROOT}/etc
        install --mode=644 ${BUILD_ROOT}/icons/*.xpm ${INSTALL_ROOT}/icons
        install --mode=644 ${BUILD_ROOT}/icons/*.png ${INSTALL_ROOT}/icons
        install --mode=644 ${BUILD_ROOT}/icons/small/* ${INSTALL_ROOT}/icons/small
        install --mode=644 ${BUILD_ROOT}/icons/windarrows/* ${INSTALL_ROOT}/icons/windarrows
        install --mode=644 ${BUILD_ROOT}/help/de/* ${BUILD_ROOT}/icons/cumulus.png ${INSTALL_ROOT}/help/de
        install --mode=644 ${BUILD_ROOT}/help/en/* ${BUILD_ROOT}/icons/cumulus.png ${INSTALL_ROOT}/help/en
        install --mode=644 ${BUILD_ROOT}/sounds/*.wav ${INSTALL_ROOT}/sounds

	#link the bin files to the target bin dir.
        install -d ${D}${bindir}
	ln -s /opt/cumulus/bin/cumulus ${D}${bindir}/cumulus
	ln -s /opt/cumulus/bin/gpsClient ${D}${bindir}/gpsClient
	ln -s /opt/cumulus/bin/nmeaSimu ${D}${bindir}/nmeaSimu
}

