ia64/xen-unstable

view tools/Rules.mk @ 17830:b8fa4a11f715

Have `make install' write the Python version number in the #!

The Xen tools contain a number of Python extensions written in C. The
C API to Python, used by these extensions, is not stable from one
version of Python to the next.

Our build system uses whatever version of Python is the default on the
build system at that time to build these extensions. However, the
actual scripts such as `xm' use #!/usr/bin/env python which uses
whichever version of Python is the default on the deployment system at
the time of invocation.

If for any reason these two versions of Python are not the same (eg,
because the system is built on one computer and executed on another,
or because the system's gains a more recent Python installation
alongside the original which changes the previous default), warnings
and failures occur.

In this patch I arrange for Python scripts to be installed via a
special wrapper around `install', which determines the build-time
Python version and path and then writes that into the #! line at the
point of `make install' (or `make dist'). (It can also be overridden
by setting PYTHON_PATH.)

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 11 09:36:23 2008 +0100 (2008-06-11)
parents 784f6dc204be
children f292689f48ba
line source
1 # -*- mode: Makefile; -*-
3 # `all' is the default target
4 all:
6 include $(XEN_ROOT)/Config.mk
8 XEN_INCLUDE = $(XEN_ROOT)/tools/include
9 XEN_XC = $(XEN_ROOT)/tools/python/xen/lowlevel/xc
10 XEN_LIBXC = $(XEN_ROOT)/tools/libxc
11 XEN_XENSTORE = $(XEN_ROOT)/tools/xenstore
12 XEN_LIBXENSTAT = $(XEN_ROOT)/tools/xenstat/libxenstat/src
14 CFLAGS_include = -I$(XEN_INCLUDE)
16 CFLAGS_libxenctrl = -I$(XEN_LIBXC) $(CFLAGS_include)
17 LDFLAGS_libxenctrl = -L$(XEN_LIBXC) -lxenctrl
19 CFLAGS_libxenguest = -I$(XEN_LIBXC) $(CFLAGS_include)
20 LDFLAGS_libxenguest = -L$(XEN_LIBXC) -lxenguest
22 CFLAGS_libxenstore = -I$(XEN_XENSTORE) $(CFLAGS_include)
23 LDFLAGS_libxenstore = -L$(XEN_XENSTORE) -lxenstore
25 X11_LDPATH = -L/usr/X11R6/$(LIBLEAFDIR)
27 CFLAGS += -D__XEN_TOOLS__
29 # Enable implicit LFS support *and* explicit LFS names.
30 CFLAGS += $(shell getconf LFS_CFLAGS)
31 CFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
32 LDFLAGS += $(shell getconf LFS_LDFLAGS)
34 # 32-bit x86 does not perform well with -ve segment accesses on Xen.
35 CFLAGS-$(CONFIG_X86_32) += $(call cc-option,$(CC),-mno-tls-direct-seg-refs)
36 CFLAGS += $(CFLAGS-y)
38 DEFAULT_PYTHON_PATH := $(shell $(XEN_ROOT)/tools/python/get-path)
39 PYTHON_PATH ?= $(DEFAULT_PYTHON_PATH)
40 INSTALL_PYTHON_PROG = $(XEN_ROOT)/tools/python/install-wrap \
41 "$(PYTHON_PATH)" $(INSTALL_PROG)
43 # Require GCC v3.4+ (to avoid issues with alignment constraints in Xen headers)
44 check-$(CONFIG_X86) = $(call cc-ver-check,CC,0x030400,\
45 "Xen requires at least gcc-3.4")
46 $(eval $(check-y))
48 %.opic: %.c
49 $(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
51 %.o: %.c
52 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
54 %.o: %.cc
55 $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
57 subdirs-all subdirs-clean subdirs-install: .phony
58 @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
59 $(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
60 done
62 subdir-all-% subdir-clean-% subdir-install-%: .phony
63 $(MAKE) -C $* $(patsubst subdir-%-$*,%,$@)