blob: 11f3683c40a3877c74683e309c48c1f2bb22554b (
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
|
PRODUCT_MAJOR_VERSION=6
PRODUCT_MINOR_VERSION=6
PRODUCT_MICRO_VERSION=80
PRODUCT_VERSION = $(PRODUCT_MAJOR_VERSION).$(PRODUCT_MINOR_VERSION).$(PRODUCT_MICRO_VERSION)
GO_BUILD = go build
GO_FLAGS = -v
REPO = $(shell pwd)
SOURCEDIR = $(REPO)/mk
BUILDDIR = $(REPO)/build
GOBUILDDIR = $(BUILDDIR)/gobuild
STAGEDIR = $(BUILDDIR)/stage
OBJECTDIR = $(BUILDDIR)/obj
DISTDIR = $(BUILDDIR)/dist
OBJECTS :=
OBJECTS += $(OBJECTDIR)/xe-daemon
OBJECTS += $(OBJECTDIR)/xenstore
PACKAGE = xe-guest-utilities
VERSION = $(PRODUCT_VERSION)
RELEASE := $(shell git rev-list HEAD | wc -l)
ARCH := $(shell go version|awk -F'/' '{print $$2}')
ifeq ($(ARCH), amd64)
ARCH = x86_64
endif
XE_DAEMON_SOURCES :=
XE_DAEMON_SOURCES += ./xe-daemon/xe-daemon.go
XE_DAEMON_SOURCES += ./syslog/syslog.go
XE_DAEMON_SOURCES += ./system/system.go
XE_DAEMON_SOURCES += ./guestmetric/guestmetric.go
XE_DAEMON_SOURCES += ./guestmetric/guestmetric_linux.go
XE_DAEMON_SOURCES += ./xenstoreclient/xenstore.go
XENSTORE_SOURCES :=
XENSTORE_SOURCES += ./xenstore/xenstore.go
XENSTORE_SOURCES += ./xenstoreclient/xenstore.go
.PHONY: build
build: $(DISTDIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_$(ARCH).tgz
.PHONY: clean
clean:
$(RM) -rf $(BUILDDIR)
$(DISTDIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_$(ARCH).tgz: $(OBJECTS)
( mkdir -p $(DISTDIR) ; \
install -d $(STAGEDIR)/etc/init.d/ ; \
install -m 755 $(SOURCEDIR)/xe-linux-distribution.init $(STAGEDIR)/etc/init.d/xe-linux-distribution ; \
install -d $(STAGEDIR)/usr/sbin/ ; \
install -m 755 $(SOURCEDIR)/xe-linux-distribution $(STAGEDIR)/usr/sbin/xe-linux-distribution ; \
install -m 755 $(OBJECTDIR)/xe-daemon $(STAGEDIR)/usr/sbin/xe-daemon ; \
install -d $(STAGEDIR)/usr/bin/ ; \
install -m 755 $(OBJECTDIR)/xenstore $(STAGEDIR)/usr/bin/xenstore ; \
ln -sf xenstore $(STAGEDIR)/usr/bin/xenstore-read ; \
ln -sf xenstore $(STAGEDIR)/usr/bin/xenstore-write ; \
ln -sf xenstore $(STAGEDIR)/usr/bin/xenstore-exists ; \
ln -sf xenstore $(STAGEDIR)/usr/bin/xenstore-rm ; \
ln -sf xenstore $(STAGEDIR)/usr/bin/xenstore-list ; \
install -d $(STAGEDIR)/etc/udev/rules.d/ ; \
install -m 644 $(SOURCEDIR)/xen-vcpu-hotplug.rules $(STAGEDIR)/etc/udev/rules.d/z10_xen-vcpu-hotplug.rules ; \
cd $(STAGEDIR) ; \
tar cf $@ * \
)
$(OBJECTDIR)/xe-daemon: $(XE_DAEMON_SOURCES:%=$(GOBUILDDIR)/%)
mkdir -p $(OBJECTDIR)
$(GO_BUILD) $(GO_FLAGS) -o $@ $<
$(OBJECTDIR)/xenstore: $(XENSTORE_SOURCES:%=$(GOBUILDDIR)/%) $(GOROOT)
mkdir -p $(OBJECTDIR)
$(GO_BUILD) $(GO_FLAGS) -o $@ $<
$(GOBUILDDIR)/%: $(REPO)/%
mkdir -p $$(dirname $@)
cat $< | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/$(PRODUCT_MAJOR_VERSION)/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/$(PRODUCT_MINOR_VERSION)/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/$(PRODUCT_MICRO_VERSION)/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/$(RELEASE)/g" \
> $@
|