This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
59 lines (47 loc) · 2.33 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
BUILD_DIR=build
CONFIG_DIR=config
PREFIX = /usr/local
CC=go build
GITHASH=$(shell git rev-parse HEAD)
DFLAGS=-race
CFLAGS=-X github.com/ovh/fossil/cmd.githash=$(GITHASH)
CROSS=GOOS=linux GOARCH=amd64
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
VPATH= $(BUILD_DIR)
.SECONDEXPANSION:
build: fossil.go $$(call rwildcard, ./cmd, *.go) $$(call rwildcard, ./core, *.go) $$(call rwildcard, ./listener, *.go) $$(call rwildcard, ./writer, *.go)
$(CC) $(DFLAGS) -ldflags "$(CFLAGS)" -o $(BUILD_DIR)/fossil fossil.go
.PHONY: release
release: fossil.go $$(call rwildcard, ./cmd, *.go) $$(call rwildcard, ./core, *.go) $$(call rwildcard, ./listener, *.go) $$(call rwildcard, ./writer, *.go)
$(CC) -ldflags "-s -w $(CFLAGS)" -o $(BUILD_DIR)/fossil fossil.go
.PHONY: dist
dist: fossil.go $$(call rwildcard, ./cmd, *.go) $$(call rwildcard, ./core, *.go) $$(call rwildcard, ./listener, *.go) $$(call rwildcard, ./writer, *.go)
$(CROSS) $(CC) -ldflags "-s -w $(CFLAGS)" -o $(BUILD_DIR)/fossil fossil.go
.PHONY: service_install
service_install:
install -m 0755 $(CONFIG_DIR)/systemd/fossil.service /etc/systemd/system/multi-user.target.wants/
systemctl daemon-reload
systemctl enable fossil.service
.PHONY: install
install: service_install
install -m 0755 $(BUILD_DIR)/fossil $(PREFIX)/bin
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/bin/fossil
.PHONY: lint
lint:
@command -v gometalinter >/dev/null 2>&1 || { echo >&2 "gometalinter is required but not available please follow instructions from https://github.com/alecthomas/gometalinter"; exit 1; }
gometalinter --deadline=180s --disable-all --enable=gofmt ./listener ./writer ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=vet ./listener ./writer ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=golint ./listener ./writer ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=ineffassign ./listener ./writer ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=misspell ./listener ./writer ./cmd/... ./core/... ./
gometalinter --deadline=180s --disable-all --enable=staticcheck ./listener ./writer ./cmd/... ./core/... ./
.PHONY: format
format:
gofmt -w -s ./cmd ./core ./listener ./writer fossil.go
.PHONY: dev
dev: format lint build
.PHONY: clean
clean:
-rm -r build