blob: c041f4c858ee26866d2a20e67e200fd5e79b4e3b [file] [log] [blame]
Anthony Liguori834574e2013-02-20 07:43:24 -06001# 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 Weil00134a62013-07-05 22:55:42 +02004# Set SRC_PATH for in-tree builds without configuration.
Anthony Liguori834574e2013-02-20 07:43:24 -06005SRC_PATH=..
6
Stefan Weilbcc55f32014-07-18 16:52:29 +02007# The default target must come before any include statements.
8all:
9
10.PHONY: all build clean install update
11
Paolo Bonzinia697d242014-09-22 16:19:05 +020012%.mo: %.po
Peter Maydell0bdb12c2016-10-04 17:27:21 +010013 $(call quiet-command, msgfmt -o $@ $<,"GEN","$@")
Paolo Bonzinia697d242014-09-22 16:19:05 +020014
Anthony Liguori834574e2013-02-20 07:43:24 -060015-include ../config-host.mak
Stefan Weil0cd8eaa2013-07-05 22:55:44 +020016include $(SRC_PATH)/rules.mak
Anthony Liguori834574e2013-02-20 07:43:24 -060017
Stefan Weil00134a62013-07-05 22:55:42 +020018PO_PATH=$(SRC_PATH)/po
19
20VERSION=$(shell cat $(SRC_PATH)/VERSION)
21SRCS=$(filter-out $(PO_PATH)/messages.po,$(wildcard $(PO_PATH)/*.po))
22OBJS=$(patsubst $(PO_PATH)/%.po,%.mo,$(SRCS))
23
24vpath %.po $(PO_PATH)
Anthony Liguori834574e2013-02-20 07:43:24 -060025
26all:
Stefan Weil18e12d42013-07-05 22:55:41 +020027 @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 Liguori834574e2013-02-20 07:43:24 -060029
30update: $(SRCS)
31
32build: $(OBJS)
33
34clean:
Jan Vesely891f8dc2016-03-19 21:58:54 -040035 rm -f $(OBJS)
Anthony Liguori834574e2013-02-20 07:43:24 -060036
37install: $(OBJS)
38 for obj in $(OBJS); do \
Mao Zhongyiba278772018-10-22 16:48:24 +080039 base=$$(basename $$obj .mo); \
Anthony Liguori834574e2013-02-20 07:43:24 -060040 $(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 Weil00134a62013-07-05 22:55:42 +020044$(PO_PATH)/messages.po: $(SRC_PATH)/ui/gtk.c
Michael Tokarevb920cad2014-04-27 13:32:07 +040045 $(call quiet-command, ( cd $(SRC_PATH) && \
Stefan Weil6598f0c2018-07-20 23:25:09 +020046 xgettext -o - --from-code=UTF-8 --foreign-user --no-location \
Stefan Weil1fa44922013-07-05 22:55:43 +020047 --package-name=QEMU --package-version=$(VERSION) \
48 --msgid-bugs-address=qemu-devel@nongnu.org -k_ -C ui/gtk.c | \
Peter Maydell0bdb12c2016-10-04 17:27:21 +010049 sed -e s/CHARSET/UTF-8/) >$@,"GEN","$@")
Anthony Liguori834574e2013-02-20 07:43:24 -060050
Stefan Weil00134a62013-07-05 22:55:42 +020051$(PO_PATH)/%.po: $(PO_PATH)/messages.po
Peter Maydell0bdb12c2016-10-04 17:27:21 +010052 $(call quiet-command, msgmerge -q $@ $< > $@.bak && mv $@.bak $@,"GEN","$@")