LOCALE_ALL=zh_TW zh_CN zh_HK

all: locale-all

locale-all: build
		
build: build-stamp
	
build-stamp:
	@for i in $(LOCALE_ALL); do \
		echo "Building translation $$i"; \
		(cd po/$$i/LC_MESSAGES && make build); \
	done

	@touch build-stamp

install: build
	cp -r $(CURDIR)/pphw/scim-ppbopomo/usr/* $(DESTDIR)/usr;
	cp -r $(CURDIR)/pphw/scim-pphanpin/usr/* $(DESTDIR)/usr;
	cp -r $(CURDIR)/pphw/scim-pphwrwp/usr/* $(DESTDIR)/usr;
	cp -r $(CURDIR)/pphw/scim-pptsangjei/usr/* $(DESTDIR)/usr;

	mkdir -p $(DESTDIR)/usr/share/nokia-maps/html/medos/i18n/zh;
	cp -r $(CURDIR)/map/* $(DESTDIR)/usr/share/nokia-maps/html/medos/i18n/zh;

	mkdir -p $(DESTDIR)/usr/share/ppchinese_pack_data;
	cp -r $(CURDIR)/tutorial/* $(DESTDIR)/usr/share/ppchinese_pack_data;

	@for i in $(LOCALE_ALL); do \
		echo "Installing locale $$i"; \
		mkdir -p $(DESTDIR)/usr/lib/locale/$$i; \
		cp -r $(CURDIR)/lib_messages/$$i $(DESTDIR)/usr/lib/locale; \
	done

	@for i in $(LOCALE_ALL); do \
		echo "Installing translation $$i"; \
		mkdir -p $(DESTDIR)/usr/share/locale/$$i/LC_MESSAGES; \
		cp $(CURDIR)/po/$$i/LC_MESSAGES/*.mo \
		   $(DESTDIR)/usr/share/locale/$$i/LC_MESSAGES;\
	done

	cp $(CURDIR)/locale-archive $(DESTDIR)/usr/lib/locale/locale-archive.fixed;	

clean:
	rm -f build-stamp
	rm -f $(CURDIR)/po/*/LC_MESSAGES/*.mo
