
DOMAIN=hwdb-client
PO_FILES := $(wildcard *.po)
CONTACT=hostmaster@grawert.net

all: update-po

# update the pot

$(DOMAIN).pot: POTFILES.in 
	xml2po ../questions_en.xml > $(DOMAIN).xml.pot	
	XGETTEXT_ARGS=--msgid-bugs-address=$(CONTACT) intltool-update  --pot -g $(DOMAIN) -o $(DOMAIN).pot
	msgcat $(DOMAIN).xml.pot $(DOMAIN).pot  > $(DOMAIN)-all.pot
	mv $(DOMAIN)-all.pot $(DOMAIN).pot

# merge the new stuff into the po files
merge-po: $(PO_FILES)
	for lang in $(patsubst %.po,%,$(wildcard *.po)); do \
		XGETTEXT_ARGS=--msgid-bugs-address=$(CONTACT) intltool-update   -g  $(DOMAIN) --dist $$lang; \
	done

# create mo from the pos
%.mo : %.po
	mkdir -p mo/$(subst .po,,$<)/LC_MESSAGES/ 
	msgfmt $< -o mo/$(subst .po,,$<)/LC_MESSAGES/$(DOMAIN).mo 


# dummy target 
update-po: $(DOMAIN).pot merge-po $(patsubst %.po,%.mo,$(wildcard *.po))

