2013-03-26 01:48:46 +04:00
|
|
|
DOCKER_PACKAGE := github.com/dotcloud/docker
|
2013-04-24 05:32:59 +04:00
|
|
|
RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1)
|
|
|
|
SRCRELEASE := docker-$(RELEASE_VERSION)
|
|
|
|
BINRELEASE := docker-$(RELEASE_VERSION).tgz
|
2013-03-26 01:48:46 +04:00
|
|
|
|
2013-04-24 05:32:59 +04:00
|
|
|
GIT_ROOT := $(shell git rev-parse --show-toplevel)
|
2013-03-26 04:23:36 +04:00
|
|
|
BUILD_DIR := $(CURDIR)/.gopath
|
2013-03-26 01:48:46 +04:00
|
|
|
|
|
|
|
GOPATH ?= $(BUILD_DIR)
|
|
|
|
export GOPATH
|
|
|
|
|
2013-03-26 10:28:35 +04:00
|
|
|
GO_OPTIONS ?=
|
|
|
|
ifeq ($(VERBOSE), 1)
|
|
|
|
GO_OPTIONS += -v
|
|
|
|
endif
|
|
|
|
|
2013-04-02 18:38:08 +04:00
|
|
|
GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
|
|
|
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES")
|
|
|
|
|
2013-04-19 08:08:20 +04:00
|
|
|
BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS)"
|
2013-04-01 22:12:56 +04:00
|
|
|
|
2013-03-26 01:48:46 +04:00
|
|
|
SRC_DIR := $(GOPATH)/src
|
|
|
|
|
|
|
|
DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE)
|
|
|
|
DOCKER_MAIN := $(DOCKER_DIR)/docker
|
|
|
|
|
2013-03-26 18:30:01 +04:00
|
|
|
DOCKER_BIN_RELATIVE := bin/docker
|
|
|
|
DOCKER_BIN := $(CURDIR)/$(DOCKER_BIN_RELATIVE)
|
2013-03-26 01:48:46 +04:00
|
|
|
|
2013-04-24 06:41:38 +04:00
|
|
|
.PHONY: all clean test hack release srcrelease $(BINRELEASE) $(SRCRELEASE) $(DOCKER_BIN) $(DOCKER_DIR)
|
2013-03-26 01:48:46 +04:00
|
|
|
|
|
|
|
all: $(DOCKER_BIN)
|
|
|
|
|
|
|
|
$(DOCKER_BIN): $(DOCKER_DIR)
|
|
|
|
@mkdir -p $(dir $@)
|
2013-04-24 06:41:38 +04:00
|
|
|
@(cd $(DOCKER_MAIN); go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@)
|
2013-03-26 18:30:01 +04:00
|
|
|
@echo $(DOCKER_BIN_RELATIVE) is created.
|
2013-03-26 01:48:46 +04:00
|
|
|
|
|
|
|
$(DOCKER_DIR):
|
|
|
|
@mkdir -p $(dir $@)
|
2013-04-24 06:41:38 +04:00
|
|
|
@rm -f $@
|
2013-03-26 01:48:46 +04:00
|
|
|
@ln -sf $(CURDIR)/ $@
|
2013-04-24 06:41:38 +04:00
|
|
|
@(cd $(DOCKER_MAIN); go get $(GO_OPTIONS))
|
2013-03-26 01:48:46 +04:00
|
|
|
|
2013-04-24 05:32:59 +04:00
|
|
|
whichrelease:
|
|
|
|
echo $(RELEASE_VERSION)
|
|
|
|
|
|
|
|
release: $(BINRELEASE)
|
2013-04-24 06:41:38 +04:00
|
|
|
srcrelease: $(SRCRELEASE)
|
|
|
|
deps: $(DOCKER_DIR)
|
2013-04-24 05:32:59 +04:00
|
|
|
|
2013-04-24 06:41:38 +04:00
|
|
|
# A clean checkout of $RELEASE_VERSION, with vendored dependencies
|
2013-04-24 05:32:59 +04:00
|
|
|
$(SRCRELEASE):
|
|
|
|
rm -fr $(SRCRELEASE)
|
|
|
|
git clone $(GIT_ROOT) $(SRCRELEASE)
|
2013-04-24 05:50:53 +04:00
|
|
|
cd $(SRCRELEASE); git checkout -q $(RELEASE_VERSION)
|
2013-04-24 05:32:59 +04:00
|
|
|
|
|
|
|
# A binary release ready to be uploaded to a mirror
|
|
|
|
$(BINRELEASE): $(SRCRELEASE)
|
|
|
|
rm -f $(BINRELEASE)
|
|
|
|
cd $(SRCRELEASE); make; cp -R bin docker-$(RELEASE_VERSION); tar -f ../$(BINRELEASE) -zv -c docker-$(RELEASE_VERSION)
|
|
|
|
|
2013-03-26 01:48:46 +04:00
|
|
|
clean:
|
|
|
|
@rm -rf $(dir $(DOCKER_BIN))
|
|
|
|
ifeq ($(GOPATH), $(BUILD_DIR))
|
|
|
|
@rm -rf $(BUILD_DIR)
|
|
|
|
else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR)))
|
|
|
|
@rm -f $(DOCKER_DIR)
|
|
|
|
endif
|
2013-03-26 02:15:37 +04:00
|
|
|
|
|
|
|
test: all
|
2013-03-26 10:28:35 +04:00
|
|
|
@(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS))
|
2013-04-02 00:05:00 +04:00
|
|
|
|
|
|
|
fmt:
|
2013-04-02 01:50:25 +04:00
|
|
|
@gofmt -s -l -w .
|
2013-04-10 01:30:10 +04:00
|
|
|
|
|
|
|
hack:
|
2013-04-10 06:07:50 +04:00
|
|
|
cd $(CURDIR)/buildbot && vagrant up
|