From bf4b452642bf2c74ba0ea314a4d344a5b095b274 Mon Sep 17 00:00:00 2001 From: Michal Rostecki Date: Wed, 28 Dec 2016 12:59:14 +0100 Subject: [PATCH] [WIP] Introduce autotools cri-o requires several C libraries and provides options to use some of them or not. Autotools may help in managing C-based dependencies, generating CFLAGS, LIBS, LDFLAGS etc. Using autotools instead of environment variables may be also more intuitive for packaging cri-o in future. Signed-off-by: Michal Rostecki --- .gitignore | 18 ++++++++++++++ .travis.yml | 2 ++ Makefile => Makefile.am | 44 +++++++++++++++++++++------------- autogen.sh | 3 +++ configure.ac | 53 +++++++++++++++++++++++++++++++++++++++++ conmon/Makefile | 12 ---------- conmon/Makefile.am | 9 +++++++ 7 files changed, 113 insertions(+), 28 deletions(-) rename Makefile => Makefile.am (85%) create mode 100755 autogen.sh create mode 100644 configure.ac delete mode 100644 conmon/Makefile create mode 100644 conmon/Makefile.am diff --git a/.gitignore b/.gitignore index dabc6067..ace303ea 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,21 @@ vendor/src/github.com/kubernetes-incubator/cri-o ocid.conf *.orig *.rej + +# Autotools +Makefile +Makefile.in +/autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.h.in +/config.log +/config.status +/configure +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 diff --git a/.travis.yml b/.travis.yml index 811546a7..4bb21571 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ services: - docker install: + - ./autogen.sh + - ./configure --with-travis - make install.tools before_script: diff --git a/Makefile b/Makefile.am similarity index 85% rename from Makefile rename to Makefile.am index a84d11ab..1304c979 100644 --- a/Makefile +++ b/Makefile.am @@ -1,13 +1,13 @@ GO ?= go EPOCH_TEST_COMMIT ?= 78aae688e2932f0cfc2a23e28ad30b58c6b8577f -PROJECT := github.com/kubernetes-incubator/cri-o -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_LINK := ${CURDIR}/vendor/src/github.com/kubernetes-incubator/cri-o -OCID_LINK_DIR := ${CURDIR}/vendor/src/github.com/kubernetes-incubator -OCID_INSTANCE := ocid_dev -SYSTEM_GOPATH := ${GOPATH} +PROJECT = github.com/kubernetes-incubator/cri-o +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_LINK = ${CURDIR}/vendor/src/github.com/kubernetes-incubator/cri-o +OCID_LINK_DIR = ${CURDIR}/vendor/src/github.com/kubernetes-incubator +OCID_INSTANCE = ocid_dev +SYSTEM_GOPATH = ${GOPATH} PREFIX ?= ${DESTDIR}/usr BINDIR ?= ${PREFIX}/bin LIBEXECDIR ?= ${PREFIX}/libexec @@ -15,10 +15,22 @@ MANDIR ?= ${PREFIX}/share/man ETCDIR ?= ${DESTDIR}/etc ETCDIR_OCID ?= ${ETCDIR}/ocid GO_MD2MAN ?= $(shell which go-md2man) -export GOPATH := ${CURDIR}/vendor -BUILDTAGS := selinux seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) +export GOPATH = ${CURDIR}/vendor +BUILDTAGS = $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions +if USE_SELINUX +BUILDTAGS += selinux +endif + +if USE_SECCOMP +BUILDTAGS += seccomp +endif + +if USE_APPARMOR +BUILDTAGS += apparmor +endif + all: binaries ocid.conf docs default: help @@ -63,7 +75,7 @@ kpod: $(GO_SRC) | ${OCID_LINK} ocid.conf: ocid ./ocid --config="" config --default > ocid.conf -clean: +clean-local: rm -f ocid.conf rm -f ocic ocid rm -f kpod @@ -88,8 +100,8 @@ localintegration: binaries binaries: ocid ocic kpod conmon pause -MANPAGES_MD := $(wildcard docs/*.md) -MANPAGES := $(MANPAGES_MD:%.md=%) +MANPAGES_MD = $(wildcard docs/*.md) +MANPAGES = $(MANPAGES_MD:%.md=%) docs/%.1: docs/%.1.md @which go-md2man > /dev/null 2>/dev/null || (echo "ERROR: go-md2man not found. Consider 'make install.tools' target" && false) @@ -105,7 +117,7 @@ docs/%.8: docs/%.8.md docs: $(MANPAGES) -install: +install-exec-local: install -D -m 755 kpod $(BINDIR)/kpod install -D -m 755 ocid $(BINDIR)/ocid install -D -m 755 ocic $(BINDIR)/ocic @@ -125,7 +137,7 @@ install.completions: install.systemd: install -D -m 644 contrib/systemd/ocid.service $(PREFIX)/lib/systemd/system/ocid.service -uninstall: +uninstall-local: rm -f $(BINDIR)/{ocid,ocic} rm -f $(LIBEXECDIR)/ocid/{conmon,pause} for i in $(filter %.1,$(MANPAGES)); do \ @@ -142,7 +154,7 @@ uninstall: # 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) +if TRAVIS git-validation -q -run DCO,short-subject else git-validation -v -run DCO,short-subject -range $(EPOCH_TEST_COMMIT)..HEAD diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 00000000..a2b2b070 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +autoreconf --install --warnings=all --force diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..cc876c57 --- /dev/null +++ b/configure.ac @@ -0,0 +1,53 @@ +AC_INIT([cri-o], [0.1]) +AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) + +AC_PROG_CC +AC_CHECK_PROG([GO], [go], [go]) + +AC_ARG_WITH([travis], + [AS_HELP_STRING([--with-travis], + [support for Travis CI])], + [], + [with_travis=no]) +AM_CONDITIONAL([TRAVIS], [test "x$with_travis" != xno]) + +PKG_CHECK_MODULES([glib], [glib-2.0]) +PKG_CHECK_MODULES([devmapper], [devmapper]) +AC_CHECK_HEADERS([btrfs/ioctl.h], [], []) + +AC_ARG_WITH([selinux], + [AS_HELP_STRING([--with-selinux], + [enable SELinux support])], + [], + [with_selinux=yes]) +AM_CONDITIONAL([USE_SELINUX], [test "x$with_selinux" != xno]) + +AC_ARG_WITH([seccomp], + [AS_HELP_STRING([--with-seccomp], + [enable seccomp support])], + [], + [with_seccomp=yes]) +AS_CASE(["$with_seccomp"], + [yes], [PKG_CHECK_MODULES([libseccomp], [libseccomp])], + [no], [] + [PKG_CHECK_MODULES([libseccomp], [libseccomp], [have_seccomp=yes], [have_seccomp=no])]) +AM_CONDITIONAL([USE_SECCOMP], [test "x$with_seccomp" != xno -a "x$have_seccomp" != xno]) + +AC_ARG_WITH([apparmor], + [AS_HELP_STRING([--with-apparmor], + [enable apparmor support])], + [], + [with_apparmor=no]) +AS_CASE(["$with_apparmor"], + [yes], [PKG_CHECK_MODULES([libapparmor], [libapparmor])], + [no], [] + [PKG_CHECK_MODULES([libapparmor], [libapparmor], [have_apparmor=yes], [have_apparmor=no])]) +AM_CONDITIONAL([USE_APPARMOR], [test "x$with_apparmor" != xno -a "x$have_apparmor" != xno]) + +CFLAGS="$CFLAGS -Wall -Wextra $glib_CFLAGS" +LDFLAGS="$LDFLAGS" +LIBS="$LIBS $glib_LIBS" + +AC_CONFIG_FILES([Makefile conmon/Makefile]) + +AC_OUTPUT diff --git a/conmon/Makefile b/conmon/Makefile deleted file mode 100644 index c8c7c4a9..00000000 --- a/conmon/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -src = $(wildcard *.c) -obj = $(src:.c=.o) - -override LIBS += $(shell pkg-config --libs glib-2.0) -override CFLAGS += -Wall -Wextra $(shell pkg-config --cflags glib-2.0) - -conmon: $(obj) - $(CC) -o $@ $^ $(CFLAGS) $(LIBS) - -.PHONY: clean -clean: - rm -f $(obj) conmon diff --git a/conmon/Makefile.am b/conmon/Makefile.am new file mode 100644 index 00000000..9d54ba59 --- /dev/null +++ b/conmon/Makefile.am @@ -0,0 +1,9 @@ +src = $(wildcard *.c) +obj = $(src:.c=.o) + +conmon: $(obj) + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + +.PHONY: clean +clean-local: + rm -f $(obj) conmon