aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstore/Makefile
blob: cd4a7b307947fbdb2390870710180243871439e3 (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
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
XEN_ROOT=../..
# This does something wrong to TARGET_ARCH.
#include $(XEN_ROOT)/tools/Rules.mk
LIBDIR = lib
XEN_LIBXC          = $(XEN_ROOT)/tools/libxc

INSTALL         = install
INSTALL_DATA	= $(INSTALL) -m0644
INSTALL_PROG    = $(INSTALL) -m0755
INSTALL_DIR     = $(INSTALL) -d -m0755

PROFILE=#-pg
BASECFLAGS=-Wall -W -g 
# Make gcc generate dependencies.
BASECFLAGS += -Wp,-MD,.$(@F).d
PROG_DEP = .*.d
#BASECFLAGS+= -O3 $(PROFILE)
#BASECFLAGS+= -I$(XEN_ROOT)/tools
BASECFLAGS+= -I$(XEN_ROOT)/tools/libxc
BASECFLAGS+= -I$(XEN_ROOT)/xen/include/public
BASECFLAGS+= -I.

CFLAGS+=$(BASECFLAGS)
LDFLAGS=$(PROFILE) -L$(XEN_LIBXC)
TESTDIR=`pwd`/testsuite/tmp
TESTFLAGS=-DTESTING
TESTENV=XENSTORED_ROOTDIR=$(TESTDIR) XENSTORED_RUNDIR=$(TESTDIR)

all: xen xenstored libxenstore.a

testcode: xen xs_test xenstored_test xs_random

xen:
	ln -sf $(XEN_ROOT)/xen/include/public $@

xenstored: xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -lxc -o $@

xenstored_test: xenstored_core_test.o xenstored_watch_test.o xenstored_domain_test.o xenstored_transaction_test.o xs_lib.o talloc_test.o fake_libxc.o utils.o
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

xs_test: xs_test.o xs_lib.o utils.o
xs_random: xs_random.o xs_test_lib.o xs_lib.o talloc.o utils.o
xs_stress: xs_stress.o xs_test_lib.o xs_lib.o talloc.o utils.o

xs_test.o xs_stress.o xenstored_core_test.o xenstored_watch_test.o xenstored_transaction_test.o xenstored_domain_test.o xs_random.o xs_test_lib.o talloc_test.o fake_libxc.o: CFLAGS=$(BASECFLAGS) $(TESTFLAGS)

xenstored_%_test.o: xenstored_%.c
	$(COMPILE.c) -o $@ $<

xs_test_lib.o: xs.c
	$(COMPILE.c) -o $@ $<

talloc_test.o: talloc.c
	$(COMPILE.c) -o $@ $<

libxenstore.a: libxenstore.a(xs.o) libxenstore.a(xs_lib.o)

clean: testsuite-clean
	rm -f *.o *.a xs_test xenstored xenstored_test xs_random xs_stress xen
	-$(RM) $(PROG_DEP)

check: testsuite-run randomcheck stresstest

testsuite-run: xen xenstored_test xs_test
	$(TESTENV) testsuite/test.sh

testsuite-clean:
	rm -rf $(TESTDIR)

# Make this visible so they can see repeat tests without --fast if they
# fail.
RANDSEED=$(shell date +%s)
randomcheck: xs_random xenstored_test
	$(TESTENV) ./xs_random --simple --fast /tmp/xs_random 200000 $(RANDSEED)
	$(TESTENV) ./xs_random --fast /tmp/xs_random 100000 $(RANDSEED)
	$(TESTENV) ./xs_random --fail /tmp/xs_random 10000 $(RANDSEED)

stresstest: xs_stress xenstored_test
	rm -rf $(TESTDIR)/store
	export $(TESTENV); PID=`./xenstored_test --output-pid`; ./xs_stress 10000; ret=$$?; kill $$PID; exit $$ret

TAGS:
	etags `find . -name '*.[ch]'`

tarball: clean
	cd .. && tar -c -j -v -h -f xenstore.tar.bz2 xenstore/

install: xenstored libxenstore.a
	$(INSTALL_DIR) -p $(DESTDIR)/var/run/xenstored
	$(INSTALL_DIR) -p $(DESTDIR)/var/lib/xenstored
	$(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
	$(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin
	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
	$(INSTALL_DATA) libxenstore.a $(DESTDIR)/usr/$(LIBDIR)

-include $(PROG_DEP)