SUBDIRS=src
BUILDDIR=build
DATA_FILE=ledpulse-home-plugin.desktop
LIB=ledpulse-home-plugin.so
HILDON_WIDGET_LIB_DIR=/usr/lib/hildon-desktop
HILDON_WIDGET_DATA_DIR=/usr/share/applications/hildon-home
SUDOERS_PATH=/etc/sudoers.d
CHMOD_BIN=ledpulse-chmod
UTIL_PATH=/usr/bin/

all:    create_builddir subdirs
MAKE_BUILD_DIR:
	mkdir -p $(BUILDDIR)

install: all
	install -d $(DESTDIR)/$(HILDON_WIDGET_LIB_DIR)
	install $(BUILDDIR)/$(LIB) $(DESTDIR)/$(HILDON_WIDGET_LIB_DIR)
	install -d $(DESTDIR)/$(HILDON_WIDGET_DATA_DIR)
	install data/$(DATA_FILE) $(DESTDIR)/$(HILDON_WIDGET_DATA_DIR)
	install -d $(DESTDIR)/$(SUDOERS_PATH)
	install -m 644 data/ledpulse.sudoers $(DESTDIR)/$(SUDOERS_PATH)
	install -d $(DESTDIR)/$(UTIL_PATH)
	install -m 755 data/$(CHMOD_BIN) $(DESTDIR)/$(UTIL_PATH)
	install -d $(DESTDIR)/usr/share/gconf/schemas
	install -m 0644 ledpulse-home-plugin.schemas $(DESTDIR)/usr/share/gconf/schemas/
	gconftool-2 --makefile-install-rule $(DESTDIR)/usr/share/gconf/schemas/ledpulse-home-plugin.schemas > /dev/null

subdirs: $(SUBDIRS)

$(SUBDIRS):
	$(MAKE) -C $@

create_builddir:
	mkdir -p build

.PHONY: all clean install $(SUBDIRS)

clean:
	rm -rf build
	for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean);done
