1 | # |
---|
2 | # Copyright (c) 2006-2007, XenSource Inc. |
---|
3 | # |
---|
4 | # This library is free software; you can redistribute it and/or |
---|
5 | # modify it under the terms of the GNU Lesser General Public |
---|
6 | # License as published by the Free Software Foundation; either |
---|
7 | # version 2.1 of the License, or (at your option) any later version. |
---|
8 | # |
---|
9 | # This library is distributed in the hope that it will be useful, |
---|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | # Lesser General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU Lesser General Public |
---|
15 | # License along with this library; if not, write to the Free Software |
---|
16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | # |
---|
18 | |
---|
19 | MAJOR = 1.0 |
---|
20 | MINOR = 0 |
---|
21 | |
---|
22 | CFLAGS = -Iinclude \ |
---|
23 | $(shell xml2-config --cflags) \ |
---|
24 | $(shell curl-config --cflags) \ |
---|
25 | -W -Wall -Wmissing-prototypes -Werror -std=c99 -O2 -fPIC |
---|
26 | |
---|
27 | LDFLAGS = $(shell xml2-config --libs) \ |
---|
28 | $(shell curl-config --libs) |
---|
29 | |
---|
30 | # -h for Solaris |
---|
31 | SONAME_LDFLAG ?= -soname |
---|
32 | # -R /usr/sfw/$(LIBDIR) -shared for Solaris |
---|
33 | SHLIB_CFLAGS ?= -shared |
---|
34 | |
---|
35 | # ginstall for Solaris |
---|
36 | INSTALL = install |
---|
37 | INSTALL_DIR = $(INSTALL) -d -m0755 -p |
---|
38 | INSTALL_DATA = $(INSTALL) -m0644 -p |
---|
39 | |
---|
40 | LIBXENAPI_HDRS = $(wildcard include/*.h) |
---|
41 | LIBXENAPI_OBJS = $(patsubst %.c, %.o, $(wildcard src/*.c)) |
---|
42 | |
---|
43 | TEST_PROGRAMS = test/test_bindings test/test_event_handling |
---|
44 | |
---|
45 | TARBALL_DEST = libxenapi-$(MAJOR).$(MINOR) |
---|
46 | |
---|
47 | .PHONY: all |
---|
48 | all: $(TEST_PROGRAMS) |
---|
49 | |
---|
50 | libxenapi.so: libxenapi.so.$(MAJOR) |
---|
51 | ln -sf $< $@ |
---|
52 | |
---|
53 | libxenapi.so.$(MAJOR): libxenapi.so.$(MAJOR).$(MINOR) |
---|
54 | ln -sf $< $@ |
---|
55 | |
---|
56 | libxenapi.so.$(MAJOR).$(MINOR): $(LIBXENAPI_OBJS) |
---|
57 | $(CC) $(CFLAGS) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenapi.so.$(MAJOR) $(SHLIB_CFLAGS) -o $@ $^ |
---|
58 | |
---|
59 | libxenapi.a: $(LIBXENAPI_OBJS) |
---|
60 | $(AR) rcs libxenapi.a $^ |
---|
61 | |
---|
62 | $(TEST_PROGRAMS): test/%: test/%.o libxenapi.so |
---|
63 | $(CC) $(LDFLAGS) -o $@ $< -L . -lxenapi |
---|
64 | |
---|
65 | |
---|
66 | .PHONY: install |
---|
67 | install: all |
---|
68 | $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/api |
---|
69 | $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR) |
---|
70 | $(INSTALL_PROG) libxenapi.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR) |
---|
71 | ln -sf libxenapi.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libxenapi.so.$(MAJOR) |
---|
72 | ln -sf libxenapi.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libxenapi.so |
---|
73 | $(INSTALL_DATA) libxenapi.a $(DESTDIR)/usr/$(LIBDIR) |
---|
74 | for i in $(LIBXENAPI_HDRS); do \ |
---|
75 | $(INSTALL_DATA) $$i $(DESTDIR)/usr/include/xen/api; \ |
---|
76 | done |
---|
77 | |
---|
78 | |
---|
79 | .PHONY: tarball |
---|
80 | tarball: $(TARBALL_DEST).tar.bz2 |
---|
81 | |
---|
82 | $(TARBALL_DEST).tar.bz2: all |
---|
83 | rm -Rf $(TARBALL_DEST) |
---|
84 | mkdir -p $(TARBALL_DEST)/include/xen/api |
---|
85 | mkdir -p $(TARBALL_DEST)/src |
---|
86 | mkdir -p $(TARBALL_DEST)/test |
---|
87 | cp COPYING $(TARBALL_DEST) |
---|
88 | cp Makefile.dist $(TARBALL_DEST)/Makefile |
---|
89 | cp Makefile.dist $(TARBALL_DEST)/Makefile.dist |
---|
90 | cp README $(TARBALL_DEST) |
---|
91 | cp include/*.h $(TARBALL_DEST)/include |
---|
92 | cp include/xen/api/*.h $(TARBALL_DEST)/include/xen/api |
---|
93 | cp src/*.c $(TARBALL_DEST)/src |
---|
94 | cp test/*.c $(TARBALL_DEST)/test |
---|
95 | fakeroot chown root:root -R $(TARBALL_DEST) |
---|
96 | fakeroot tar cjf $(TARBALL_DEST).tar.bz2 $(TARBALL_DEST) |
---|
97 | |
---|
98 | |
---|
99 | .PHONY: clean |
---|
100 | clean: |
---|
101 | rm -f `find -name *.o` |
---|
102 | rm -f libxenapi.so* |
---|
103 | rm -f libxenapi.a |
---|
104 | rm -f $(TEST_PROGRAMS) |
---|
105 | |
---|
106 | |
---|
107 | .PHONY: uberheader |
---|
108 | uberheader: include/xen/api/xen_all.h |
---|
109 | include/xen/api/xen_all.h:: |
---|
110 | echo "/* This file is autogenerated */" >$@ |
---|
111 | echo "#ifndef XEN_API_XEN_ALL_H" >>$@ |
---|
112 | echo "#define XEN_API_XEN_ALL_H" >>$@ |
---|
113 | ls include/xen/api/*.h | grep -v xen_all.h | grep -v _decl.h | \ |
---|
114 | sed 's,^include/\(.*\)$$,#include <\1>,g' >>$@ |
---|
115 | echo "#endif" >>$@ |
---|