X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=python%2FMakefile;h=7ae69d74738c480d4cffefdc96f7ce87b0ad49b6;hb=91cec69dc44c4a25c6ed53b874da4de35b6812b8;hp=3b8879de0e884511293b1371166f68598696c9d9;hpb=471f8ae097d6c209b6cca044534aae586d514c00;p=util-vserver.git diff --git a/python/Makefile b/python/Makefile index 3b8879d..7ae69d7 100644 --- a/python/Makefile +++ b/python/Makefile @@ -1,16 +1,53 @@ -INCLUDES := -I.. -I../lib -I/usr/include/python2.3 -CPPFLAGS = $(DEFS) $(INCLUDES) -CFLAGS = $(CPPFLAGS) -g -Wall -COMPILE = $(CC) $(CFLAGS) -LIBS = -L../lib -lvserver -LINK = $(CC) $(LDFLAGS) +# +# GNUMakefile for util-vserver Python bindings +# +# It's too hard to integrate distutils into the autoconf/libtool +# framework, so run this Makefile separately from and after the normal +# util-vserver build. +# +# Steve Muir +# Mark Huang +# Copyright (C) 2005 The Trustees of Princeton University +# +# $Id: Makefile,v 1.7 2005/08/26 04:00:44 mlhuang Exp $ +# -PY_MODS := passfdimpl.so +ALL := vserverimpl.so vduimpl.so util_vserver_vars.py -all: $(PY_MODS) +# need command substitution +SHELL := /bin/bash -$(PY_MODS): %.so: %.o - $(LINK) -shared -o $@ $^ $(LIBS) +pythonlibdir := @libdir@/python@PYTHON_VERSION@/site-packages + +all: $(ALL) %.o: %.c - $(COMPILE) -c $< + # builds object and incompletely linked library + python setup.py build_ext + # copy to current directory + cp -a build/temp.*/*.o . + +vserverimpl.so vduimpl.so: %.so: %.o + # relink the object against libvserver with libtool + ../libtool --tag=CC --mode=link $(CC) -shared -o $@ $< ../lib/libvserver.la + +util_vserver_vars.py: ../scripts/util-vserver-vars + # python does not export variables beginning with underscore + (. $< ; \ + while read var ; do eval echo $$var=\$${$$var} ; done < \ + <(sed -ne "s/\([^=]*\)=.*/\1/p" $<) \ + | sed -e "s/^_*//" -e "s/\([^=]*\)=\(.*\)/\1='\2'/") > $@ + +install: $(ALL) + # install relinked libraries and byte-compiled scripts + python setup.py install --root="$(DESTDIR)" + # reinstall libraries with libtool so that the final path + # to libvserver is resolved + for so in $(filter %.so, $(ALL)) ; do \ + ../libtool --tag=CC --mode=install install "$$so" `find "$(DESTDIR)" -name "$$so"` ; \ + done + +clean: + rm -rf $(ALL) *.o build + +.PHONY: all install clean