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

all: build-mo

# update the pot

$(DOMAIN).pot: POTFILES.in 
	xml2po ../questions_en.xml > $(DOMAIN).xml.pot	
	INTLTOOL_EXTRACT=/usr/bin/intltool-extract XGETTEXT_ARGS=--msgid-bugs-address=$(CONTACT) intltool-update  --pot -g $(DOMAIN) -o $(DOMAIN).pot
	msgcat $(DOMAIN).xml.pot $(DOMAIN).pot  > $(DOMAIN)-all.pot
	rm $(DOMAIN).xml.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 \
		INTLTOOL_EXTRACT=/usr/bin/intltool-extract 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 
build-mo: $(DOMAIN).pot $(patsubst %.po,%.mo,$(wildcard *.po))

clean:
	rm -rf mo
	rm -f $(DOMAIN).pot
