-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (63 loc) · 2.19 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
GOCMD=go
GOTEST=$(GOCMD) test
VERSION?=$(shell cat VERSION | tr -d "\n")
RELEASE?=1
BINARY_NAME=rcagent
DIR_NAME=rcagent-$(VERSION)
LOCAL_DIR=/usr/local/rcagent
VFLAGS=-X github.com/rechecked/rcagent/internal/config.Version=$(VERSION)
LDFLAGS?=
.PHONY: build test clean install
all: help
build: clean
$(GOCMD) build -o build/bin/$(BINARY_NAME) -ldflags "$(VFLAGS) $(LDFLAGS)"
build-tar: clean
tar -czf build/rcagent-$(VERSION).tar.gz . --transform 's,^,rcagent-$(VERSION)/,'
build-rpm: build-tar
mkdir -p $(HOME)/rpmbuild/SOURCES/
mv -f build/rcagent-$(VERSION).tar.gz $(HOME)/rpmbuild/SOURCES/
cp build/package/rcagent.spec build/rcagent.spec
sed -i "s/Version:.*/Version: $(VERSION)/g" build/rcagent.spec
sed -i "s/Release:.*/Release: $(RELEASE)%{?dist}/g" build/rcagent.spec
rpmbuild -ba build/rcagent.spec
find $(HOME)/rpmbuild/RPMS -name "rcagent-*.rpm" -exec cp {} build \;
build-deb: build-rpm
cd build && alien -c -k -v rcagent-*.rpm
build-dmg:
mkdir build/$(DIR_NAME)
cp build/bin/$(BINARY_NAME) build/$(DIR_NAME)/$(BINARY_NAME)
cp build/package/config.yml build/$(DIR_NAME)/config.yml
cp build/package/macos/install.sh build/$(DIR_NAME)/install.sh
cp build/package/macos/uninstall.sh build/$(DIR_NAME)/uninstall.sh
cd build && hdiutil create -volname $(DIR_NAME) -srcfolder $(DIR_NAME) -ov -format UDZO $(DIR_NAME).dmg
install:
mkdir -p $(LOCAL_DIR)/plugins
cp -f build/bin/$(BINARY_NAME) $(LOCAL_DIR)/$(BINARY_NAME)
cp -n build/package/config.yml $(LOCAL_DIR)/config.yml
test:
$(GOTEST) -v ./... -coverprofile cover.out
coverage:
$(GOCMD) tool cover -func cover.out
clean:
rm -rf build/bin
rm -rf build/rcagent-*
rm -f build/rcagent.spec
help:
@echo ''
@echo 'Usage:'
@echo ' make <target>'
@echo ''
@echo 'Targets:'
@echo ' build build the binary'
@echo ''
@echo ' install install rcagent into /usr/local'
@echo ''
@echo ' build-rpm build rpm package'
@echo ' build-deb build deb package'
@echo ' build-dmg build dmg package'
@echo ''
@echo ' build-tar bundle the source into a tar.gz file'
@echo ''
@echo ' test run the go tests'
@echo ' coverage show the coverage from running make test'
@echo ' clean clean up the directoies/binary files'