2016-10-21 12:19:40 +00:00
|
|
|
GO ?= go
|
|
|
|
EPOCH_TEST_COMMIT ?= 78aae688e2932f0cfc2a23e28ad30b58c6b8577f
|
2016-09-26 23:55:12 +00:00
|
|
|
PROJECT := github.com/kubernetes-incubator/cri-o
|
2016-09-20 10:23:34 +00:00
|
|
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
|
|
|
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
|
|
|
|
OCID_IMAGE := ocid_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
|
2016-09-26 23:55:12 +00:00
|
|
|
OCID_LINK := ${CURDIR}/vendor/src/github.com/kubernetes-incubator/cri-o
|
2016-09-20 10:23:34 +00:00
|
|
|
OCID_LINK_DIR := ${CURDIR}/vendor/src/github.com/kubernetes-incubator
|
|
|
|
OCID_INSTANCE := ocid_dev
|
2016-09-21 09:41:23 +00:00
|
|
|
SYSTEM_GOPATH := ${GOPATH}
|
2016-09-28 17:08:56 +00:00
|
|
|
PREFIX ?= ${DESTDIR}/usr
|
2016-10-21 12:19:40 +00:00
|
|
|
BINDIR ?= ${PREFIX}/bin
|
|
|
|
LIBEXECDIR ?= ${PREFIX}/libexec
|
|
|
|
MANDIR ?= ${PREFIX}/share/man
|
|
|
|
ETCDIR ?= ${PREFIX}/etc
|
2016-10-06 00:55:07 +00:00
|
|
|
GO_MD2MAN ?= $(shell which go-md2man)
|
2016-09-20 10:23:34 +00:00
|
|
|
export GOPATH := ${CURDIR}/vendor
|
2016-10-05 13:29:30 +00:00
|
|
|
BUILDTAGS := selinux
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2016-10-14 16:03:36 +00:00
|
|
|
all: binaries ocid.conf docs
|
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
default: help
|
|
|
|
|
|
|
|
help:
|
|
|
|
@echo "Usage: make <target>"
|
|
|
|
@echo
|
2016-09-19 18:36:57 +00:00
|
|
|
@echo " * 'binaries' - Build ocid, conmon and ocic"
|
2016-09-20 10:23:34 +00:00
|
|
|
@echo " * 'integration' - Execute integration tests"
|
2016-09-19 06:28:34 +00:00
|
|
|
@echo " * 'clean' - Clean artifacts"
|
|
|
|
@echo " * 'lint' - Execute the source code linter"
|
|
|
|
|
2016-09-21 10:04:13 +00:00
|
|
|
lint: ${OCID_LINK}
|
2016-09-28 18:53:29 +00:00
|
|
|
@which gometalinter > /dev/null 2>/dev/null || (echo "ERROR: gometalinter not found. Consider 'make install.tools' target" && false)
|
2016-09-19 06:28:34 +00:00
|
|
|
@echo "checking lint"
|
|
|
|
@./.tool/lint
|
2016-09-17 09:37:45 +00:00
|
|
|
|
2016-09-20 10:23:34 +00:00
|
|
|
${OCID_LINK}:
|
|
|
|
mkdir -p ${OCID_LINK_DIR}
|
|
|
|
ln -sfn ${CURDIR} ${OCID_LINK}
|
|
|
|
|
2016-09-17 09:37:45 +00:00
|
|
|
conmon:
|
|
|
|
make -C $@
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2016-10-02 08:36:39 +00:00
|
|
|
pause:
|
|
|
|
make -C $@
|
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
GO_SRC = $(shell find . -name \*.go)
|
2016-10-15 04:48:18 +00:00
|
|
|
ocid: $(GO_SRC) | ${OCID_LINK}
|
2016-10-21 12:19:40 +00:00
|
|
|
$(GO) build --tags "$(BUILDTAGS)" -o $@ ./cmd/server/
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2016-10-15 04:48:18 +00:00
|
|
|
ocic: $(GO_SRC) | ${OCID_LINK}
|
2016-10-21 12:19:40 +00:00
|
|
|
$(GO) build -o $@ ./cmd/client/
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2016-10-12 19:53:58 +00:00
|
|
|
ocid.conf: ocid
|
2016-10-21 12:19:40 +00:00
|
|
|
./ocid --config="" config --default > ocid.conf
|
2016-10-12 19:53:58 +00:00
|
|
|
|
2016-07-15 17:52:13 +00:00
|
|
|
clean:
|
2016-10-12 19:53:58 +00:00
|
|
|
rm -f ocid.conf
|
2016-07-15 17:52:13 +00:00
|
|
|
rm -f ocic ocid
|
2016-09-20 10:23:34 +00:00
|
|
|
rm -f ${OCID_LINK}
|
2016-10-18 09:16:07 +00:00
|
|
|
rm -f docs/*.5 docs/*.8
|
2016-09-28 18:33:53 +00:00
|
|
|
find . -name \*~ -delete
|
|
|
|
find . -name \#\* -delete
|
2016-10-14 16:03:36 +00:00
|
|
|
make -C conmon clean
|
|
|
|
make -C pause clean
|
2016-09-17 13:50:35 +00:00
|
|
|
|
2016-09-20 10:23:34 +00:00
|
|
|
ocidimage:
|
|
|
|
docker build -t ${OCID_IMAGE} .
|
|
|
|
|
|
|
|
dbuild: ocidimage
|
2016-10-21 12:19:40 +00:00
|
|
|
docker run --name=${OCID_INSTANCE} --privileged ${OCID_IMAGE} -v ${PWD}:/go/src/${PROJECT} --rm make binaries
|
2016-09-20 10:23:34 +00:00
|
|
|
|
|
|
|
integration: ocidimage
|
2016-09-27 08:51:35 +00:00
|
|
|
docker run -e TESTFLAGS -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${OCID_IMAGE} make localintegration
|
2016-09-20 10:23:34 +00:00
|
|
|
|
|
|
|
localintegration: binaries
|
2016-09-24 07:55:26 +00:00
|
|
|
./test/test_runner.sh ${TESTFLAGS}
|
2016-09-20 10:23:34 +00:00
|
|
|
|
2016-10-14 16:03:36 +00:00
|
|
|
binaries: ocid ocic conmon pause
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
MANPAGES_MD := $(wildcard docs/*.md)
|
|
|
|
MANPAGES := $(MANPAGES_MD:%.md=%)
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2016-10-09 17:36:43 +00:00
|
|
|
docs/%.8: docs/%.8.md
|
2016-09-28 21:55:35 +00:00
|
|
|
@which go-md2man > /dev/null 2>/dev/null || (echo "ERROR: go-md2man not found. Consider 'make install.tools' target" && false)
|
2016-09-28 18:33:53 +00:00
|
|
|
$(GO_MD2MAN) -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
|
|
|
|
2016-10-09 17:36:43 +00:00
|
|
|
docs/%.5: docs/%.5.md
|
2016-09-28 21:55:35 +00:00
|
|
|
@which go-md2man > /dev/null 2>/dev/null || (echo "ERROR: go-md2man not found. Consider 'make install.tools' target" && false)
|
2016-09-28 18:33:53 +00:00
|
|
|
$(GO_MD2MAN) -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
docs: $(MANPAGES)
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
install:
|
|
|
|
install -D -m 755 ocid $(BINDIR)/ocid
|
|
|
|
install -D -m 755 ocic $(BINDIR)/ocic
|
|
|
|
install -D -m 755 conmon/conmon $(LIBEXECDIR)/ocid/conmon
|
|
|
|
install -D -m 755 pause/pause $(LIBEXECDIR)/ocid/pause
|
|
|
|
install -d -m 755 $(MANDIR)/man{8,5}
|
|
|
|
install -m 644 $(filter %.8,$(MANPAGES)) -t $(MANDIR)/man8
|
|
|
|
install -m 644 $(filter %.5,$(MANPAGES)) -t $(MANDIR)/man5
|
|
|
|
install -D -m 644 ocid.conf $(ETCDIR)/ocid.conf
|
2016-09-28 17:08:56 +00:00
|
|
|
|
2016-10-15 04:51:39 +00:00
|
|
|
install.systemd:
|
2016-10-31 14:42:23 +00:00
|
|
|
install -D -m 644 contrib/systemd/ocid.service $(PREFIX)/lib/systemd/system
|
2016-10-15 04:51:39 +00:00
|
|
|
|
2016-09-28 17:08:56 +00:00
|
|
|
uninstall:
|
2016-10-21 12:19:40 +00:00
|
|
|
rm -f $(BINDIR)/{ocid,ocic}
|
|
|
|
rm -f $(LIBEXECDIR)/ocid/{conmon,pause}
|
|
|
|
for i in $(filter %.8,$(MANPAGES)); do \
|
|
|
|
rm -f $(MANDIR)/man8/$$(basename $${i}); \
|
2016-09-28 18:33:53 +00:00
|
|
|
done
|
2016-10-21 12:19:40 +00:00
|
|
|
for i in $(filter %.5,$(MANPAGES)); do \
|
|
|
|
rm -f $(MANDIR)/man5/$$(basename $${i}); \
|
2016-10-09 17:36:43 +00:00
|
|
|
done
|
2016-09-28 17:08:56 +00:00
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
.PHONY: .gitvalidation
|
|
|
|
# When this is running in travis, it will only check the travis commit range
|
|
|
|
.gitvalidation:
|
|
|
|
@which git-validation > /dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make install.tools' target" && false)
|
|
|
|
ifeq ($(TRAVIS),true)
|
2016-09-20 08:24:28 +00:00
|
|
|
git-validation -q -run DCO,short-subject
|
2016-09-19 06:28:34 +00:00
|
|
|
else
|
2016-09-20 08:24:28 +00:00
|
|
|
git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD
|
2016-09-19 06:28:34 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
.PHONY: install.tools
|
|
|
|
|
2016-09-28 21:55:35 +00:00
|
|
|
install.tools: .install.gitvalidation .install.gometalinter .install.md2man
|
2016-09-19 06:28:34 +00:00
|
|
|
|
|
|
|
.install.gitvalidation:
|
2016-09-21 09:41:23 +00:00
|
|
|
GOPATH=${SYSTEM_GOPATH} go get github.com/vbatts/git-validation
|
2016-09-19 06:28:34 +00:00
|
|
|
|
|
|
|
.install.gometalinter:
|
2016-09-21 09:41:23 +00:00
|
|
|
GOPATH=${SYSTEM_GOPATH} go get github.com/alecthomas/gometalinter
|
|
|
|
GOPATH=${SYSTEM_GOPATH} gometalinter --install
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2016-09-28 21:55:35 +00:00
|
|
|
.install.md2man:
|
|
|
|
GOPATH=${SYSTEM_GOPATH} go get github.com/cpuguy83/go-md2man
|
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
.PHONY: \
|
|
|
|
binaries \
|
2016-10-02 08:36:39 +00:00
|
|
|
clean \
|
2016-09-19 07:21:14 +00:00
|
|
|
conmon \
|
2016-09-28 18:33:53 +00:00
|
|
|
default \
|
|
|
|
docs \
|
|
|
|
help \
|
2016-09-28 17:08:56 +00:00
|
|
|
install \
|
2016-10-02 08:36:39 +00:00
|
|
|
lint \
|
|
|
|
pause \
|
2016-09-28 17:08:56 +00:00
|
|
|
uninstall
|