-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·52 lines (42 loc) · 1.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# --- adapted from: https://github.com/filebrowser/filebrowser/blob/master/Makefile --------------
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
help: ## Show this help
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-15s${GREEN}%s${RESET}\n", $$1, $$2} \
}' $(MAKEFILE_LIST)
# ------------------------------------------------------------------------------------------------
GOOS ?= $(shell go env GOOS)
ifeq ($(GOOS),windows)
BIN_EXT := .exe
RM := rmdir /s /q
else
RM := rm -rf
endif
APP_NAME=rando
VERSION=`git describe --always --long --dirty|tr '\n' '-';date +%Y.%m.%d`
LDFLAGS=-ldflags "-w -s -X main.version=$(VERSION)" -trimpath
GO_BUILD=GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) go build $(LDFLAGS)
.SILENT: ;
build: ## tidy up, build the binary, and put it in ./bin
echo "Building binary to ./bin/$(APP_NAME)"
go mod tidy
mkdir -p ./bin
$(GO_BUILD) -o ./bin/$(APP_NAME)$(BIN_EXT) ./cmd/$(APP_NAME)/main.go
clean: ## run go clean and delete ./bin if it exists
go clean
$(RM) ./bin
# --- stolen from: https://github.com/traefikturkey/onramp/blob/master/Makefile ☜(꒡⌓꒡) ----------
excuse: ## fucking epic!
curl -s programmingexcuses.com | grep -Eo "<a[^<>]+>[^<>]+</a>" | grep -Eo "[^<>]+" | sed -n 2p
# -------------------------------------------------------------------------------------------------
# bunch of fuckin' phonies
.PHONY: build docker-build docker-run clean excuse help