Files
xen/tools/python/Makefile
T
Keir Fraser 727a00e80e Permit user to suppress passing --prefix to setup.py
We change all invocations of setup.py as follows:

* use $(PYTHON) instead of `python' so that the user can specify
  an alternative python version if they need to.  If not set it
  defaults to `python' in Config.mk.

* pass --prefix=$(PREFIX) via a new make variable
  $(PYTHON_PREFIX_ARG).  This allows a user to suppress the
  --prefix=... argument entirely by setting PYTHON_PREFIX_ARG=''.
  This will work around the bug described here
     https://bugs.launchpad.net/ubuntu/+bug/362570
  where passing --prefix=/usr/local (which ought to have no effect as
  /usr/local is the default prefix) changes which subdirectory
  distutils chooses, and results in the files being installed in
  site-packages which is not on the default search path.

  Users not affected by this python packaging bug should not set
  PYTHON_PREFIX_ARG and their builds will not be affected.  (Provided
  PREFIX did not contain spaces.  People who put spaces in PREFIX are
  being quite optimistic.)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2009-05-07 19:32:10 +01:00

86 lines
2.4 KiB
Makefile

XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Rules.mk
.PHONY: all
all: build
# For each new supported translation, add its name here, eg 'fr_FR'
# to cause the .po file to be built & installed, eg
LINGUAS :=
POPACKAGE := xen-xm
PODIR := xen/xm/messages
POTFILE := $(PODIR)/xen-xm.pot
I18NSRCFILES = $(shell find xen/xm/ -name '*.py')
CATALOGS = $(patsubst %,xen/xm/messages/%.mo,$(LINGUAS))
NLSDIR = $(SHAREDIR)/locale
.PHONY: build buildpy
buildpy:
CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py build
build: buildpy refresh-pot refresh-po $(CATALOGS)
# NB we take care to only update the .pot file it strings have
# actually changed. This is complicated by the embedded date
# string, hence the sed black magic. This avoids the expensive
# re-generation of .po files on every single build
refresh-pot: $(I18NSRCFILES)
xgettext --default-domain=$(POPACAKGE) \
--keyword=N_ \
--keyword=_ \
-o $(POTFILE)-tmp \
$(I18NSRCFILES)
sed -f remove-potcdate.sed < $(POTFILE) > $(POTFILE)-1
sed -f remove-potcdate.sed < $(POTFILE)-tmp > $(POTFILE)-2
set -e; if cmp -s $(POTFILE)-1 $(POTFILE)-2; then \
rm -f $(POTFILE)-tmp $(POTFILE)-1 $(POTFILE)-2; \
else \
mv $(POTFILE)-tmp $(POTFILE); \
rm -f $(POTFILE)-1 $(POTFILE)-2; \
fi
refresh-po: $(POTFILE)
set -e; for l in $(LINGUAS); do \
if $(MSGMERGE) $(PODIR)/$$l.po $(POTFILE) > $(PODIR)/$$l-tmp ; then \
mv -f $(PODIR)/$$l-tmp $(PODIR)/$$l.po ; \
echo "$(MSGMERGE) of $$l.po succeeded" ; \
else \
echo "$(MSGMERGE) of $$l.po failed" ; \
rm -f $(PODIR)/$$l-tmp ; \
fi \
done
%.mo: %.po
$(MSGFMT) -c -o $@ $<
.PHONY: install
install: install-messages install-dtd
CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py install \
$(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" --force
install-dtd: all
$(INSTALL_DIR) $(DESTDIR)$(DOCDIR)
$(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(DOCDIR)
install-messages: all
set -e; if which $(MSGFMT) >/dev/null ; then \
$(INSTALL_DIR) $(DESTDIR)$(NLSDIR); \
for l in $(LINGUAS); do \
$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l; \
$(INSTALL_DIR) $(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES; \
$(INSTALL_DATA) $(PODIR)/$$l.mo \
$(DESTDIR)$(NLSDIR)/$$l/LC_MESSAGES/$(POPACKAGE).mo; \
done ; \
fi
.PHONY: test
test:
export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); python test.py -b -u
.PHONY: clean
clean:
rm -rf build *.pyc *.pyo *.o *.a *~ $(CATALOGS) xen/util/auxbin.pyc
rm -f $(DEPS)
-include $(DEPS)