diff --git a/.dockerignore b/.dockerignore index e21d69008ba9..0f2c34f66b20 100644 --- a/.dockerignore +++ b/.dockerignore @@ -38,7 +38,7 @@ coverage-all.html .idea/ *.plist -cilium/bash_autocomplete +*_bash_completion *.swo outgoing diff --git a/.gitignore b/.gitignore index 0622bd019a55..394b1d9d2e53 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ coverage-all.html .idea/ *.plist -cilium/bash_autocomplete +*_bash_completion *.swo outgoing diff --git a/Documentation/Makefile b/Documentation/Makefile index 25f879de95cf..5f4f893df73e 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.quiet .PHONY: default clean builder-image cmdref epub latex html run-server stop-server diff --git a/Makefile b/Makefile index 7953d0f70510..1e2a87d8e91a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include Makefile.defs SUBDIRS_CILIUM_CONTAINER := proxylib envoy plugins/cilium-cni bpf cilium daemon cilium-health bugtool @@ -5,9 +8,9 @@ ifdef LIBNETWORK_PLUGIN SUBDIRS_CILIUM_CONTAINER += plugins/cilium-docker endif SUBDIRS := $(SUBDIRS_CILIUM_CONTAINER) operator plugins tools hubble-proxy -GOFILES_EVAL := $(subst _$(ROOT_DIR)/,,$(shell $(CGO_DISABLED) $(GOLIST) $(GO) list -e ./...)) +GOFILES_EVAL := $(subst _$(ROOT_DIR)/,,$(shell $(GO_LIST) -e ./...)) GOFILES ?= $(GOFILES_EVAL) -TESTPKGS_EVAL := $(subst github.com/cilium/cilium/,,$(shell $(CGO_DISABLED) $(GOLIST) $(GO) list -e ./... | grep -v '/api/v1\|/vendor\|/contrib' | grep -v -P 'test(?!/helpers/logutils)')) +TESTPKGS_EVAL := $(subst github.com/cilium/cilium/,,$(shell $(GO_LIST) -e ./... | grep -v '/api/v1\|/vendor\|/contrib' | grep -v -P 'test(?!/helpers/logutils)')) TESTPKGS ?= $(TESTPKGS_EVAL) GOLANGVERSION := $(shell $(GO) version 2>/dev/null | grep -Eo '(go[0-9].[0-9])') GOLANG_SRCFILES := $(shell for pkg in $(subst github.com/cilium/cilium/,,$(GOFILES)); do find $$pkg -name *.go -print; done | grep -v vendor | sort | uniq) @@ -89,7 +92,7 @@ tests-privileged: # cilium-map-migrate is a dependency of some unit tests. $(QUIET) $(MAKE) $(SUBMAKEOPTS) -C bpf cilium-map-migrate $(QUIET)$(foreach pkg,$(PRIV_TEST_PKGS),\ - $(GO) test $(GOFLAGS) $(TEST_LDFLAGS) github.com/cilium/cilium/$(pkg) $(GOTEST_PRIV_OPTS) || exit 1;) + $(GO_TEST) $(TEST_LDFLAGS) github.com/cilium/cilium/$(pkg) $(GOTEST_PRIV_OPTS) || exit 1;) start-kvstores: ifeq ($(SKIP_KVSTORES),"false") @@ -151,7 +154,7 @@ endif # hence will trigger an error of too many arguments. As a workaround, we # have to process these packages in different subshells. for pkg in $(patsubst %,github.com/cilium/cilium/%,$(TESTPKGS)); do \ - $(_GO) test $(GOFLAGS) $(TEST_UNITTEST_LDFLAGS) $$pkg $(GOTEST_BASE) $(GOTEST_COVER_OPTS) || exit 1; \ + $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $$pkg $(GOTEST_BASE) $(GOTEST_COVER_OPTS) || exit 1; \ tail -n +2 coverage.out >> coverage-all-tmp.out; \ done $(MAKE) generate-cov @@ -160,14 +163,14 @@ endif bench: start-kvstores $(QUIET)$(foreach pkg,$(patsubst %,github.com/cilium/cilium/%,$(TESTPKGS)),\ - $(GO) test $(GOFLAGS) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) \ + $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) \ $(pkg) \ || exit 1;) $(MAKE) stop-kvstores bench-privileged: $(QUIET)$(foreach pkg,$(patsubst %,github.com/cilium/cilium/%,$(TESTPKGS)),\ - $(GO) test $(GOFLAGS) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) \ + $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) \ -tags=privileged_tests $(pkg) \ || exit 1;) @@ -365,7 +368,7 @@ gofmt: govet: @$(ECHO_CHECK) vetting all GOFILES... - $(QUIET) $(GOLIST) $(_GO) vet \ + $(QUIET) $(GO_VET) \ ./api/... \ ./bugtool/... \ ./cilium/... \ diff --git a/Makefile.defs b/Makefile.defs index 41ab42d518ac..181de58e115b 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + SHELL := /bin/bash .SHELLFLAGS := -eu -o pipefail -c @@ -14,16 +17,32 @@ LOCALSTATEDIR?=/var RUNDIR?=/var/run CONFDIR?=/etc -CGO_DISABLED = CGO_ENABLED=0 -GOLIST ?= GO111MODULE=off -ifeq ($(GO),) - GO = $(CGO_DISABLED) go - _GO = go +INSTALL = install + +# Container engine +export CONTAINER_ENGINE?=docker +CONTAINER_ENGINE_FULL=$(QUIET)$(CONTAINER_ENGINE) + +# Set DOCKER_IMAGE_TAG with "latest" by default +ifeq ($(DOCKER_IMAGE_TAG),) + DOCKER_IMAGE_TAG="latest" +endif + +ifeq ($(shell uname -m),aarch64) + ETCD_IMAGE=quay.io/coreos/etcd:v3.2.17-arm64 else - _GO = $(GO) + ETCD_IMAGE=quay.io/coreos/etcd:v3.2.17 endif -INSTALL = install +GO ?= go + +# go build/test/clean flags +# these are declared here so they are treated explicitly +# as non-immediate variables +GO_BUILD_FLAGS = +GO_TEST_FLAGS = +GO_CLEAN_FLAGS = +GO_BUILD_LDFLAGS = VERSION = $(shell cat $(dir $(lastword $(MAKEFILE_LIST)))/VERSION) VERSION_MAJOR = $(shell cat $(dir $(lastword $(MAKEFILE_LIST)))/VERSION | cut -d. -f1) @@ -33,8 +52,8 @@ ifneq ($(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/.git),) else GIT_VERSION = $(shell cat $(ROOT_DIR)/GIT_VERSION) endif -BUILD = $(VERSION) $(GIT_VERSION) $(shell $(GO) version) -GOLDFLAGS = -X "github.com/cilium/cilium/pkg/version.Version=$(BUILD)" +FULL_BUILD_VERSION = $(VERSION) $(GIT_VERSION) $(shell $(GO) version) +GO_BUILD_LDFLAGS += -X "github.com/cilium/cilium/pkg/version.Version=$(FULL_BUILD_VERSION)" ifeq ($(NOSTRIP),) # Note: these options will not remove annotations needed for stack @@ -42,23 +61,18 @@ ifeq ($(NOSTRIP),) # # -w: Omit the DWARF symbol table. # -s: Omit the symbol table and debug information. - GOLDFLAGS += -s -w + GO_BUILD_LDFLAGS += -s -w endif CILIUM_ENVOY_SHA=$(shell grep -o "FROM.*cilium/cilium-envoy:[0-9a-fA-F]*" $(ROOT_DIR)/Dockerfile | cut -d : -f 2) -GOLDFLAGS += -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=$(CILIUM_ENVOY_SHA)" +GO_BUILD_LDFLAGS += -X "github.com/cilium/cilium/pkg/envoy.RequiredEnvoyVersionSHA=$(CILIUM_ENVOY_SHA)" BPF_FILES_EVAL := $(shell git ls-files $(ROOT_DIR)/bpf/ | grep -v .gitignore | tr "\n" ' ') BPF_FILES ?= $(BPF_FILES_EVAL) BPF_SRCFILES := $(subst ../,,$(BPF_FILES)) CILIUM_DATAPATH_SHA=$(shell cat $(BPF_FILES) | sha1sum | awk '{print $$1}') -GOLDFLAGS += -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA=$(CILIUM_DATAPATH_SHA)" - -# Set DOCKER_IMAGE_TAG with "latest" by default -ifeq ($(DOCKER_IMAGE_TAG),) - DOCKER_IMAGE_TAG="latest" -endif +GO_BUILD_LDFLAGS += -X "github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA=$(CILIUM_DATAPATH_SHA)" # Set -mod=vendor if running >= go 1.13 or if GO111MODULE is set. # A go build is being executed with go modules if: @@ -66,37 +80,37 @@ endif # * The go command is invoked in a directory outside of the $GOPATH/src tree # and the environment variable GO111MODULE unset (or explicitly set to 'auto'). ifeq ($(GO111MODULE),on) - GOFLAGS ?= -mod=vendor - GOCLEAN ?= -mod=vendor + GO_BUILD_FLAGS += -mod=vendor + GO_TEST_FLAGS += -mod=vendor + GO_CLEAN_FLAGS += -mod=vendor endif + # Compile with '-mod=vendor' if go >= 1.13 GO_MAJOR_VERSION_GE_1 := $(shell expr `$(GO) version | grep -E 'go[0-9]{1}+' -o | sed 's/go//g'` \>= 1) ifeq ($(GO_MAJOR_VERSION_GE_1),1) GO_MINOR_VERSION_GE_13 := $(shell expr `$(GO) version | grep -E 'go[^ ]+' -o | sed 's/go1.//g'` \>= 13) ifeq ($(GO_MINOR_VERSION_GE_13),1) - GOFLAGS ?= -mod=vendor - GOCLEAN ?= -mod=vendor + GO_BUILD_FLAGS += -mod=vendor + GO_TEST_FLAGS += -mod=vendor + GO_CLEAN_FLAGS += -mod=vendor endif endif -GOBUILD = $(GOFLAGS) -ldflags '$(GOLDFLAGS)' $(EXTRA_GOBUILD_FLAGS) - -# Uncomment to enable race detection -#GOBUILD += -race - -# Uncomment to enable deadlock detection -#GOBUILD += -tags lockdebug +ifneq ($(RACE),) + GO_BUILD_FLAGS += -race + GO_TEST_FLAGS += -race +endif ifneq ($(LOCKDEBUG),) - GOBUILD += -tags lockdebug + GO_BUILD_FLAGS += -tags lockdebug endif -# Container engine -export CONTAINER_ENGINE?=docker -CONTAINER_ENGINE_FULL=$(QUIET)$(CONTAINER_ENGINE) +GO_BUILD_FLAGS += -ldflags '$(GO_BUILD_LDFLAGS) $(EXTRA_GO_BUILD_LDFLAGS)' $(EXTRA_GO_BUILD_FLAGS) -ifeq ($(shell uname -m),aarch64) - ETCD_IMAGE=quay.io/coreos/etcd:v3.2.17-arm64 -else - ETCD_IMAGE=quay.io/coreos/etcd:v3.2.17 -endif +GO_BUILD = CGO_ENABLED=0 $(GO) build $(GO_BUILD_FLAGS) +GO_BUILD_WITH_CGO = CGO_ENABLED=1 $(GO) build $(GO_BUILD_FLAGS) +GO_TEST = $(GO) test $(GO_TEST_FLAGS) +GO_CLEAN = $(GO) clean $(GO_TEST_FLAGS) +# TODO: remove `GO111MODULE=off` once Go 1.13 is deprecated by Go maintainers +GO_VET = GO111MODULE=off $(GO) vet +GO_LIST = GO111MODULE=off $(GO) list diff --git a/Makefile.quiet b/Makefile.quiet index e606d68a235c..1a78ba4ee8b8 100644 --- a/Makefile.quiet +++ b/Makefile.quiet @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + ifeq ($(ROOT_DIR),) ROOT_DIR ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) RELATIVE_DIR ?= $(shell echo $(realpath .) | sed "s;$(ROOT_DIR)[/]*;;") diff --git a/api/v1/Makefile b/api/v1/Makefile index 0c69aba61044..89affb67d97c 100644 --- a/api/v1/Makefile +++ b/api/v1/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + PROTOC ?= protoc HUBBLE_PROTO_SOURCES := \ diff --git a/bpf/Makefile b/bpf/Makefile index 1d57dd08e638..9cc943f7ae61 100644 --- a/bpf/Makefile +++ b/bpf/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs .PHONY: all subdirs check preprocess assembly install clean diff --git a/bpf/Makefile.bpf b/bpf/Makefile.bpf index 1412030b2b17..292d7e86c6f5 100644 --- a/bpf/Makefile.bpf +++ b/bpf/Makefile.bpf @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + FLAGS := -I$(ROOT_DIR)/bpf/include -I$(ROOT_DIR)/bpf -D__NR_CPUS__=$(shell nproc) -O2 -g CLANG_FLAGS := ${FLAGS} -target bpf -emit-llvm diff --git a/bpf/sockops/Makefile b/bpf/sockops/Makefile index 19d9ad40e404..4697445884bc 100644 --- a/bpf/sockops/Makefile +++ b/bpf/sockops/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs .PHONY: all assembly check preprocess clean diff --git a/bugtool/Makefile b/bugtool/Makefile index 9f5fcc72c859..91508f97f1ed 100644 --- a/bugtool/Makefile +++ b/bugtool/Makefile @@ -1,31 +1,22 @@ # Copyright 2017-2020 Authors of Cilium -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-License-Identifier: Apache-2.0 include ../Makefile.defs -TARGET=cilium-bugtool -SOURCES := $(shell find ../common . -name '*.go') -$(TARGET): $(SOURCES) - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +TARGET := cilium-bugtool + +.PHONY: all $(TARGET) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ + clean: @$(ECHO_CLEAN) -$(QUIET)rm -f .cilium-bugtool.config $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) diff --git a/cilium-dev.Dockerfile.dockerignore b/cilium-dev.Dockerfile.dockerignore index 76952e1e9143..266b9866147d 100644 --- a/cilium-dev.Dockerfile.dockerignore +++ b/cilium-dev.Dockerfile.dockerignore @@ -45,7 +45,7 @@ coverage-all.html .idea/ *.plist -cilium/bash_autocomplete +*_bash_completion *.swo outgoing diff --git a/cilium-docker-plugin.Dockerfile b/cilium-docker-plugin.Dockerfile index 4bd52ac76d8d..bfb9403a3149 100644 --- a/cilium-docker-plugin.Dockerfile +++ b/cilium-docker-plugin.Dockerfile @@ -3,8 +3,7 @@ LABEL maintainer="maintainer@cilium.io" ADD . /go/src/github.com/cilium/cilium WORKDIR /go/src/github.com/cilium/cilium/plugins/cilium-docker ARG LOCKDEBUG -ARG V -RUN make CGO_ENABLED=0 GOOS=linux LOCKDEBUG=$LOCKDEBUG PKG_BUILD=1 EXTRA_GOBUILD_FLAGS="-a -installsuffix cgo" +RUN make LOCKDEBUG=$LOCKDEBUG FROM scratch LABEL maintainer="maintainer@cilium.io" diff --git a/cilium-health/Makefile b/cilium-health/Makefile index 29287f617d05..b1ffd5dbedf7 100644 --- a/cilium-health/Makefile +++ b/cilium-health/Makefile @@ -1,31 +1,33 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -SUBDIRS = responder -TARGET = cilium-health +TARGET := cilium-health +SUBDIRS := responder -.PHONY: all $(SUBDIRS) install clean +.PHONY: all $(TARGET) $(SUBDIRS) clean install all: $(TARGET) $(SUBDIRS) -SOURCES := $(shell find ../api/v1/health ../pkg/health cmd . \ - \( -name '*.go' ! -name '*_test.go' $(foreach dir,$(SUBDIRS),! -path './$(dir)/*') \) ) -$(TARGET): $(SOURCES) +$(TARGET): @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) - -$(SUBDIRS): force - @ $(MAKE) $(SUBMAKEOPTS) -C $@ all + $(QUIET)$(GO_BUILD) -o $@ clean: @$(ECHO_CLEAN) $(QUIET)for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i clean; done -$(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i install; done $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR) + +$(SUBDIRS): force + @ $(MAKE) $(SUBMAKEOPTS) -C $@ all + .PHONY: force force :; diff --git a/cilium-health/responder/Makefile b/cilium-health/responder/Makefile index 050a883f5987..29c25ab5cf92 100644 --- a/cilium-health/responder/Makefile +++ b/cilium-health/responder/Makefile @@ -1,17 +1,22 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs -TARGET=cilium-health-responder -SOURCES := $(shell find ../../pkg/health/probe/responder . \( -name '*.go' ! -name '*_test.go' \)) -$(TARGET): $(SOURCES) - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +TARGET := cilium-health-responder + +.PHONY: all $(TARGET) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ + clean: @$(ECHO_CLEAN) -$(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) diff --git a/cilium-operator.Dockerfile b/cilium-operator.Dockerfile index ac5ae3acbbd5..d9e385270bcb 100644 --- a/cilium-operator.Dockerfile +++ b/cilium-operator.Dockerfile @@ -3,8 +3,7 @@ LABEL maintainer="maintainer@cilium.io" ADD . /go/src/github.com/cilium/cilium WORKDIR /go/src/github.com/cilium/cilium/operator ARG LOCKDEBUG -ARG V -RUN make CGO_ENABLED=0 GOOS=linux LOCKDEBUG=$LOCKDEBUG PKG_BUILD=1 EXTRA_GOBUILD_FLAGS="-a -installsuffix cgo -tags operator_aws,operator_azure" +RUN make LOCKDEBUG=$LOCKDEBUG EXTRA_GO_BUILD_FLAGS="-tags operator_aws,operator_azure" FROM docker.io/library/alpine:3.9.3 as certs RUN apk --update add ca-certificates diff --git a/cilium/.gitignore b/cilium/.gitignore index f3c6bfa6a3df..700f27eb0fdf 100644 --- a/cilium/.gitignore +++ b/cilium/.gitignore @@ -1,2 +1 @@ cilium -bash_autocomplete diff --git a/cilium/Makefile b/cilium/Makefile index 845a21a0a602..918a453b45fa 100644 --- a/cilium/Makefile +++ b/cilium/Makefile @@ -1,23 +1,26 @@ -include ../Makefile.quiet +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -TARGET=cilium -SOURCES := $(shell find ../api ../daemon ../common ../pkg cmd . \( -name '*.go' ! -name '*_test.go' \)) +TARGET := cilium -$(TARGET): $(SOURCES) - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +.PHONY: all $(TARGET) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ + clean: - @$(ECHO_CLEAN) $(notdir $(shell pwd)) + @$(ECHO_CLEAN) -$(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(CONFDIR)/bash_completion.d - ./$(TARGET) completion bash > bash_autocomplete - $(QUIET)$(INSTALL) -m 0644 -T bash_autocomplete $(DESTDIR)$(CONFDIR)/bash_completion.d/cilium + ./$(TARGET) completion bash > $(TARGET)_bash_completion + $(QUIET)$(INSTALL) -m 0644 -T $(TARGET)_bash_completion $(DESTDIR)$(CONFDIR)/bash_completion.d/$(TARGET) diff --git a/contrib/codegen/Makefile b/contrib/codegen/Makefile index cca0cc9eab19..a3b0a2059cbf 100644 --- a/contrib/codegen/Makefile +++ b/contrib/codegen/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + CFLAGS=-O2 -Wall all: hexgen diff --git a/contrib/packaging/deb/Makefile b/contrib/packaging/deb/Makefile index b0b5020f0a69..45e8c273a033 100644 --- a/contrib/packaging/deb/Makefile +++ b/contrib/packaging/deb/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../../Makefile.defs BUILDDIR := "$(CURDIR)/cilium-$(VERSION)" @@ -5,7 +8,6 @@ BASEDIR := "$(CURDIR)/../../../" BRANCH := $(shell git rev-parse --abbrev-ref HEAD) build: clean - mkdir -p output (cd $(BASEDIR) && git bundle create $(CURDIR)/version_$(VERSION) $(BRANCH) --tags) (cd $(CURDIR) && git clone $(CURDIR)/version_$(VERSION) cilium -b $(BRANCH)) diff --git a/contrib/packaging/rpm/Makefile b/contrib/packaging/rpm/Makefile index 7cae4143d816..cd9877de6888 100644 --- a/contrib/packaging/rpm/Makefile +++ b/contrib/packaging/rpm/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../../Makefile.defs VERSION := $(shell git tag -l --sort=-v:refname | sed 's/v\([^-].*\)/\1/g' | head -1) diff --git a/daemon/Makefile b/daemon/Makefile index 0fc23db04e35..f8e25cee18aa 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -1,22 +1,26 @@ -# GOBUILD relies on the order of makefile list to get VERSION file +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -TARGET=cilium-agent -LINKS=cilium-node-monitor -SOURCES := $(shell find ../api ../common ../daemon ../pkg . \( -name '*.go' ! -name '*_test.go' \)) -$(TARGET): $(SOURCES) ../Dockerfile ../Makefile ../Makefile.defs Makefile - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +TARGET := cilium-agent +LINKS := cilium-node-monitor all: $(TARGET) links +.PHONY: all $(TARGET) links + +$(TARGET): ../Dockerfile ../Makefile ../Makefile.defs Makefile + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $(TARGET) + links: $(foreach link,$(LINKS), ln -f -s $(TARGET) $(link) || cp $(TARGET) $(link);) clean: @$(ECHO_CLEAN) $(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) $(foreach link,$(LINKS), $(QUIET)rm -f $(link);) ifeq ("$(PKG_BUILD)","") diff --git a/examples/kubernetes/addons/prometheus/templates/Makefile b/examples/kubernetes/addons/prometheus/templates/Makefile index c3f243e219d1..e3e38343b5a9 100644 --- a/examples/kubernetes/addons/prometheus/templates/Makefile +++ b/examples/kubernetes/addons/prometheus/templates/Makefile @@ -1,5 +1,7 @@ -include ../../../../../Makefile.defs +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 +include ../../../../../Makefile.defs DESTINATION= "../monitoring-example.yaml" diff --git a/examples/kubernetes/connectivity-check/Makefile b/examples/kubernetes/connectivity-check/Makefile index a1f8ed28d2ee..48340af61f00 100644 --- a/examples/kubernetes/connectivity-check/Makefile +++ b/examples/kubernetes/connectivity-check/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + OUT := connectivity-check.yaml SRC := $(wildcard *.yaml) SRC := $(filter-out $(OUT), $(SRC)) diff --git a/hubble-proxy/.gitignore b/hubble-proxy/.gitignore index d32972278f53..f69665e491f2 100644 --- a/hubble-proxy/.gitignore +++ b/hubble-proxy/.gitignore @@ -1,2 +1 @@ hubble-proxy -bash_autocomplete diff --git a/hubble-proxy/Makefile b/hubble-proxy/Makefile index 4bfe6be7fd75..ae4d207d65af 100644 --- a/hubble-proxy/Makefile +++ b/hubble-proxy/Makefile @@ -1,27 +1,27 @@ -include ../Makefile.quiet +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -TARGET=hubble-proxy -SOURCES := $(shell find . ../pkg/hubble \( -name '*.go' ! -name '*_test.go' \)) +TARGET := hubble-proxy +.PHONY: all $(TARGET) clean install all: $(TARGET) -$(TARGET): $(SOURCES) +$(TARGET): @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) + $(QUIET)$(GO_BUILD) -o $@ strip $(TARGET) clean: - @$(ECHO_CLEAN) $(notdir $(shell pwd)) + @$(ECHO_CLEAN) -$(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(CONFDIR)/bash_completion.d - ./$(TARGET) completion bash > bash_autocomplete - $(QUIET)$(INSTALL) -m 0644 -T bash_autocomplete $(DESTDIR)$(CONFDIR)/bash_completion.d/hubble-proxy - -.PHONY: clean install + ./$(TARGET) completion bash > $(TARGET)_bash_completion + $(QUIET)$(INSTALL) -m 0644 -T $(TARGET)_bash_completion $(DESTDIR)$(CONFDIR)/bash_completion.d/$(TARGET) diff --git a/install/kubernetes/Makefile b/install/kubernetes/Makefile index 05ff959dc98b..79145e7f88ab 100644 --- a/install/kubernetes/Makefile +++ b/install/kubernetes/Makefile @@ -1,5 +1,7 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs -include $(ROOT_DIR)/Makefile.quiet MANAGED_ETCD_VERSION := "v2.0.7" diff --git a/operator/Makefile b/operator/Makefile index 61337e38180f..9e90093eaa08 100644 --- a/operator/Makefile +++ b/operator/Makefile @@ -1,20 +1,23 @@ -# GOBUILD relies on the order of makefile list to get VERSION file +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -TARGET=cilium-operator -SOURCES := $(shell find ../pkg . \( -name '*.go' ! -name '*_test.go' \)) -$(TARGET): $(SOURCES) - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +TARGET := cilium-operator + +.PHONY: all $(TARGET) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ + clean: @$(ECHO_CLEAN) - $(QUIET)rm -f $(TARGET) - $(GO) clean $(GOCLEAN) + -$(QUIET)rm -f $(TARGET) + $(QUIET)$(GO_CLEAN) install: - groupadd -f cilium $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR) diff --git a/plugins/Makefile b/plugins/Makefile index cddec89e158a..8ba50778e86e 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -1,11 +1,16 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -SUBDIRS = cilium-docker cilium-cni +SUBDIRS := cilium-docker cilium-cni + +.PHONY: all $(SUBDIRS) clean install all: $(SUBDIRS) $(SUBDIRS): force - @ $(MAKE) $(SUBMAKEOPTS) -C $@ all + @$(MAKE) $(SUBMAKEOPTS) -C $@ all clean: $(QUIET)for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i clean; done diff --git a/plugins/cilium-cni/Makefile b/plugins/cilium-cni/Makefile index 740c4631850e..c87217e635e7 100644 --- a/plugins/cilium-cni/Makefile +++ b/plugins/cilium-cni/Makefile @@ -1,20 +1,22 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs -all: cilium-cni +TARGET := cilium-cni + +.PHONY: all $(TARGET) clean install -TARGET=cilium-cni +all: $(TARGET) + +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ clean: @$(ECHO_CLEAN) - $(QUIET)$(GO) clean $(GOCLEAN) -$(QUIET)rm -f $(TARGET) - -SOURCES := $(shell find ../../api/v1/models ../../common ../../pkg/client ../../pkg/endpoint . -name '*.go') - -$(TARGET): $(SOURCES) - @$(ECHO_GO) - # Compile without cgo to allow use of cilium-cni on non-glibc platforms - see GH-5055 - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(CNICONFDIR) diff --git a/plugins/cilium-docker/Makefile b/plugins/cilium-docker/Makefile index 1da6f9526428..5d57847eb57e 100644 --- a/plugins/cilium-docker/Makefile +++ b/plugins/cilium-docker/Makefile @@ -1,22 +1,27 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs -TARGET=cilium-docker +TARGET := cilium-docker -all: $(TARGET) +.PHONY: all $(TARGET) clean install -SOURCES := $(shell find ../../api/v1 ../../common ../../pkg/client ../../pkg/endpoint driver . -name '*.go') +all: $(TARGET) -$(TARGET): $(SOURCES) +$(TARGET): @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) - -run: - ./cilium-docker -d + $(QUIET)$(GO_BUILD) -o $@ clean: @$(ECHO_CLEAN) - $(QUIET)$(GO) clean $(GOCLEAN) - -$(QUIET) rm -f $(TARGET) + -$(QUIET)rm -f $(TARGET) + $(QUIET)$(GO_CLEAN) install: + $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) $(QUIET)$(INSTALL) -m 0755 $(TARGET) $(DESTDIR)$(BINDIR) + +.PHONY: run +run: + ./cilium-docker -d diff --git a/proxylib/Makefile b/proxylib/Makefile index eee8678f1961..154060ee5266 100644 --- a/proxylib/Makefile +++ b/proxylib/Makefile @@ -1,22 +1,25 @@ -include ../Makefile.quiet +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -PROXYLIB_GOLDFLAGS=$(GOLDFLAGS) -extldflags -Wl,-soname,libcilium.so.$(VERSION_MAJOR) -PROXYLIB_GOBUILD=-ldflags '$(PROXYLIB_GOLDFLAGS)' +EXTRA_GO_BUILD_LDFLAGS = -extldflags -Wl,-soname,libcilium.so.$(VERSION_MAJOR) -TARGET=libcilium.so -DEPS := $(shell find ../pkg accesslog npds test . \( -name '*.go' ! -name '*_test.go' \)) -$(TARGET): $(DEPS) - @$(ECHO_GO) - $(QUIET)$(_GO) build $(GOBUILD) $(PROXYLIB_GOBUILD) -o $@.$(VERSION_MAJOR) -buildmode=c-shared - $(QUIET)ln -sf $@.$(VERSION_MAJOR) $@ || cp $@.$(VERSION_MAJOR) $@ +TARGET := libcilium.so + +.PHONY: all $(TARGET) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD_WITH_CGO) -o $@.$(VERSION_MAJOR) -buildmode=c-shared + $(QUIET)ln -sf $@.$(VERSION_MAJOR) $@ || cp $@.$(VERSION_MAJOR) $@ + clean: @$(ECHO_CLEAN) -$(QUIET)rm -f $(TARGET) - $(QUIET)$(_GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(LIBDIR) diff --git a/test/Makefile b/test/Makefile index d3d9423d9f00..aae5ae6e3800 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs provision = true diff --git a/test/bpf/Makefile b/test/bpf/Makefile index b92ff59d1aa7..e3f9bf00dd23 100644 --- a/test/bpf/Makefile +++ b/test/bpf/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs FLAGS := -I../../bpf/ -I../../bpf/include -I. -D__NR_CPUS__=$(shell nproc) -O2 diff --git a/test/startup-script/Makefile b/test/startup-script/Makefile index ac81e6eb1d2c..54061df1df60 100644 --- a/test/startup-script/Makefile +++ b/test/startup-script/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + TAG=v1 IMAGE=docker.io/cilium/startup-script diff --git a/tests/Makefile b/tests/Makefile index f50e9f49f224..1978f408c8e4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,7 @@ -include ../Makefile.defs +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 +include ../Makefile.defs runtime-tests: ./run-tests diff --git a/tests/k8s/Makefile b/tests/k8s/Makefile index 64aff3b5a46b..a29850146199 100644 --- a/tests/k8s/Makefile +++ b/tests/k8s/Makefile @@ -1,3 +1,6 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs k8s-multi-node-tests: diff --git a/tools/Makefile b/tools/Makefile index f7e31d383686..4e0e16cc6e5c 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,6 +1,11 @@ +# Copyright 2017-2019 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../Makefile.defs -SUBDIRS = alignchecker maptool +SUBDIRS := alignchecker maptool + +.PHONY: all $(SUBDIRS) clean install all: $(SUBDIRS) @@ -15,4 +20,3 @@ install: .PHONY: force force :; - diff --git a/tools/alignchecker/Makefile b/tools/alignchecker/Makefile index f5c30133836f..6e3a4c7a9cbe 100644 --- a/tools/alignchecker/Makefile +++ b/tools/alignchecker/Makefile @@ -1,17 +1,22 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs -TARGET=cilium-align-checker -SOURCES := $(shell find ../../pkg/bpf . \( -name '*.go' ! -name '*_test.go' \)) -$(TARGET): $(SOURCES) - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +TARGET := cilium-align-checker + +.PHONY: all $(TARGET) $(SUBDIRS) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ + clean: @$(ECHO_CLEAN) -$(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) diff --git a/tools/maptool/Makefile b/tools/maptool/Makefile index 481c37fc732c..ba177f5bdf77 100644 --- a/tools/maptool/Makefile +++ b/tools/maptool/Makefile @@ -1,17 +1,22 @@ +# Copyright 2017-2020 Authors of Cilium +# SPDX-License-Identifier: Apache-2.0 + include ../../Makefile.defs -TARGET=maptool -SOURCES := $(shell find ../../pkg/bpf . \( -name '*.go' ! -name '*_test.go' \)) -$(TARGET): $(SOURCES) - @$(ECHO_GO) - $(QUIET)$(GO) build $(GOBUILD) -o $(TARGET) +TARGET := maptool + +.PHONY: all $(TARGET) $(SUBDIRS) clean install all: $(TARGET) +$(TARGET): + @$(ECHO_GO) + $(QUIET)$(GO_BUILD) -o $@ + clean: @$(ECHO_CLEAN) -$(QUIET)rm -f $(TARGET) - $(QUIET)$(GO) clean $(GOCLEAN) + $(QUIET)$(GO_CLEAN) install: $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)