APP = gpxview
MAEMO_VERSION_MAJOR = 4
prefix = /usr
datarootdir = ${prefix}/share
datadir = ${prefix}/share

LANGS = en_GB de_DE fi_FI
LANGS_HELP = en_GB de_DE fi_FI

ICON_SIZES = 12x12 16x16 32x32 48x48 64x64 45x12 90x24

all:

clean:

install-debian:
#	install -m 644 help/gpxview.html $(DESTDIR)$(prefix)/share/$(APP)

install-maemo:
	# the path to /share is hardcoded since datapath points to /opt on fremantle
	install -d $(DESTDIR)$(prefix)/share/applications/hildon
	install $(APP).desktop $(DESTDIR)$(prefix)/share/applications/hildon
	for s in 40 26; do \
	  install -d $(DESTDIR)$(prefix)/share/icons/hicolor/$${s}x$${s}/hildon ;\
	  install -m 644 icons/$${s}x$${s}/$(APP).png $(DESTDIR)$(prefix)/share/icons/hicolor/$${s}x$${s}/hildon/$(APP).png ;\
	done
	install -d $(DESTDIR)$(prefix)/share/icons/hicolor/scalable/hildon
	install -m 644 icons/64x64/$(APP).png $(DESTDIR)$(prefix)/share/icons/hicolor/scalable/hildon/$(APP).png
	if [ $(MAEMO_VERSION_MAJOR) -lt 5 ]; then \
		echo "Installing hildon help files for maemo <= 4"; \
		for LANG in $(LANGS_HELP); do \
			install -d $(DESTDIR)$(prefix)/share/osso-help/$${LANG} ;\
			install -m 644 ../help/$${LANG}/*.xml $(DESTDIR)$(prefix)/share/osso-help/$${LANG} ;\
		done;\
	else \
	  echo "Installing backup configuration for maemo >= 5"; \
	  install -d $(DESTDIR)/etc/osso-backup/applications ;\
	  install $(APP).conf $(DESTDIR)/etc/osso-backup/applications ;\
	fi

install: install-maemo
	install -d $(DESTDIR)$(datadir)/$(APP)
	install -m 644 COPYING welcome.gpx icons/*.png $(DESTDIR)$(datadir)/$(APP);
	for SIZE in $(ICON_SIZES); do \
		install -d $(DESTDIR)$(datadir)/$(APP)/$${SIZE} ;\
		install -m 644 icons/$${SIZE}/*.png $(DESTDIR)$(datadir)/$(APP)/$${SIZE};\
	done
	for LANG in $(LANGS); do \
		install -d $(DESTDIR)$(prefix)/share/locale/$${LANG}/LC_MESSAGES ;\
		msgfmt ../po/$${LANG}.po -o $(DESTDIR)$(prefix)/share/locale/$${LANG}/LC_MESSAGES/$(APP).mo ;\
	done

