GUI_CONLER = conler-gui
CLI_CONLER = conler-cli

build:
	@cd src; make all

INSTALL=/usr/bin/install
DST=$(PREFIX)/$(DESTDIR)
DST_BIN=$(DST)/usr/bin
DST_ICONS_26=$(DST)/usr/share/icons/hicolor/26x26/hildon
DST_ICONS_40=$(DST)/usr/share/icons/hicolor/40x40/hildon
DST_ICONS_S=$(DST)/usr/share/icons/hicolor/scalable/hildon
DST_PIXMAP_DIR=$(DST)/usr/share/pixmaps/conler
install: build
	$(INSTALL) -g root -o root src/$(CLI_CONLER) $(DST)/usr/bin
	$(INSTALL) -g root -o root src/$(GUI_CONLER) $(DST)/usr/bin
	$(INSTALL) -g root -o root -m 744 data/run-wrapper.sh $(DST)/usr/bin/conler-run-wrapper.sh
	$(INSTALL) -g root -o root -m 644 data/icons/26x26/conler.png $(DST_ICONS_26)
	$(INSTALL) -g root -o root -m 644 data/icons/40x40/conler.png $(DST_ICONS_40)
	$(INSTALL) -g root -o root -m 644 data/icons/scalable/conler.png $(DST_ICONS_S)
	$(INSTALL) -g root -o root -m 644 data/pixmaps/*.png $(DST_PIXMAP_DIR)
	$(INSTALL) -g root -o root -m 644 data/conler-help.xml $(DST)/usr/share/osso-help/en_GB/conler.xml
	$(INSTALL) -g root -o root -m 644 data/conler.desktop $(DST)/usr/share/applications/hildon
	$(INSTALL) -g root -o root -m 644 data/com.thekondor.conler.service $(DST)/usr/share/dbus-1/services

deb: BUILD_DIR=/tmp/conler-$(shell /bin/date +%s)
deb: DEB_CONTROL=$(strip $(BUILD_DIR))/debian/control
deb:
	@/bin/cp -r $(shell /bin/pwd) $(BUILD_DIR)
	@/bin/find $(BUILD_DIR) -type d | /bin/grep '.svn$$' | /bin/xargs rm -rdf
	@/bin/echo "XB-Maemo-Icon-26:" >> $(DEB_CONTROL)
	@/usr/bin/openssl base64 < data/icons/26x26/conler.png | /usr/bin/sed -e 's/^/ /' >> $(DEB_CONTROL)
	@cd $(BUILD_DIR); dpkg-buildpackage -rfakeroot -uc -us -sa -D
	@echo
	@echo "*** INFO: Check /tmp out for the build .deb package"
	@/bin/rm -rdf $(BUILD_DIR)


.PHONY: clean
clean:
	@cd src; make clean

