-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (43 loc) · 1.6 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
53
54
55
56
57
58
59
60
.DEFAULT_GOAL := help
.PHONY : build
ifneq ($(OS), Windows_NT)
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
# supporting source command otherwise /bin/sh
# will be taken as default, which doesn't support source
# neccesary for bash_autocomplete
SHELL := /bin/bash
endif
endif
GOPATH := $(shell go env GOPATH)
DESTDIR?=
PREFIX?=/usr/local
INSTALL_DIR?=$(GOPATH)/bin
MAN_DIR?=$(PREFIX)/share/man
APP := devto
VERSION := $(shell git describe --always)
RFC_3339 := "+%Y-%m-%dT%H:%M:%SZ"
DATE := $(shell date -u $(RFC_3339))
COMMIT := $(shell git rev-list -1 HEAD)
OPTS?=GO111MODULE=on
DEVTO_REPO := github.com/Gealber/devto-cli
BUILDINFO_PATH := $(DEVTO_REPO)/buildinfo
BUILDINFO_VERSION := -X $(BUILDINFO_PATH).version=$(VERSION)
BUILDINFO_DATE := -X $(BUILDINFO_PATH).date=$(DATE)
BUILDINFO_COMMIT := -X $(BUILDINFO_PATH).commit=$(COMMIT)
BUILDINFO?=$(BUILDINFO_VERSION) $(BUILDINFO_DATE) $(BUILDINFO_COMMIT)
BUILD_OPTS?="-ldflags=$(BUILDINFO)"
BUILD_OPTS_DEPLOY?="-ldflags=$(BUILDINFO) -w -s"
build: ## Build binary
go build ${BUILD_OPTS} -o ${APP}
manpage: ## Create manpage. Need sudo permissions
mkdir -p $(MAN_DIR)/man1
install -m 644 share/man/devto.1 $(MAN_DIR)/man1/devto.1
install: ## Install binary and allow manpage
go build $(BUILD_OPTS) -o $(INSTALL_DIR)/$(APP)
bash_autocompletion: ## Enable Bash autocompletation
source bash/enable.sh
clean: ## Cleaning binary
rm -f ${APP}
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'