-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (60 loc) · 1.73 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Origin: https://github.com/innogames/graphite-ch-optimizer/blob/master/Makefile
# MIT License
NAME = aes-256-cbc-cli
VERSION = $(shell git describe --always --tags --abbrev=0 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/c\1/;s/-/./g')
GIT_COMMIT = $(shell git rev-parse HEAD)
DATE = $(shell date +%F)
VENDOR = "Lev Subbotin <subveles@gmail.com>"
URL = https://github.com/GranderStark/$(NAME)
define DESC =
'Simple aes encryption-decryption ommand line tool'
endef
GO_FILES = $(shell find ./ -name '*.go')
GO_BUILD = go build -ldflags "-X 'main.version=$(VERSION)' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.buildDate=$(DATE)'"
PKG_FILES = build/$(NAME)_$(VERSION)_amd64.deb build/$(NAME)-$(VERSION)-1.x86_64.rpm
export CGO_ENABLED = 0
export GOOS = $(shell uname -s | awk '{print tolower($0)}')
export GOARCH = amd64
.PHONY: clean all version test
all: build
version:
@echo $(VERSION)
clean:
rm -rf build
rm -rf $(NAME)
rebuild: clean all
test:
go vet ./...
go test -v ./...
build: $(NAME)/$(NAME)
$(NAME)/config.yml: $(NAME)/$(NAME)
./$(NAME)/$(NAME) default-config > $@
$(NAME)/$(NAME): $(GO_FILES)
$(GO_BUILD) -o $@ ./cmd/$(NAME)
build/$(NAME): $(GO_FILES)
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO_BUILD) -o $@ ./cmd/$(NAME)
packages: $(PKG_FILES)
.ONESHELL:
build/pkg: build/$(NAME)
cd build
mkdir -p pkg/etc/$(NAME)
mkdir -p pkg/usr/bin
cp -l $(NAME) pkg/usr/bin/
deb: $(word 1, $(PKG_FILES))
rpm: $(word 2, $(PKG_FILES))
# Set TYPE to package suffix w/o dot
$(PKG_FILES): TYPE = $(subst .,,$(suffix $@))
$(PKG_FILES): build/pkg
fpm --verbose \
-s dir \
-a x86_64 \
-t $(TYPE) \
--vendor $(VENDOR) \
-m $(VENDOR) \
--url $(URL) \
--description $(DESC) \
--license MIT \
-n $(NAME) \
-v $(VERSION) \
-p build \
build/pkg/=/