Skip to content

Commit

Permalink
Makefiles: Quieten output
Browse files Browse the repository at this point in the history
Quieten a bunch of targets and only print out the operation performed.
To use this, define V=0 in your environment or run:
    $ make V=0

This is implemented through a new makefile, Makefile.quiet. This keeps
the variables relevant to quiet output separate from other functional
changes in Makefile.defs.

Signed-off-by: Joe Stringer <joe@covalent.io>
  • Loading branch information
joestringer authored and tgraf committed Mar 17, 2018
1 parent 5350b72 commit f50ae69
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 68 deletions.
25 changes: 16 additions & 9 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Minimal makefile for Sphinx documentation
#
include ../Makefile.quiet

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXBUILD = $(QUIET) sphinx-build
SPHINXPROJ = Cilium
SOURCEDIR = .
BUILDDIR = _build
Expand All @@ -21,6 +22,7 @@ PIP_REQUIREMENTS = $(shell cat requirements.txt | sed -e 's/==.*//g' -e 's/\n/ /

check-requirements:
@set -e; \
$(ECHO_CHECK) documentation dependencies...; \
PYPKGS=$$(pip freeze); \
for pkg in ${PIP_REQUIREMENTS}; do \
echo $${PYPKGS} | grep -q $${pkg} \
Expand All @@ -30,16 +32,21 @@ check-requirements:
done

cmdref:
# We don't know what changed so recreate the directory
-rm -rvf $(CMDREFDIR)/cilium*
${CILIUMDIR}/cilium cmdref -d $(CMDREFDIR)
${BUGTOOLDIR}/cilium-bugtool cmdref -d $(CMDREFDIR)
${AGENTDIR}/cilium-agent --cmdref $(CMDREFDIR)
${HEALTHDIR}/cilium-health --cmdref $(CMDREFDIR)
$(QUIET) # We don't know what changed so recreate the directory
$(QUIET) -rm -rvf $(CMDREFDIR)/cilium*
@$(ECHO_GEN)cmdref/cilium
$(QUIET) ${CILIUMDIR}/cilium cmdref -d $(CMDREFDIR)
@$(ECHO_GEN)cmdref/cilium-bugtool
$(QUIET) ${BUGTOOLDIR}/cilium-bugtool cmdref -d $(CMDREFDIR)
@$(ECHO_GEN)cmdref/cilium-agent
$(QUIET) ${AGENTDIR}/cilium-agent --cmdref $(CMDREFDIR)
@$(ECHO_GEN)cmdref/cilium-health
$(QUIET) ${HEALTHDIR}/cilium-health --cmdref $(CMDREFDIR)

.PHONY: help Makefile check-requirements cmdref
.PHONY: help Makefile ../Makefile.quiet check-requirements cmdref

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile check-requirements
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(ECHO_GEN)_build/$@
$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
46 changes: 26 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tests-ginkgo-real:
go test $(TEST_LDFLAGS) \
-timeout 360s -coverprofile=coverage.out -covermode=count $(pkg) $(GOTEST_OPTS) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o=coverage-all.html
$(GO) tool cover -html=coverage-all.out -o=coverage-all.html
rm coverage-all.out
rm coverage.out
@rmdir ./daemon/1 ./daemon/1_backup 2> /dev/null || true
Expand Down Expand Up @@ -74,21 +74,22 @@ tests: force
$(MAKE) unit-tests tests-envoy

unit-tests: start-kvstores
echo "mode: count" > coverage-all.out
echo "mode: count" > coverage.out
$(QUIET) echo "mode: count" > coverage-all.out
$(QUIET) echo "mode: count" > coverage.out
$(foreach pkg,$(TESTPKGS),\
go test \
$(QUIET) go test \
-timeout 360s -coverprofile=coverage.out -covermode=count $(pkg) $(GOTEST_OPTS) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
go tool cover -html=coverage-all.out -o=coverage-all.html
rm coverage-all.out
rm coverage.out
$(GO) tool cover -html=coverage-all.out -o=coverage-all.html
$(QUIET) rm coverage-all.out
$(QUIET) rm coverage.out
@rmdir ./daemon/1 ./daemon/1_backup 2> /dev/null || true
docker rm -f "cilium-etcd-test-container"
docker rm -f "cilium-consul-test-container"
$(QUIET) docker rm -f "cilium-etcd-test-container"
$(QUIET) docker rm -f "cilium-consul-test-container"

clean-tags:
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files tags
@$(ECHO_CLEAN) tags
@-rm -f cscope.out cscope.in.out cscope.po.out cscope.files tags

tags: $(GOLANG_SRCFILES) $(BPF_SRCFILES)
ctags $(GOLANG_SRCFILES) $(BPF_SRCFILES)
Expand Down Expand Up @@ -202,9 +203,12 @@ gofmt:
for pkg in $(GOFILES); do go fmt $$pkg; done

precheck:
contrib/scripts/check-fmt.sh
contrib/scripts/check-log-newlines.sh
@go vet $(GOFILES)
@$(ECHO_CHECK) contrib/scripts/check-fmt.sh
$(QUIET) contrib/scripts/check-fmt.sh
@$(ECHO_CHECK) contrib/scripts/check-log-newlines.sh
$(QUIET) contrib/scripts/check-log-newlines.sh
@$(ECHO_CHECK) vetting all GOFILES...
$(QUIET)go vet $(GOFILES)

pprof-help:
@echo "Available pprof targets:"
Expand All @@ -215,20 +219,20 @@ pprof-help:
@echo " pprof-mutex"

pprof-heap:
go tool pprof http://localhost:6060/debug/pprof/heap
$(GO) tool pprof http://localhost:6060/debug/pprof/heap

pprof-profile:
go tool pprof http://localhost:6060/debug/pprof/profile
$(GO) tool pprof http://localhost:6060/debug/pprof/profile


pprof-block:
go tool pprof http://localhost:6060/debug/pprof/block
$(GO) tool pprof http://localhost:6060/debug/pprof/block

pprof-trace-5s:
curl http://localhost:6060/debug/pprof/trace?seconds=5

pprof-mutex:
go tool pprof http://localhost:6060/debug/pprof/mutex
$(GO) tool pprof http://localhost:6060/debug/pprof/mutex

update-authors:
@echo "Updating AUTHORS file..."
Expand Down Expand Up @@ -259,9 +263,11 @@ install-manpages:
mandb

postcheck: build
MAKE=$(MAKE) contrib/scripts/check-cmdref.sh
contrib/scripts/lock-check.sh
-$(MAKE) -C Documentation/ dummy SPHINXOPTS="-q" 2>&1 | grep -v "tabs assets"
@$(ECHO_CHECK) contrib/scripts/check-cmdref.sh
$(QUIET) MAKE=$(MAKE) contrib/scripts/check-cmdref.sh
@$(ECHO_CHECK) contrib/scripts/lock-check.sh
$(QUIET) contrib/scripts/lock-check.sh
-$(QUIET) $(MAKE) -C Documentation/ dummy SPHINXOPTS="-q" 2>&1 | grep -v "tabs assets"

.PHONY: force
force :;
9 changes: 6 additions & 3 deletions Makefile.defs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include $(ROOT_DIR)/Makefile.quiet

PREFIX?=/usr
BINDIR?=$(PREFIX)/bin
RUNDIR?=/var/run
CONFDIR?=/etc

GO = go
INSTALL = install
GO = $(QUIET)go
INSTALL = $(QUIET)install

VERSION = $(shell cat $(dir $(lastword $(MAKEFILE_LIST)))/VERSION)
# Use git only if in a Git repo
ifneq ($(wildcard $(dir $(lastword $(MAKEFILE_LIST)))/.git),)
GIT_VERSION = $(shell git show -s --format='format:%h %aI')
else
GIT_VERSION = $(shell cat $(dir $(lastword $(MAKEFILE_LIST)))/GIT_VERSION)
GIT_VERSION = $(shell cat $(ROOT_DIR)/GIT_VERSION)
endif
BUILD = $(VERSION) $(GIT_VERSION) $(shell go version)
GOBUILD = -ldflags '-X "github.com/cilium/cilium/pkg/version.Version=$(BUILD)"'
Expand Down
20 changes: 20 additions & 0 deletions Makefile.quiet
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ifeq ($(V),0)
QUIET=@
ECHO_CC=echo " CC $(notdir $(shell pwd))/$@"
ECHO_GEN=echo " GEN $(notdir $(shell pwd))/"
ECHO_GO=echo " GO $(notdir $(shell pwd))/$@"
ECHO_CHECK=echo " CHECK"
ECHO_BAZEL=echo " BAZEL $(notdir $(shell pwd))/$(notdir $(shell dirname $(ENVOY_BIN)))/$@"
ECHO_GINKGO=echo " GINKG $(notdir $(shell pwd))"
ECHO_CLEAN=echo " CLEAN"
else
# The whitespace at below EOLs is required for verbose case!
ECHO_CC=:
ECHO_GEN=:
ECHO_GO=:
ECHO_CHECK=:
ECHO_BAZEL=:
ECHO_GINKGO=:
ECHO_CLEAN=:
endif

29 changes: 18 additions & 11 deletions bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ ifeq ("$(PKG_BUILD)","")
all: $(BPF)

%.o: %.c $(LIB)
${CLANG} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@)
${LLC} ${LLC_FLAGS} -o $@ $(patsubst %.o,%.ll,$@)
@$(ECHO_CC)
$(QUIET) ${CLANG} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@)
$(QUIET) ${LLC} ${LLC_FLAGS} -o $@ $(patsubst %.o,%.ll,$@)

