DESTDIR = 
HELPFILES = $(shell ls help | grep -E 'xhtml$$|css$$|png$$')
LRELEASE = lrelease-qt4
LUPDATE = pylupdate4
SOURCES = $(shell ls *.py| grep -v marques.py)
ITF_SOURCES = $(shell ls *.ui)
ITF = $(patsubst %.ui, Ui_%.py, $(ITF_SOURCES))
TSFILES = $(shell ls lang/*.ts)

all: interfaces languages

interfaces: $(ITF)

Ui_%.py: %.ui
	pyuic4 $< > $@

languages:
	$(LUPDATE) $(SOURCES) -ts $(TSFILES)
	$(LRELEASE) lang/*.ts 2>/dev/null || lrelease lang/*.ts 2>/dev/null || true


clean:
	rm -rf build
	rm -f *~ Ui_* *.pyc lang/*.qm

distclean: clean

install:
	install -d $(DESTDIR)/usr/share/scolasync
	install -m 644 marques.py $(DESTDIR)/usr/share/scolasync
	install	-d $(DESTDIR)/usr/share/pyshared/scolasync
	install -m 644 $(SOURCES) $(DESTDIR)/usr/share/pyshared/scolasync
	for f in $(ITF); do \
	  sed -e 's%images%/usr/share/scolasync/images%' \
	    -e 's%.*\(/usr/share/icons.*\)%\1%' \
	    $$f > $(DESTDIR)/usr/share/pyshared/scolasync/$$f; done
	install -d $(DESTDIR)/usr/share/scolasync/lang
	install -m 644 lang/*.qm $(DESTDIR)/usr/share/scolasync/lang
	install -d $(DESTDIR)/usr/share/scolasync/images
	install -m 644 images/* $(DESTDIR)/usr/share/scolasync/images
	install -d $(DESTDIR)/usr/share/scolasync/help
	install -m 644 help/* $(DESTDIR)/usr/share/scolasync/help

svn-keywords:
	for f in $(SOURCES); do svn propset svn:keywords "Id" $$f; done

PHONY: all interfaces languages clean distclean svn-keywords install

