aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xc/lib/Makefile
blob: f542935167e4331c85da0a0d815158757eb1ad2b (plain)
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
MAJOR    = 1.3
MINOR    = 0
SONAME   = libxc.so.$(MAJOR)

CC       = gcc
CFLAGS   = -c -Werror -O3 -fno-strict-aliasing
CFLAGS  += -I../../../xen/include/hypervisor-ifs
CFLAGS  += -I../../xend/lib
CFLAGS  += -I../../../xenolinux-sparse/include

HDRS     = $(wildcard *.h)
OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))

LIB      = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)

all: check-for-zlib $(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

install: all
	mkdir -p $(prefix)/usr/lib
	mkdir -p $(prefix)/usr/include
	install -m0755 $(LIB) $(prefix)/usr/lib
	install -m0644 xc.h $(prefix)/usr/include

clean:
	$(RM) *.a *.so *.o *.rpm $(LIB)

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

libxc.so:
	ln -sf libxc.so.$(MAJOR) $@
libxc.so.$(MAJOR):
	ln -sf libxc.so.$(MAJOR).$(MINOR) $@
libxc.so.$(MAJOR).$(MINOR): $(OBJS)
	$(CC) -Wl,-soname -Wl,$(SONAME) -shared -o $@ $^ -lz

%.o: %.c $(HDRS) Makefile
	$(CC) $(CFLAGS) -o $@ $<