check:
sparse -Wsparse-all ${FLAGS} *.c
clang ${CLANG_FLAGS} --analyze *.c
@$(ECHO_CHECK) bpf/*.c
$(QUIET) sparse -Wsparse-all ${FLAGS} *.c
$(QUIET) $(CLANG) ${CLANG_FLAGS} --analyze *.c

LB_OPTIONS = \
-DSKIP_DEBUG \
Expand All @@ -34,12 +36,14 @@ LB_OPTIONS = \
-DLB_L3 -DLB_L4

bpf_lb.o: bpf_lb.c $(LIB)
set -e; \
$(QUIET) set -e; \
$(foreach OPTS,$(LB_OPTIONS), \
$(ECHO_CC) " [$(OPTS)]"; \
${CLANG} ${OPTS} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@); \
${LLC} ${LLC_FLAGS} -o /dev/null $(patsubst %.o,%.ll,$@); )
${CLANG} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@)
${LLC} ${LLC_FLAGS} -o $@ $(patsubst %.o,%.ll,$@)
@$(ECHO_CC)
$(QUIET) ${CLANG} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@)
$(QUIET) ${LLC} ${LLC_FLAGS} -o $@ $(patsubst %.o,%.ll,$@)

LXC_OPTIONS = \
-DSKIP_DEBUG \
Expand All @@ -49,12 +53,14 @@ LXC_OPTIONS = \
# FIXME: GH-2906: Test with both HAVE_LPM_MAP_TYPE and SKIP_CIDR_PREFIXES

bpf_lxc.o: bpf_lxc.c $(LIB)
set -e; \
$(QUIET) set -e; \
$(foreach OPTS,$(LXC_OPTIONS), \
$(ECHO_CC) " [$(OPTS)]"; \
${CLANG} ${OPTS} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@); \
${LLC} ${LLC_FLAGS} -o /dev/null $(patsubst %.o,%.ll,$@); )
${CLANG} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@)
${LLC} ${LLC_FLAGS} -o $@ $(patsubst %.o,%.ll,$@)
@$(ECHO_CC)
$(QUIET) ${CLANG} ${CLANG_FLAGS} -c $< -o $(patsubst %.o,%.ll,$@)
$(QUIET) ${LLC} ${LLC_FLAGS} -o $@ $(patsubst %.o,%.ll,$@)

else

Expand All @@ -65,4 +71,5 @@ endif
install:

clean:
rm -fr *.o
@$(ECHO_CLEAN) $(notdir $(shell pwd))
$(QUIET)rm -fr *.o
5 changes: 3 additions & 2 deletions bugtool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ include ../Makefile.defs
TARGET=cilium-bugtool
SOURCES := $(shell find ../common . -name '*.go')
$(TARGET): $(SOURCES)
@$(ECHO_GO)
$(GO) build -i $(GOBUILD) -o $(TARGET)

all: $(TARGET)

clean:
-rm .cilium-bugtool.config
rm -f $(TARGET)
@$(ECHO_CLEAN) $(notdir $(shell pwd))
-$(QUIET)rm -f .cilium-bugtool.config $(TARGET)
$(GO) clean

install:
Expand Down
4 changes: 3 additions & 1 deletion cilium-health/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ include ../Makefile.defs
TARGET=cilium-health
SOURCES := $(shell find ../api/v1/health ../pkg/health cmd . \( -name '*.go' ! -name '*_test.go' \))
$(TARGET): $(SOURCES)
@$(ECHO_GO)
$(GO) build -i $(GOBUILD) -o $(TARGET)

all: $(TARGET)

clean:
rm -f $(TARGET)
@$(ECHO_CLEAN) $(notdir $(shell pwd))
-$(QUIET)rm -f $(TARGET)
$(GO) clean

install:
Expand Down
5 changes: 4 additions & 1 deletion cilium/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
include ../Makefile.quiet
include ../Makefile.defs

TARGET=cilium
SOURCES := $(shell find ../api ../daemon ../common ../pkg cmd . \( -name '*.go' ! -name '*_test.go' \))
$(TARGET): $(SOURCES)
@$(ECHO_GO)
$(GO) build -i $(GOBUILD) -o $(TARGET)

all: $(TARGET)

clean:
rm -f $(TARGET)
@$(ECHO_CLEAN) $(notdir $(shell pwd))
-$(QUIET)rm -f $(TARGET)
$(GO) clean

install:
Expand Down
3 changes: 2 additions & 1 deletion contrib/packaging/deb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ build: clean
docker run --rm -v $(CURDIR)/output:/output cilium:cilium-bin-deb-$(VERSION)

clean:
rm -rf cilium output version_*
@$(ECHO_CLEAN) $(notdir $(shell pwd))
$(QUIET)rm -rf cilium output version_*

release:
cd $(BASEDIR)
Expand Down
3 changes: 2 additions & 1 deletion contrib/packaging/rpm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ build: clean
echo -e "\nCilium version $(VERSION) packages are located here:\n$(CURDIR)/output/\n"

clean:
rm -rf env cilium output version_* cilium-*.tar.gz
@$(ECHO_CLEAN) $(notdir $(shell pwd))
$(QUIET)rm -rf env cilium output version_* cilium-*.tar.gz

.PHONY: force build clean
force :;
2 changes: 1 addition & 1 deletion contrib/scripts/bindata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [[ $GO_BINDATA_SHA1SUM == "" ]]; then
exit 1
fi

if echo "$GO_BINDATA_SHA1SUM bindata.go" | sha1sum -c; then
if echo "$GO_BINDATA_SHA1SUM bindata.go" | sha1sum -c --quiet; then
exit 0
fi

Expand Down
13 changes: 9 additions & 4 deletions daemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ include ../Makefile.defs
TARGET=cilium-agent
SOURCES := $(shell find ../api ../common ../daemon ../pkg ../monitor . \( -name '*.go' ! -name '*_test.go' \))
$(TARGET): $(SOURCES) check-bindata
@$(ECHO_GO)
$(GO) build -i $(GOBUILD) -o $(TARGET)

GO_BINDATA := go-bindata -prefix ../ -mode 0640 -modtime 1450269211 \
GO_BINDATA := $(QUIET) go-bindata -prefix ../ -mode 0640 -modtime 1450269211 \
-ignore Makefile -ignore bpf_features.h -ignore lxc_config.h \
-ignore netdev_config.h -ignore node_config.h -ignore filter_config.h \
-ignore '.+\.o$$' -ignore '.+\.orig$$' -ignore '.+~$$' \
Expand All @@ -21,7 +22,8 @@ GO_BINDATA := go-bindata -prefix ../ -mode 0640 -modtime 1450269211 \
all: $(TARGET)

clean:
rm -f $(TARGET)
@$(ECHO_CLEAN) $(notdir $(shell pwd))
$(QUIET)rm -f $(TARGET)
$(GO) clean

ifeq ("$(PKG_BUILD)","")
Expand All @@ -41,10 +43,13 @@ endif

.PHONY: check-bindata
check-bindata: bindata.go
../contrib/scripts/bindata.sh $(GO_BINDATA_SHA1SUM)
@$(ECHO_CHECK) contrib/scripts/bindata.sh
$(QUIET) ../contrib/scripts/bindata.sh $(GO_BINDATA_SHA1SUM)

apply-bindata: go-bindata
../contrib/scripts/bindata.sh apply
@$(ECHO_GEN)bpf.sha
$(QUIET) ../contrib/scripts/bindata.sh apply

bindata.go go-bindata: $(BPF_FILES)
@$(ECHO_GEN) $@
$(GO_BINDATA) -o ./bindata.go $(BPF_FILES)
Loading

0 comments on commit f50ae69

Please sign in to comment.