LOCALEDIR 	= $(RPM_BUILD_ROOT)/usr/share/locale
LANG		= en_US

MSGFMT		= msgfmt -v --statistics

SUBDIRS		= dist-6.0 powertools-6.0
POFILES		= $(addsuffix /C.po, $(SUBDIRS))
POTFILES	= dist-6.0/specs.pot powertools-6.0/powertools.pot
MOFILES		= specs.mo powertools.mo

VERSION		= $(shell awk '/^Version:/ { print $$2 }' specspo.spec)
ARCHIVE		= specspo-$(VERSION).tar.gz

all: $(MOFILES)

install: $(MOFILES)
	install -d $(LOCALEDIR)/$(LANG)/LC_MESSAGES
	install -c $(MOFILES) $(LOCALEDIR)/$(LANG)/LC_MESSAGES

check: $(POFILES)
	for pofile in $(POFILES) ; do \
		echo "Testing $$pofile..." ; \
		$(MSGFMT) -o /dev/null $$pofile ; \
	done

specs.mo: dist-6.0/C.po
	$(MSGFMT) -o $@ $<

powertools.mo: powertools-6.0/C.po
	$(MSGFMT) -o $@ $<

archive: $(POFILES) specspo.spec Makefile $(POTFILES)
	@rm -f $(ARCHIVE)
	@for i in $(SUBDIRS) ; do $(MAKE) -C $$i ; done
	@tar czf $(ARCHIVE) $^

clean:
	@rm -f *~ $(MOFILES)
	@for i in $(SUBDIRS) ; do $(MAKE) clean -C $$i ; done
	@rm -f specspo*.tar.gz

