randomedit/Makefile

61 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2018-09-24 05:53:13 +00:00
ifeq ($(origin VERSION), undefined)
VERSION != git rev-parse --short HEAD
endif
PREFIX=/usr/local
HOST_GOOS=$(shell go env GOOS)
HOST_GOARCH=$(shell go env GOARCH)
# GOOS=windows GOARCH=386
2021-07-13 12:42:16 +00:00
NAME=randomedit
REPO_PATH=bitbucket.com/glenux-corp/randomedit
2018-09-24 05:53:13 +00:00
BUILD_DIR=$(shell pwd)/_build
INSTALL_DIR=$(PREFIX)/bin
SHARE_DIR=$(PREFIX)/share/$(NAME)
all: build
build: vendor ## build executable
@mkdir -p "$(BUILD_DIR)"
# go build -i ./...
# GOBIN="$(BUILD_DIR)" go install ./...
for binary in $$(cd cmd ; ls) ; do \
2018-09-24 05:53:13 +00:00
name="$$(basename "$$binary")" ; \
go build -o "_build/$$binary" ./cmd/$$binary/... || exit 1 ; \
2018-09-24 05:53:13 +00:00
done
install:
install -g root -o root -m 644 -D Procfile "$(SHARE_DIR)"/Procfile
for binary in "$(BUILD_DIR)"/* ; do \
name="$$(basename "$$binary")" ; \
install -g root -o root -m 0755 -D $$binary "$(INSTALL_DIR)"/$$name || exit 1 ; \
done
echo "INSTALL_DIR=$(INSTALL_DIR)" > "$(SHARE_DIR)"/env.production
uninstall:
for binary in "$(BUILD_DIR)"/* ; do \
name="$$(basename "$$binary")" ; \
rm -f "$(INSTALL_DIR)/$$name" || exit 1 ; \
done
rm -fr "$(SHARE_DIR)
vendor: ## prepare build tools & vendor dependencies
go mod download
.PHONY: vendor
help: ## print this help
@echo "Usage: make <target>"
@echo ""
@echo "With one of following targets:"
@awk 'BEGIN {FS = ":.*?## "} \
/^[a-zA-Z_-]+:.*?## / \
{ sub("\\\\n",sprintf("\n%22c"," "), $$2); \
printf("\033[36m%-20s\033[0m %s\n", $$1, $$2); \
}' $(MAKEFILE_LIST)
clean: ## remove build artifacts
rm -rf "$(BUILD_DIR)"/*