.PHONY : all run-stakeout templates doc api-doc extract-strings localizations

all : templates localizations doc api-doc

run-stakeout :
	stakeout.rb make \
		'agentmanager/*.py' \
		'agents/*.py' \
		'agentmanager/templates/*.tmpl' \
		README \
		doc/writing-agents.rst \
		'i18n/fr/*.po' &

templates :
	cd agentmanager/templates && make

doc :
	cd doc && make

api-doc : api/index.html

api/index.html : agentmanager/*.py agents/*.py
	epydoc --html -o api -n zephir-agents agentmanager agents

# list localizable strings
XGETTEXT = xgettext -F -i --omit-header -L "Python"
extract-strings :
	@cat i18n/po_header.in
	@find . -name "*.py" -not -name "*Tmpl.py*" -exec echo -e "\n########" {} \; -exec $(XGETTEXT) {} -o - \;

localizations : i18n/fr/LC_MESSAGES/zephir-agents.mo
	mkdir -p i18n/fr/LC_MESSAGES

i18n/fr/LC_MESSAGES/zephir-agents.mo : i18n/fr/fr.po
	msgfmt $< -o $@


# to list non localized strings
#   find . -name "*.py" -exec xgettext -L "Python" {} -a - \; | grep msgid | sort -u > new_msgid_list
#   grep msgid fr.po > old_msg_id_list
#   comm -23 new_msgid_list old_msgid_list
