makefile: place phony markers after targets (#4408)

The .PHONY targets in the Makefile are usually placed far away from the actual targets, and thus aren't always updated. Placing the .PHONY targets right next to the targets they cover make them more visible and thus more likely to be updated when necessary.
This commit is contained in:
Erik Grinaker
2020-02-14 14:41:18 +01:00
committed by GitHub
parent 3b5794ffe9
commit 5f5e0e1d02
3 changed files with 56 additions and 15 deletions
+11 -2
View File
@@ -51,25 +51,31 @@ PROTOBUF = $(TOOLS_DESTDIR)/protoc
GOODMAN = $(TOOLS_DESTDIR)/goodman
all: tools
.PHONY: all
tools: certstrap protobuf goodman
.PHONY: tools
check: check_tools
.PHONY: check
check_tools:
@# https://stackoverflow.com/a/25668869
@echo "Found tools: $(foreach tool,$(notdir $(GOTOOLS)),\
$(if $(shell which $(tool)),$(tool),$(error "No $(tool) in PATH")))"
.PHONY: check_tools
certstrap: $(CERTSTRAP)
$(CERTSTRAP):
@echo "Get Certstrap"
@go get github.com/square/certstrap@v1.2.0
.PHONY: certstrap
protobuf: $(PROTOBUF)
$(PROTOBUF):
@echo "Get GoGo Protobuf"
@go get github.com/gogo/protobuf/protoc-gen-gogo@v1.3.1
.PHONY: protobuf
buf: protoc-gen-buf-check-breaking protoc-gen-buf-check-lint
@echo "Installing buf..."
@@ -77,6 +83,7 @@ buf: protoc-gen-buf-check-breaking protoc-gen-buf-check-lint
"https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${UNAME_S}-${UNAME_M}" \
-o "${BIN}/buf" && \
chmod +x "${BIN}/buf"
.PHONY: buf
protoc-gen-buf-check-breaking:
@echo "Installing protoc-gen-buf-check-breaking..."
@@ -91,17 +98,20 @@ protoc-gen-buf-check-lint:
"https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/protoc-gen-buf-check-lint-${UNAME_S}-${UNAME_M}" \
-o "${BIN}/protoc-gen-buf-check-lint" && \
chmod +x "${BIN}/protoc-gen-buf-check-lint"
.PHONY: protoc-gen-buf-check-lint
goodman: $(GOODMAN)
$(GOODMAN):
@echo "Get Goodman"
@go get github.com/snikch/goodman/cmd/goodman@10e37e294daa3c9a90abded60ff9924bafab3888
.PHONY: goodman
tools-clean:
rm -f $(CERTSTRAP) $(PROTOBUF) $(GOX) $(GOODMAN)
rm -f tools-stamp
rm -rf /usr/local/include/google/protobuf
rm -f /usr/local/bin/protoc
.PHONY: tooks-clean
###
# Non Go tools
@@ -127,5 +137,4 @@ protoc:
@unzip -o $(PROTOC_ZIP) -d /usr/local bin/protoc
@unzip -o $(PROTOC_ZIP) -d /usr/local 'include/*'
@rm -f $(PROTOC_ZIP)
.PHONY: all tools tools-clean protoc
.PHONY: protoc