summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile68
1 files changed, 51 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index d5eeb5c..fa2563e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,36 +1,70 @@
+PRODUCT_VERSION = 6.6.80
+
GO_BUILD = go build
GO_FLAGS = -a -x
-SRC_DIR = .
-BIN_DIR = bin
+REPO = $(shell pwd)
+SOURCEDIR = $(REPO)/mk
+BUILDDIR = $(REPO)/build
+STAGEDIR = $(BUILDDIR)/stage
+OBJECTDIR = $(BUILDDIR)/obj
+DISTDIR = $(BUILDDIR)/dist
+
+OBJECTS :=
+OBJECTS += $(OBJECTDIR)/xe-daemon
+OBJECTS += $(OBJECTDIR)/xenstore
-BINARIES :=
-BINARIES += $(BIN_DIR)/xe-daemon
-BINARIES += $(BIN_DIR)/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 += $(SRC_DIR)/xe-daemon/xe-daemon.go
-XE_DAEMON_SOURCES += $(SRC_DIR)/guestmetric/guestmetric.go
-XE_DAEMON_SOURCES += $(SRC_DIR)/guestmetric/guestmetric_linux.go
-XE_DAEMON_SOURCES += $(SRC_DIR)/xenstoreclient/xenstore.go
+XE_DAEMON_SOURCES += $(REPO)/xe-daemon/xe-daemon.go
+XE_DAEMON_SOURCES += $(REPO)/guestmetric/guestmetric.go
+XE_DAEMON_SOURCES += $(REPO)/guestmetric/guestmetric_linux.go
+XE_DAEMON_SOURCES += $(REPO)/xenstoreclient/xenstore.go
XENSTORE_SOURCES :=
-XENSTORE_SOURCES += $(SRC_DIR)/xenstore/xenstore.go
-XENSTORE_SOURCES += $(SRC_DIR)/xenstoreclient/xenstore.go
+XENSTORE_SOURCES += $(REPO)/xenstore/xenstore.go
+XENSTORE_SOURCES += $(REPO)/xenstoreclient/xenstore.go
.PHONY: build
-build: $(BINARIES)
+build: $(DISTDIR)/$(PACKAGE)_$(VERSION)-$(RELEASE)_$(ARCH).tgz
.PHONY: clean
clean:
- -rm -f $(BINARIES)
+ $(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 -s /usr/bin/xenstore $(STAGEDIR)/usr/bin/xenstore-read ; \
+ ln -s /usr/bin/xenstore $(STAGEDIR)/usr/bin/xenstore-write ; \
+ ln -s /usr/bin/xenstore $(STAGEDIR)/usr/bin/xenstore-exists ; \
+ ln -s /usr/bin/xenstore $(STAGEDIR)/usr/bin/xenstore-rm ; \
+ 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 $@ * \
+ )
-$(BIN_DIR)/xe-daemon: $(XE_DAEMON_SOURCES)
- mkdir -p $(BIN_DIR)
+$(OBJECTDIR)/xe-daemon: $(XE_DAEMON_SOURCES)
+ mkdir -p $(OBJECTDIR)
$(GO_BUILD) $(GO_FLAGS) -o $@ $<
-$(BIN_DIR)/xenstore: $(XENSTORE_SOURCES)
- mkdir -p $(BIN_DIR)
+$(OBJECTDIR)/xenstore: $(XENSTORE_SOURCES)
+ mkdir -p $(OBJECTDIR)
$(GO_BUILD) $(GO_FLAGS) -o $@ $<