ia64/xen-unstable

view tools/python/Makefile @ 19616:61501fa86b1b

python: get rid of hardcoded search pathes in python code.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 19 02:16:37 2009 +0100 (2009-05-19)
parents bf946cc3008b
children 303793468225
line source
1 XEN_ROOT = ../..
2 include $(XEN_ROOT)/tools/Rules.mk
4 .PHONY: all
5 all: build
7 # For each new supported translation, add its name here, eg 'fr_FR'
8 # to cause the .po file to be built & installed, eg
9 LINGUAS :=
10 POPACKAGE := xen-xm
11 PODIR := xen/xm/messages
12 POTFILE := $(PODIR)/xen-xm.pot
13 I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
14 CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
15 NLSDIR = $(SHAREDIR)/locale
16 xenpath = "xen/util/path.py"
18 .PHONY: build buildpy genpath
19 genpath:
20 rm -f ${xenpath}
21 echo "SBINDIR=\"$(SBINDIR)\"" >> ${xenpath}
22 echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath}
23 echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath}
24 echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath}
25 echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath}
27 buildpy: genpath
28 CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
30 build: buildpy refresh-pot refresh-po $(CATALOGS)
32 # NB we take care to only update the .pot file it strings have
33 # actually changed. This is complicated by the embedded date
34 # string, hence the sed black magic. This avoids the expensive
35 # re-generation of .po files on every single build
36 refresh-pot: $(I18NSRCFILES)
37 xgettext --default-domain=$(POPACAKGE) \
38 --keyword=N_ \
39 --keyword=_ \
40 -o $(POTFILE)-tmp \
41 $(I18NSRCFILES)
42 sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
43 sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
44 set -e; if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
45 rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
46 else \
47 mv $(POTFILE)-tmp $(POTFILE); \
48 rm -f $(POTFILE)-1 $(POTFILE)-2; \
49 fi
51 refresh-po: $(POTFILE)
52 set -e; for l in $(LINGUAS); do \
53 if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; then \
54 mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
55 echo "$(MSGMERGE) of $$l.po succeeded" ; \
56 else \
57 echo "$(MSGMERGE) of $$l.po failed" ; \
58 rm -f $(PODIR)/$$l-tmp ; \
59 fi \
60 done
62 %.mo: %.po
63 $(MSGFMT) -c -o $@ $<
65 .PHONY: install
66 install: install-messages install-dtd
67 CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py install \
68 $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" --force
70 install-dtd: all
71 $(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
72 $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(DOCDIR)
74 install-messages: all
75 set -e; if which $(MSGFMT) >/dev/null ; then \
76 $(INSTALL_DIR) $(DESTDIR)$(NLSDIR); \
77 for l in $(LINGUAS); do \
78 $(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l; \
79 $(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
80 $(INSTALL_DATA) $(PODIR)/$$l.mo \
81 $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES/$(POPACKAGE).mo; \
82 done ; \
83 fi
85 .PHONY: test
86 test:
87 export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); python test.py -b -u
89 .PHONY: clean
90 clean:
91 rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
92 rm -f $(DEPS)
94 -include $(DEPS)