#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
#

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/meta-subst.mk

# work around #262408
DEB_DH_INSTALL_SOURCEDIR := $(DEB_DESTDIR)

BINDIR = $(DEB_DESTDIR)/usr/bin
LIBDIR = $(DEB_DESTDIR)/lib
DATADIR = $(DEB_DESTDIR)/usr/share
SYSCONFDIR = $(DEB_DESTDIR)/etc
DESKTOPDIR = $(DATADIR)/applications
SOUNDDIR = $(DATADIR)/sounds

PKGDATADIR = $(DATADIR)/elho
PKGLIBDIR = $(LIBDIR)/elho
PKGSOUNDDIR = $(SOUNDDIR)/elho
PKAUTHORITYDIR=$(SYSCONFDIR)/polkit-1/localauthority/20-org.d
XSESSIONDIR = $(SYSCONFDIR)/X11/Xsession.d

common-install-indep::
	mkdir -p $(DEB_DESTDIR)

	install --directory $(BINDIR)
	install --mode=755 elho-gnome-config $(BINDIR)

	install --directory $(PKGLIBDIR)
	install --mode=755 add-gnome-keyboard-shortcut $(PKGLIBDIR)

	install --directory $(SYSCONFDIR)/default
	install --mode=644 etc/default/cpufrequtils $(SYSCONFDIR)/default

	install --directory $(SYSCONFDIR)/sysctl.d
	for f in kernelpanic ; \
	do \
		install --mode=644 --no-target-directory "etc/sysctl.d/$$f" \
			"$(SYSCONFDIR)/sysctl.d/$${f}.conf" ; \
	done

	install --directory $(PKAUTHORITYDIR)
	install --mode=644 polkit/net.elho.cpufreqselector.pkla \
		$(PKAUTHORITYDIR)

	install --directory $(XSESSIONDIR)
	install --mode=644 --no-target-directory \
		etc/X11/Xsession.d/source-profile \
		$(XSESSIONDIR)/80elho-desktop_source-profile

	install --directory $(DESKTOPDIR)
	install --directory $(DESKTOPDIR)/screensavers
	install --mode=644 mate-screensaver/phosphor-small.desktop \
		$(DESKTOPDIR)/screensavers
	install --mode=644 mate-screensaver/phosphor-tiny.desktop \
		$(DESKTOPDIR)/screensavers

	install --directory $(PKGSOUNDDIR)
	for f in silence.wav phone.wav receive.wav send.wav ; \
	do \
		install --mode=644 "sounds/$$f" $(PKGSOUNDDIR) ; \
	done

	install --directory $(DATADIR)/gajim/data/iconsets/gossip
	for d in gossip/{16x16,32x32,48x48} ; \
	do \
		install --directory "$(DATADIR)/gajim/data/iconsets/$${d}" ; \
		for f in "gajim/iconsets/$${d}"/* ; \
		do \
			install --mode=644 "$${f}" \
				"$(DATADIR)/gajim/data/iconsets/$${d}" ; \
		done \
	done

	install --directory $(DATADIR)/geeqie/applications
	install --mode=644 geeqie/applications/exiv2-bottom-right.desktop \
		$(DATADIR)/geeqie/applications
	install --mode=644 geeqie/applications/exiv2-left-bottom.desktop \
		$(DATADIR)/geeqie/applications
	install --mode=644 geeqie/applications/exiv2-right-top.desktop \
		$(DATADIR)/geeqie/applications
	install --mode=644 geeqie/applications/exiv2-top-left.desktop \
		$(DATADIR)/geeqie/applications

	install --directory $(PKGDATADIR)/customize
	install --directory $(PKGDATADIR)/customize/etc/lightdm
	install --mode=644 etc/lightdm/lightdm.conf.sed \
		$(PKGDATADIR)/customize/etc/lightdm
	install --directory $(PKGDATADIR)/customize/usr/share/applications
	install --mode=644 chromium/chromium.desktop.sed \
		$(PKGDATADIR)/customize/usr/share/applications

	install --directory $(PKGDATADIR)/preseed
	for f in elho-desktop.cfg exim4-dns.cfg ; \
	do \
		install --mode=644 "preseed/$$f" $(PKGDATADIR)/preseed ; \
	done
