1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
ifndef BUILD_PIC_LIBS
ifeq ($(wildcard /etc/debian_version),)
BUILD_PIC_LIBS=n
else
BUILD_PIC_LIBS=y
endif
endif
INSTALL = install
INSTALL_PROG = $(INSTALL) -m0755
INSTALL_DATA = $(INSTALL) -m0644
INSTALL_DIR = $(INSTALL) -d -m0755
MAJOR = 3.0
MINOR = 0
CC = gcc
XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Rules.mk
vpath %c $(XEN_LIBXUTIL)
INCLUDES += -I $(XEN_LIBXUTIL)
SRCS :=
SRCS += xc_atropos.c
SRCS += xc_bvtsched.c
SRCS += xc_domain.c
SRCS += xc_evtchn.c
SRCS += xc_io.c
SRCS += xc_linux_build.c
SRCS += xc_plan9_build.c
SRCS += xc_linux_restore.c
SRCS += xc_linux_save.c
SRCS += xc_misc.c
SRCS += xc_physdev.c
SRCS += xc_private.c
SRCS += xc_rrobin.c
SRCS += xc_vmx_build.c
CFLAGS += -Wall
CFLAGS += -Werror
CFLAGS += -O3
CFLAGS += -fno-strict-aliasing
CFLAGS += $(INCLUDES) -I.
# Get gcc to generate the dependencies for us.
CFLAGS += -Wp,-MD,.$(@F).d
DEPS = .*.d
LIB_OBJS := $(patsubst %.c,%.o,$(SRCS))
PIC_OBJS := $(patsubst %.c,%.opic,$(SRCS))
LIB := libxc.a libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
all: check-for-zlib mk-symlinks
$(MAKE) $(LIB)
check-for-zlib:
@if [ ! -e /usr/include/zlib.h ]; then \
echo "***********************************************************"; \
echo "ERROR: install zlib header files (http://www.gzip.org/zlib)"; \
echo "***********************************************************"; \
false; \
fi
LINUX_ROOT := $(wildcard $(XEN_ROOT)/linux-2.6.*-xen-sparse)
mk-symlinks:
[ -e xen/linux ] || mkdir -p xen/linux
[ -e xen/io ] || mkdir -p xen/io
( cd xen >/dev/null ; \
ln -sf ../$(XEN_ROOT)/xen/include/public/*.h . )
( cd xen/io >/dev/null ; \
ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
( cd xen/linux >/dev/null ; \
ln -sf ../../$(LINUX_ROOT)/include/asm-xen/linux-public/*.h . )
install: all
[ -d $(DESTDIR)/usr/lib ] || $(INSTALL_DIR) $(DESTDIR)/usr/lib
[ -d $(DESTDIR)/usr/include ] || $(INSTALL_DIR) $(DESTDIR)/usr/include
$(INSTALL_PROG) libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib
$(INSTALL_DATA) libxc.a $(DESTDIR)/usr/lib
ln -sf libxc.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/lib/libxc.so.$(MAJOR)
ln -sf libxc.so.$(MAJOR) $(DESTDIR)/usr/lib/libxc.so
$(INSTALL_DATA) xc.h $(DESTDIR)/usr/include
clean:
rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
rpm: all
rm -rf staging
mkdir staging
mkdir staging/i386
rpmbuild --define "staging$$PWD/staging" --define '_builddir.' \
--define "_rpmdir$$PWD/staging" -bb rpm.spec
mv staging/i386/*.rpm .
rm -rf staging
$(PIC_OBJS): %.opic: %.c
$(CC) $(CPPFLAGS) -DPIC $(CFLAGS) -fPIC -c -o $@ $<
libxc.a: $(OBJS)
$(AR) rc $@ $^
libxc.so: libxc.so.$(MAJOR)
ln -sf $< $@
libxc.so.$(MAJOR): libxc.so.$(MAJOR).$(MINOR)
ln -sf $< $@
ifeq ($(BUILD_PIC_LIBS),y)
libxc.so.$(MAJOR).$(MINOR): $(PIC_OBJS)
$(CC) -Wl,-soname -Wl,libxc.so.$(MAJOR) -shared -o $@ $^ -L../libxutil -lxutil -lz
else
libxc.so.$(MAJOR).$(MINOR): $(LIB_OBJS)
$(CC) -Wl,-soname -Wl,libxc.so.$(MAJOR) -shared -o $@ $^ -L../libxutil -lxutil -lz
endif
-include $(DEPS)
|