-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
48 lines (40 loc) · 1.09 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
CGO_CPPFLAGS ?= ${CPPFLAGS}
export CGO_CPPFLAGS
CGO_CFLAGS ?= ${CFLAGS}
export CGO_CFLAGS
CGO_LDFLAGS ?= $(filter -g -L% -l% -O%,${LDFLAGS})
export CGO_LDFLAGS
EXE =
ifeq ($(GOOS),windows)
EXE = .exe
endif
## The following tasks delegate to `script/build.go` so they can be run cross-platform.
.PHONY: bin/inst$(EXE)
bin/inst$(EXE): script/build
@script/build $@
script/build: script/build.go
GOOS= GOARCH= GOARM= GOFLAGS= CGO_ENABLED= go build -o $@ $<
.PHONY: clean
clean:
rm -f script/build
rm -f bin/inst
# just a convenience task around `go test`
.PHONY: test
test:
@go test -v -race -coverpkg=./... -coverprofile=coverage.out ./...
@go tool cover -func=coverage.out
@go tool cover -html=coverage.out
@rm coverage.out
## Install/uninstall tasks are here for use on *nix platform. On Windows, there is no equivalent.
DESTDIR :=
prefix := /usr/local
bindir := ${prefix}/bin
mandir := ${prefix}/share/man
.PHONY: install
install: bin/inst
install -d ${DESTDIR}${bindir}
install -m755 bin/inst ${DESTDIR}${bindir}/
.PHONY: uninstall
uninstall:
rm -f ${DESTDIR}${bindir}/inst
rm -f bin/inst