- python does not export variables beginning with underscore
[util-vserver.git] / python / Makefile
1 #
2 # GNUMakefile for util-vserver Python bindings
3 #
4 # It's too hard to integrate distutils into the autoconf/libtool
5 # framework, so run this Makefile separately from and after the normal
6 # util-vserver build.
7 #
8 # Steve Muir <smuir@cs.princeton.edu>
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # Copyright (C) 2005 The Trustees of Princeton University
11 #
12 # $Id: Makefile,v 1.7 2005/08/26 04:00:44 mlhuang Exp $
13 #
14
15 ALL := vserverimpl.so vduimpl.so util_vserver_vars.py
16
17 # need command substitution
18 SHELL := /bin/bash
19
20 pythonlibdir := @libdir@/python@PYTHON_VERSION@/site-packages
21
22 all: $(ALL)
23
24 %.o: %.c
25         # builds object and incompletely linked library
26         python setup.py build_ext
27         # copy to current directory
28         cp -a build/temp.*/*.o .
29
30 vserverimpl.so vduimpl.so: %.so: %.o
31         # relink the object against libvserver with libtool
32         ../libtool --tag=CC --mode=link $(CC) -shared -o $@ $< ../lib/libvserver.la
33
34 util_vserver_vars.py: ../scripts/util-vserver-vars
35         # python does not export variables beginning with underscore
36         (. $< ; \
37         while read var ; do eval echo $$var=\$${$$var} ; done < \
38         <(sed -ne "s/\([^=]*\)=.*/\1/p" $<) \
39         | sed -e "s/^_*//" -e "s/\([^=]*\)=\(.*\)/\1='\2'/") > $@
40
41 install: $(ALL)
42         # install relinked libraries and byte-compiled scripts
43         python setup.py install --root="$(DESTDIR)"
44         # reinstall libraries with libtool so that the final path
45         # to libvserver is resolved
46         for so in $(filter %.so, $(ALL)) ; do \
47           ../libtool --tag=CC --mode=install install "$$so" `find "$(DESTDIR)" -name "$$so"` ; \
48         done
49
50 clean:
51         rm -rf $(ALL) *.o build
52
53 .PHONY: all install clean