Skip to content

Commit 11b7a12

Browse files
committedApr 30, 2020
Improve Makefile
1 parent 6b43402 commit 11b7a12

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
porcelain
2+
porcelain.1
23
dist/

‎Makefile

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1-
all:
2-
@go build -ldflags "-X main.date=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.commit=`git rev-parse --short HEAD` -X main.version=`git describe --tags --long`"
1+
.POSIX:
2+
.SUFFIXES:
3+
4+
GO ?= go
5+
RM ?= rm
6+
SCDOC ?= scdoc
7+
8+
REV ?= $(shell git rev-parse --short HEAD)
9+
VERSION ?= $(shell git describe --tags --long)
10+
11+
GOFLAGS =
12+
GO_LDFLAGS ?= -s -w
13+
GO_LDFLAGS += -X main.date=$(shell date -u -I) -X main.commit=$(REV) -X main.version=$(VERSION)
14+
15+
.PHONY: all
16+
all: porcelain porcelain.1
17+
18+
porcelain:
19+
$(GO) build $(GOFLAGS) -ldflags "$(GO_LDFLAGS)"
20+
21+
porcelain.1: porcelain.1.scd
22+
$(SCDOC) < $< >$@
23+
24+
PREFIX ?= /usr/local
25+
BINDIR ?= $(PREFIX)/bin
26+
MANDIR ?= $(PREFIX)/share/man
27+
28+
.PHONY: install
29+
install: porcelain porcelain.1
30+
mkdir -p $(DESTDIR)$(BINDIR)
31+
mkdir -p $(DESTDIR)$(MANDIR)/man1
32+
cp -f porcelain $(DESTDIR)$(BINDIR)
33+
cp -f porcelain.1 $(DESTDIR)$(MANDIR)/man1
34+
35+
.PHONY: clean
36+
clean:
37+
$(RM) porcelain porcelain.1

0 commit comments

Comments
 (0)
Please sign in to comment.