-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (79 loc) · 2.42 KB
/
Makefile
File metadata and controls
121 lines (79 loc) · 2.42 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
## These will be provided to the target
NAME=shlac
VERSION=0.6-0ubuntu4
SOURCE=https://github.com/umbrella-evgeny-nefedkin/shlac.git
PPA=ppa:onm/shlac
BUILD = $(shell date +%s)
## Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
SHELL = /bin/bash
GOPATH = $(shell pwd)
GOBIN = $(GOPATH)/bin
TARGET1 = $(NAME)d
TARGET2 = $(NAME)
BIN = $(DESTDIR)/usr/bin
CONF = $(DESTDIR)/etc/$(NAME)
export PATH := $(PATH):/usr/local/go/bin
.PHONY: all install uninstall clean ppa configure ppa_test configure_test
all:
@echo "##################################"
@echo "# Compile binaries"
@echo "##################################"
@echo $(LDFLAGS)
mkdir -p $(GOBIN)
GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install $(LDFLAGS) $(TARGET1) $(TARGET2)
@echo " *** Done ***"
@echo ""
install: all
mkdir -p $(BIN)
@echo " *** Install server"
install $(GOBIN)/$(TARGET1) $(BIN)
@echo " *** Install client"
install $(GOBIN)/$(TARGET2) $(BIN)
@echo " *** Install config"
mkdir -p $(CONF)
install ./config.json $(CONF)/config.json
uninstall:
rm -rf $(BIN)/$(TARGET1)
rm -rf $(BIN)/$(TARGET2)
rm -rf $(CONF)/config.json
configure_test:
@echo "##############################"
@echo "# Compile TEST build"
@echo "##############################"
$(MAKE) clean
./configure_ppa.sh shlac $(VERSION) 1 $(SOURCE)
cd build/tmp; debuild -S -us -uc
@echo " *** Build(TEST) is compiled ***"
@echo ""
configure:
@echo "###############################"
@echo "# Compile build"
@echo "###############################"
@echo " ==> Cleaning build directory..."
$(MAKE) clean
@echo " ==> Configure build..."
./configure_ppa.sh shlac $(VERSION) 0 $(SOURCE)
### build package (https://help.launchpad.net/Packaging/PPA/BuildingASourcePackage)
cd build/tmp; debuild -S -sa
@echo " *** Build is compiled ***"
@echo ""
ppa: ppa_test configure
@echo " ==> Uploading to PPA..."
dput -d $(PPA) $(shell ls build/*.changes)
$(MAKE) clean
ppa_test: configure_test
@echo "###############################"
@echo "#**** TESTING BUILD ****#"
@echo "###############################"
@echo " ==> Unpacking..."
cd build/; dpkg-source -x *.dsc
@echo " ==> Testing..."
cd build/$(NAME)-$(VERSION); dh_auto_test;
@echo " ==> Compiling..."
cd build/$(NAME)-$(VERSION); dh_auto_build -a
@echo " *** Build(TEST) is OK ***"
@echo ""
$(MAKE) clean
clean:
@rm -rf build/