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))
|
|
|
|
OCID_INSTANCE := ocid_dev
|
2017-01-05 05:39:22 +00:00
|
|
|
PREFIX ?= ${DESTDIR}/usr/local
|
2016-10-21 12:19:40 +00:00
|
|
|
BINDIR ?= ${PREFIX}/bin
|
|
|
|
LIBEXECDIR ?= ${PREFIX}/libexec
|
|
|
|
MANDIR ?= ${PREFIX}/share/man
|
2016-10-31 17:38:03 +00:00
|
|
|
ETCDIR ?= ${DESTDIR}/etc
|
2016-11-23 09:41:48 +00:00
|
|
|
ETCDIR_OCID ?= ${ETCDIR}/ocid
|
2016-12-07 21:42:31 +00:00
|
|
|
BUILDTAGS := selinux seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh)
|
2016-12-02 15:15:15 +00:00
|
|
|
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
|
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
|
2017-01-17 19:57:35 +00:00
|
|
|
@echo " * 'install' - Install binaries to system locations"
|
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-12-14 11:31:24 +00:00
|
|
|
@echo " * 'gofmt' - Verify the source code gofmt"
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
.PHONY: check-gopath
|
|
|
|
|
|
|
|
check-gopath:
|
2017-01-17 19:57:35 +00:00
|
|
|
ifndef GOPATH
|
|
|
|
$(error GOPATH is not set)
|
|
|
|
endif
|
2017-01-19 19:23:29 +00:00
|
|
|
|
|
|
|
lint: check-gopath
|
2016-09-19 06:28:34 +00:00
|
|
|
@echo "checking lint"
|
|
|
|
@./.tool/lint
|
2016-09-17 09:37:45 +00:00
|
|
|
|
2016-12-14 11:31:24 +00:00
|
|
|
gofmt:
|
|
|
|
@./hack/verify-gofmt.sh
|
|
|
|
|
2016-09-17 09:37:45 +00:00
|
|
|
conmon:
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C $@
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2016-10-02 08:36:39 +00:00
|
|
|
pause:
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C $@
|
2016-10-02 08:36:39 +00:00
|
|
|
|
2016-12-16 23:34:51 +00:00
|
|
|
bin2img:
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C test/$@ BUILDTAGS="$(BUILDTAGS)"
|
2016-12-16 23:34:51 +00:00
|
|
|
|
2017-01-10 22:57:22 +00:00
|
|
|
copyimg:
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C test/$@ BUILDTAGS="$(BUILDTAGS)"
|
2017-01-10 22:57:22 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
checkseccomp: check-gopath
|
2017-01-31 16:57:19 +00:00
|
|
|
$(MAKE) -C test/$@
|
2017-01-19 17:10:47 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
ocid: check-gopath
|
2017-01-24 13:07:05 +00:00
|
|
|
$(GO) build -o $@ \
|
2017-01-17 19:57:35 +00:00
|
|
|
-tags "$(BUILDTAGS)" \
|
|
|
|
$(PROJECT)/cmd/ocid
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
ocic: check-gopath
|
2017-01-24 13:07:05 +00:00
|
|
|
$(GO) build -o $@ $(PROJECT)/cmd/ocic
|
2016-07-15 17:52:13 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
kpod: check-gopath
|
2017-01-24 13:07:05 +00:00
|
|
|
$(GO) build -o $@ $(PROJECT)/cmd/kpod
|
2016-11-30 20:14:49 +00:00
|
|
|
|
2016-10-12 19:53:58 +00:00
|
|
|
ocid.conf: ocid
|
2017-03-02 04:37:45 +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-12-02 15:15:15 +00:00
|
|
|
rm -f docs/*.1 docs/*.5 docs/*.8
|
2017-01-10 22:57:22 +00:00
|
|
|
rm -fr test/testdata/redis-image
|
2016-09-28 18:33:53 +00:00
|
|
|
find . -name \*~ -delete
|
|
|
|
find . -name \#\* -delete
|
2017-01-24 13:07:05 +00:00
|
|
|
rm -f ocic ocid kpod
|
2016-10-14 16:03:36 +00:00
|
|
|
make -C conmon clean
|
|
|
|
make -C pause clean
|
2016-12-16 23:34:51 +00:00
|
|
|
make -C test/bin2img clean
|
2017-01-10 22:57:22 +00:00
|
|
|
make -C test/copyimg clean
|
2017-01-19 17:10:47 +00:00
|
|
|
make -C test/checkseccomp 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
|
|
|
|
2017-01-19 17:10:47 +00:00
|
|
|
binaries: ocid ocic kpod conmon pause bin2img copyimg checkseccomp
|
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
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
docs/%.1: docs/%.1.md check-gopath
|
2017-03-24 18:18:37 +00:00
|
|
|
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
docs/%.5: docs/%.5.md check-gopath
|
2017-03-24 18:18:37 +00:00
|
|
|
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
docs/%.8: docs/%.8.md check-gopath
|
2017-03-24 18:18:37 +00:00
|
|
|
$(GOPATH)/bin/go-md2man -in $< -out $@.tmp && touch $@.tmp && mv $@.tmp $@
|
2016-12-02 15:15:15 +00:00
|
|
|
|
2016-10-21 12:19:40 +00:00
|
|
|
docs: $(MANPAGES)
|
2016-09-28 18:33:53 +00:00
|
|
|
|
2017-01-19 19:23:29 +00:00
|
|
|
install: check-gopath
|
2017-01-24 13:07:05 +00:00
|
|
|
install -D -m 755 ocid $(BINDIR)/ocid
|
|
|
|
install -D -m 755 ocic $(BINDIR)/ocic
|
|
|
|
install -D -m 755 kpod $(BINDIR)/kpod
|
2016-10-21 12:19:40 +00:00
|
|
|
install -D -m 755 conmon/conmon $(LIBEXECDIR)/ocid/conmon
|
|
|
|
install -D -m 755 pause/pause $(LIBEXECDIR)/ocid/pause
|
2017-01-16 23:01:49 +00:00
|
|
|
install -d -m 755 $(MANDIR)/man1
|
|
|
|
install -d -m 755 $(MANDIR)/man5
|
|
|
|
install -d -m 755 $(MANDIR)/man8
|
2016-12-02 15:15:15 +00:00
|
|
|
install -m 644 $(filter %.1,$(MANPAGES)) -t $(MANDIR)/man1
|
2016-10-21 12:19:40 +00:00
|
|
|
install -m 644 $(filter %.5,$(MANPAGES)) -t $(MANDIR)/man5
|
2016-12-02 15:15:15 +00:00
|
|
|
install -m 644 $(filter %.8,$(MANPAGES)) -t $(MANDIR)/man8
|
2017-01-05 05:39:22 +00:00
|
|
|
|
|
|
|
install.config:
|
2016-11-23 09:41:48 +00:00
|
|
|
install -D -m 644 ocid.conf $(ETCDIR_OCID)/ocid.conf
|
|
|
|
install -D -m 644 seccomp.json $(ETCDIR_OCID)/seccomp.json
|
2016-09-28 17:08:56 +00:00
|
|
|
|
2016-12-02 15:15:15 +00:00
|
|
|
install.completions:
|
|
|
|
install -d -m 755 ${BASHINSTALLDIR}
|
|
|
|
install -m 644 -D completions/bash/kpod ${BASHINSTALLDIR}
|
|
|
|
|
2016-10-15 04:51:39 +00:00
|
|
|
install.systemd:
|
2016-10-31 17:38:03 +00:00
|
|
|
install -D -m 644 contrib/systemd/ocid.service $(PREFIX)/lib/systemd/system/ocid.service
|
2016-10-15 04:51:39 +00:00
|
|
|
|
2016-09-28 17:08:56 +00:00
|
|
|
uninstall:
|
2017-01-17 19:57:35 +00:00
|
|
|
rm -f $(BINDIR)/ocid
|
|
|
|
rm -f $(BINDIR)/ocic
|
|
|
|
rm -f $(LIBEXECDIR)/ocid/conmon
|
|
|
|
rm -f $(LIBEXECDIR)/ocid/pause
|
2016-12-02 15:15:15 +00:00
|
|
|
for i in $(filter %.1,$(MANPAGES)); do \
|
2016-10-21 12:19:40 +00:00
|
|
|
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-12-02 15:15:15 +00:00
|
|
|
for i in $(filter %.8,$(MANPAGES)); do \
|
|
|
|
rm -f $(MANDIR)/man8/$$(basename $${i}); \
|
|
|
|
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
|
2017-01-19 19:23:29 +00:00
|
|
|
.gitvalidation: check-gopath
|
2016-09-19 06:28:34 +00:00
|
|
|
ifeq ($(TRAVIS),true)
|
2017-01-19 16:47:29 +00:00
|
|
|
git-validation -q -run DCO,short-subject
|
2016-09-19 06:28:34 +00:00
|
|
|
else
|
2017-01-19 16:47:29 +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
|
|
|
|
2017-03-24 18:18:37 +00:00
|
|
|
.install.gitvalidation: check-gopath
|
2017-01-17 19:57:35 +00:00
|
|
|
go get -u github.com/vbatts/git-validation
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2017-03-24 18:18:37 +00:00
|
|
|
.install.gometalinter: check-gopath
|
2017-01-17 19:57:35 +00:00
|
|
|
go get -u github.com/alecthomas/gometalinter
|
2017-03-24 18:18:37 +00:00
|
|
|
$(GOPATH)/bin/gometalinter --install
|
2016-09-19 06:28:34 +00:00
|
|
|
|
2017-03-24 18:18:37 +00:00
|
|
|
.install.md2man: check-gopath
|
2017-01-17 19:57:35 +00:00
|
|
|
go get -u github.com/cpuguy83/go-md2man
|
2016-09-28 21:55:35 +00:00
|
|
|
|
2016-09-19 06:28:34 +00:00
|
|
|
.PHONY: \
|
2016-12-16 23:34:51 +00:00
|
|
|
bin2img \
|
2016-09-19 06:28:34 +00:00
|
|
|
binaries \
|
2017-01-19 17:10:47 +00:00
|
|
|
checkseccomp \
|
2016-10-02 08:36:39 +00:00
|
|
|
clean \
|
2016-09-19 07:21:14 +00:00
|
|
|
conmon \
|
2017-01-10 22:57:22 +00:00
|
|
|
copyimg \
|
2016-09-28 18:33:53 +00:00
|
|
|
default \
|
|
|
|
docs \
|
2016-12-14 11:31:24 +00:00
|
|
|
gofmt \
|
2016-09-28 18:33:53 +00:00
|
|
|
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
|