Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 1 | # This makefile is very special as it's meant to build as part of the build |
| 2 | # process and also within the source tree to update the translation files. |
| 3 | |
Stefan Weil | 00134a6 | 2013-07-05 22:55:42 +0200 | [diff] [blame] | 4 | # Set SRC_PATH for in-tree builds without configuration. |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 5 | SRC_PATH=.. |
| 6 | |
Stefan Weil | bcc55f3 | 2014-07-18 16:52:29 +0200 | [diff] [blame] | 7 | # The default target must come before any include statements. |
| 8 | all: |
| 9 | |
| 10 | .PHONY: all build clean install update |
| 11 | |
Paolo Bonzini | a697d24 | 2014-09-22 16:19:05 +0200 | [diff] [blame] | 12 | %.mo: %.po |
Peter Maydell | 0bdb12c | 2016-10-04 17:27:21 +0100 | [diff] [blame] | 13 | $(call quiet-command, msgfmt -o $@ $<,"GEN","$@") |
Paolo Bonzini | a697d24 | 2014-09-22 16:19:05 +0200 | [diff] [blame] | 14 | |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 15 | -include ../config-host.mak |
Stefan Weil | 0cd8eaa | 2013-07-05 22:55:44 +0200 | [diff] [blame] | 16 | include $(SRC_PATH)/rules.mak |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 17 | |
Stefan Weil | 00134a6 | 2013-07-05 22:55:42 +0200 | [diff] [blame] | 18 | PO_PATH=$(SRC_PATH)/po |
| 19 | |
| 20 | VERSION=$(shell cat $(SRC_PATH)/VERSION) |
| 21 | SRCS=$(filter-out $(PO_PATH)/messages.po,$(wildcard $(PO_PATH)/*.po)) |
| 22 | OBJS=$(patsubst $(PO_PATH)/%.po,%.mo,$(SRCS)) |
| 23 | |
| 24 | vpath %.po $(PO_PATH) |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 25 | |
| 26 | all: |
Stefan Weil | 18e12d4 | 2013-07-05 22:55:41 +0200 | [diff] [blame] | 27 | @echo "Use 'make update' to update translation files or use 'make build'" |
| 28 | @echo "or 'make install' to build and install the translation files." |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 29 | |
| 30 | update: $(SRCS) |
| 31 | |
| 32 | build: $(OBJS) |
| 33 | |
| 34 | clean: |
Jan Vesely | 891f8dc | 2016-03-19 21:58:54 -0400 | [diff] [blame] | 35 | rm -f $(OBJS) |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 36 | |
| 37 | install: $(OBJS) |
| 38 | for obj in $(OBJS); do \ |
Mao Zhongyi | ba27877 | 2018-10-22 16:48:24 +0800 | [diff] [blame] | 39 | base=$$(basename $$obj .mo); \ |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 40 | $(INSTALL) -d $(DESTDIR)$(prefix)/share/locale/$$base/LC_MESSAGES; \ |
| 41 | $(INSTALL) -m644 $$obj $(DESTDIR)$(prefix)/share/locale/$$base/LC_MESSAGES/qemu.mo; \ |
| 42 | done |
| 43 | |
Stefan Weil | 00134a6 | 2013-07-05 22:55:42 +0200 | [diff] [blame] | 44 | $(PO_PATH)/messages.po: $(SRC_PATH)/ui/gtk.c |
Michael Tokarev | b920cad | 2014-04-27 13:32:07 +0400 | [diff] [blame] | 45 | $(call quiet-command, ( cd $(SRC_PATH) && \ |
Stefan Weil | 6598f0c | 2018-07-20 23:25:09 +0200 | [diff] [blame] | 46 | xgettext -o - --from-code=UTF-8 --foreign-user --no-location \ |
Stefan Weil | 1fa4492 | 2013-07-05 22:55:43 +0200 | [diff] [blame] | 47 | --package-name=QEMU --package-version=$(VERSION) \ |
| 48 | --msgid-bugs-address=qemu-devel@nongnu.org -k_ -C ui/gtk.c | \ |
Peter Maydell | 0bdb12c | 2016-10-04 17:27:21 +0100 | [diff] [blame] | 49 | sed -e s/CHARSET/UTF-8/) >$@,"GEN","$@") |
Anthony Liguori | 834574e | 2013-02-20 07:43:24 -0600 | [diff] [blame] | 50 | |
Stefan Weil | 00134a6 | 2013-07-05 22:55:42 +0200 | [diff] [blame] | 51 | $(PO_PATH)/%.po: $(PO_PATH)/messages.po |
Peter Maydell | 0bdb12c | 2016-10-04 17:27:21 +0100 | [diff] [blame] | 52 | $(call quiet-command, msgmerge -q $@ $< > $@.bak && mv $@.bak $@,"GEN","$@") |