Skip to content

Commit

Permalink
Refactor Makefile targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky committed Aug 22, 2020
1 parent 38166b9 commit 91d0992
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project_name: pgcenter
before:
hooks:
- go mod download
- make dep
- make clean
builds:
-
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
- "1.13.x"
- "1.14.x"

env:
global:
Expand Down
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ LDFLAGS = -ldflags "-X github.com/lesovsky/pgcenter/cmd.gitTag=${TAG} \
-X github.com/lesovsky/pgcenter/cmd.gitCommit=${COMMIT} \
-X github.com/lesovsky/pgcenter/cmd.gitBranch=${BRANCH}"

.PHONY: all clean install uninstall
.PHONY: help clean dep build install uninstall

all: pgcenter
.DEFAULT_GOAL := help

pgcenter:
help: ## Display this help screen.
@echo "Makefile available targets:"
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " * \033[36m%-15s\033[0m %s\n", $$1, $$2}'

clean: ## Clean build directory.
rm -f ./bin/${PROGRAM_NAME}
rmdir ./bin

dep: ## Download the dependencies.
go mod download
CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o ${PROGRAM_NAME} ${SOURCE}

install:
install -pm 755 ${PROGRAM_NAME} /usr/bin/${PROGRAM_NAME}
build: dep ## Build pgcenter executable.
mkdir -p ./bin
CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build ${LDFLAGS} -o bin/${PROGRAM_NAME} ${SOURCE}

clean:
rm -f ${PROGRAM_NAME}
install: ## Install pgcenter executable into /usr/bin directory.
install -pm 755 bin/${PROGRAM_NAME} /usr/bin/${PROGRAM_NAME}

uninstall:
uninstall: ## Uninstall pgcenter executable from /usr/bin directory.
rm -f /usr/bin/${PROGRAM_NAME}

0 comments on commit 91d0992

Please sign in to comment.