ia64/xen-unstable

view tools/xenstat/libxenstat/Makefile @ 6338:59a6a0350158

Minor xenstat changes from Christian Limpach.
author mark.williamson@cl.cam.ac.uk
date Fri Aug 19 18:22:56 2005 +0000 (2005-08-19)
parents 173b918160e2
children f51fe43c5d1c 6783e59e1c45
line source
1 # libxenstat: statistics-collection library for Xen
2 # Copyright (C) International Business Machines Corp., 2005
3 # Author: Josh Triplett <josht@us.ibm.com>
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 XEN_ROOT=../../..
16 include $(XEN_ROOT)/tools/Rules.mk
17 LINUX_ROOT := $(XEN_ROOT)/linux-2.6-xen-sparse
19 INSTALL = install
20 INSTALL_PROG = $(INSTALL) -m0755 -D
21 INSTALL_DATA = $(INSTALL) -m0644 -D
23 prefix=/usr
24 includedir=$(prefix)/include
25 libdir=$(prefix)/lib
27 LDCONFIG=ldconfig
28 MAKE_LINK=ln -sf
30 MAJOR=0
31 MINOR=0
33 LIB=src/libxenstat.a
34 SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR)
35 SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so
36 OBJECTS=src/xenstat.o src/xen-interface.o
37 SONAME_FLAGS=-Wl,-soname -Wl,libxenstat.so.$(MAJOR)
39 WARN_FLAGS=-Wall -Werror
41 CFLAGS+=-Isrc
42 CFLAGS+=-I$(XEN_ROOT)/xen/include/public
43 CFLAGS+=-I$(LINUX_ROOT)/include/asm-xen/linux-public/
44 LDFLAGS+=-Lsrc
46 all: $(LIB)
48 $(LIB): $(OBJECTS)
49 $(AR) rc $@ $^
50 $(RANLIB) $@
52 $(SHLIB): $(OBJECTS)
53 $(CC) $(LDFLAGS) $(SONAME_FLAGS) -shared -o $@ $(OBJECTS)
55 src/xenstat.o: src/xenstat.c src/xenstat.h src/xen-interface.h
56 $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<
58 src/xen-interface.o: src/xen-interface.c src/xen-interface.h
59 $(CC) $(CFLAGS) $(WARN_FLAGS) -c -o $@ $<
61 src/libxenstat.so.$(MAJOR): $(LIB)
62 $(MAKE_LINK) $(<F) $@
64 src/libxenstat.so: src/libxenstat.so.$(MAJOR)
65 $(MAKE_LINK) $(<F) $@
67 install: all
68 #install: all
69 # $(INSTALL_DATA) src/xenstat.h $(DESTDIR)$(includedir)/xenstat.h
70 # $(INSTALL_PROG) $(LIB) $(DESTDIR)$(libdir)/libxenstat.a
71 # $(INSTALL_PROG) $(SHLIB) \
72 # $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR).$(MINOR)
73 # $(MAKE_LINK) libxenstat.so.$(MAJOR).$(MINOR) \
74 # $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR)
75 # $(MAKE_LINK) libxenstat.so.$(MAJOR) \
76 # $(DESTDIR)$(libdir)/libxenstat.so
77 # -$(LDCONFIG)
79 PYLIB=bindings/swig/python/_xenstat.so
80 PYMOD=bindings/swig/python/xenstat.py
81 PYSRC=bindings/swig/python/_xenstat.c
82 PERLLIB=bindings/swig/perl/xenstat.so
83 PERLMOD=bindings/swig/perl/xenstat.pm
84 PERLSRC=bindings/swig/perl/xenstat.c
85 BINDINGS=$(PYLIB) $(PYMOD) $(PERLLIB) $(PERLMOD)
86 BINDINGSRC=$(PYSRC) $(PERLSRC)
88 # The all-bindings target builds all the language bindings
89 all-bindings: perl-bindings python-bindings
91 # The install-bindings target installs all the language bindings
92 install-bindings: install-perl-bindings install-python-bindings
94 $(BINDINGS): $(SHLIB) $(SHLIB_LINKS) src/xenstat.h
96 SWIG_FLAGS=-module xenstat -Isrc
98 # Python bindings
99 PYTHON_VERSION=2.3
100 PYTHON_FLAGS=-I/usr/include/python$(PYTHON_VERSION) -lpython$(PYTHON_VERSION)
101 $(PYSRC) $(PYMOD): bindings/swig/xenstat.i
102 swig -python $(SWIG_FLAGS) -outdir $(@D) -o $(PYSRC) $<
104 $(PYLIB): $(PYSRC)
105 $(CC) $(CFLAGS) $(LDFLAGS) $(PYTHON_FLAGS) -shared -lxenstat -o $@ $<
107 python-bindings: $(PYLIB) $(PYMOD)
109 pythonlibdir=$(prefix)/lib/python$(PYTHON_VERSION)/site-packages
110 install-python-bindings: $(PYLIB) $(PYMOD)
111 $(INSTALL_PROG) $(PYLIB) $(DESTDIR)$(pythonlibdir)/_xenstat.so
112 $(INSTALL_PROG) $(PYMOD) $(DESTDIR)$(pythonlibdir)/xenstat.py
114 ifeq ($(XENSTAT_PYTHON_BINDINGS),y)
115 all: python-bindings
116 install: install-python-bindings
117 endif
119 # Perl bindings
120 PERL_FLAGS=`perl -MConfig -e 'print "$$Config{ccflags} -I$$Config{archlib}/CORE";'`
121 $(PERLSRC) $(PERLMOD): bindings/swig/xenstat.i
122 swig -perl $(SWIG_FLAGS) -outdir $(@D) -o $(PERLSRC) $<
124 $(PERLLIB): $(PERLSRC)
125 $(CC) $(CFLAGS) $(LDFLAGS) $(PERL_FLAGS) -shared -lxenstat -o $@ $<
127 perl-bindings: $(PERLLIB) $(PERLMOD)
129 perllibdir=$(prefix)/lib/perl5
130 perlmoddir=$(prefix)/share/perl5
131 install-perl-bindings: $(PERLLIB) $(PERLMOD)
132 $(INSTALL_PROG) $(PERLLIB) $(DESTDIR)$(perllibdir)/xenstat.so
133 $(INSTALL_PROG) $(PERLMOD) $(DESTDIR)$(perlmoddir)/xenstat.pm
135 ifeq ($(XENSTAT_PERL_BINDINGS),y)
136 all: perl-bindings
137 install: install-perl-bindings
138 endif
140 clean:
141 rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS) \
142 $(BINDINGS) $(BINDINGSRC)