# Makefile for Computer Janitor
#
# Copyright (C) 2008-2011  Canonical, Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

all: data/computer-janitor-gtk.desktop

DESKTOP=data/computer-janitor-gtk.desktop
$(DESKTOP): $(DESKTOP).in
	intltool-merge -d po $(DESKTOP).in $(DESKTOP)

check: check-unittests check-has-unit-tests check-licenses

check-unittests:
	env COMPUTER_JANITOR_UNITTEST=yes LC_ALL=C python -m CoverageTestRunner
	rm -f .coverage

check-has-unit-tests:
	find computerjanitorapp -name '*.py' ! -name '*_tests.py' | \
	grep -Exv '^computerjanitorapp/(__init__|ui_gtk).py' | \
	sed 's/\.py$$//' | \
	while read file; do \
	    [ -e $${file}_tests.py ] || \
	    (echo "Missing unit test: $$file.py"; exit 1); done

check-licenses:
	./license-check

clean:
	rm -f computerjanitorapp/*.py[co] .coverage
	rm -f po/computerjanitor.pot
	rm -rf build $(DESKTOP)

update-po:
	echo '[encoding: UTF-8]' > po/POTFILES.in; \
	find computerjanitorapp -name \*.py >> po/POTFILES.in; \
	for f in data/*.ui; do \
		echo '[type: gettext/glade]'$$f >> po/POTFILES.in; \
	done; \
	ls data/*.in plugins/*.py >> po/POTFILES.in; \
	python setup.py build_i18n --merge-po --po-dir po
