-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
59 lines (48 loc) · 1.62 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
.DEFAULT_GOAL := help
VERSION := $(shell git describe --tags)
BUILD := $(shell git rev-parse --short HEAD)
PROJECTNAME := $(shell basename "$(PWD)")
MANPATH := $(HOME)/.local/share/man
APIURL := "10.10.150.25:6666"
APISECRETS := $(APIURL)/secrets
APICERT := $(APIURL)/cert
BBDIR := $(HOME)/.butlerburton
# Go related variables.
GOFILES := $(wildcard *.go)
# Redirect error output to a file, so we can show it in development mode.
STDERR=/tmp/.$(PROJECTNAME)-stderr.txt
# Use linker flags to provide version
LDFLAGS=-ldflags "-X=main.Version=$(VERSION)"
# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent
# Make sure manpath/man1 is created
_dummy := $(shell mkdir -p $(MANPATH)/man1)
## install: install app, runs 'go install' internally
install:
curl $(APISECRETS) --create-dirs -o $(BBDIR)/private.json
curl $(APICERT) --create-dirs -o $(BBDIR)/butlerBurtonCert.pfx
go install $(LDFLAGS)
cp butler-burton.1.gz $(MANPATH)/man1
## update: updates the installed app to a new version. Basically the same as install without downloading the cert-files
update:
go install $(LDFLAGS)
cp butler-burton.1.gz $(MANPATH)/man1
## build: build binary, runs 'go build' internally
build:
go build $(LDFLAGS) -o $(PROJECTNAME)
## generate and gzip manppage from markdown, uses pandoc
manpage:
pandoc butlerburton.md -s -t man -o butler-burton.1
gzip butler-burton.1
## build and interact with docker dev environment
dev:
docker build -t "bb" .
docker run -it "bb" sh
.PHONY: help
all: help
help: Makefile
@echo
@echo " Choose a command run in "$(PROJECTNAME)":"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo