forked from hakwerk/labca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (70 loc) · 2.25 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
PKG?=github.com/hakwerk/labca/gui
BINNAME?=labca-gui
# Set V to 1 for verbose output from the Makefile
Q=$(if $V,,@)
PREFIX?=
TAG=$(shell git rev-list --tags --max-count=1)
VERSION=$(shell git describe --tags $(TAG))
DEB_VERSION=$(shell echo $(VERSION) | sed 's/^v//' | sed 's/-/./g')
RELEASE=./release
all: build
.PHONY: all
ifdef V
$(info VERSION is $(VERSION))
$(info DEB_VERSION is $(DEB_VERSION))
endif
#########################################
# Build
#########################################
LDFLAGS := -ldflags='-w -X "main.standaloneVersion=$(VERSION)"'
download:
$Q cd gui; \
go mod download; \
cd ..
build: $(PREFIX)bin/$(BINNAME)
@echo "Build Complete!"
$(PREFIX)bin/$(BINNAME): download $(call rwildcard,*.go)
$Q mkdir -p $(@D)
$Q cd gui; \
$(GOOS_OVERRIDE) $(GOFLAGS) go build -o ../$(PREFIX)bin/$(BINNAME) $(LDFLAGS) $(PKG); \
cd ..
.PHONY: download build
#########################################
# Install
#########################################
INSTALL_PREFIX?=/usr/
install: $(PREFIX)bin/$(BINNAME)
$Q install -D $(PREFIX)bin/$(BINNAME) $(DESTDIR)$(INSTALL_PREFIX)bin/$(BINNAME)
uninstall:
$Q rm -f $(DESTDIR)$(INSTALL_PREFIX)/bin/$(BINNAME)
.PHONY: install uninstall
#########################################
# Debian
#########################################
changelog:
$Q echo "labca-gui ($(DEB_VERSION)) unstable; urgency=medium" > debian/changelog
$Q echo >> debian/changelog
$Q echo " * See https://github.com/hakwerk/labca/releases" >> debian/changelog
$Q echo >> debian/changelog
$Q echo " -- hakwerk <[email protected]> $(shell date -uR)" >> debian/changelog
debian: changelog
$Q mkdir -p $(RELEASE); \
OUTPUT=../labca-gui*.deb; \
rm -f $$OUTPUT; \
dpkg-buildpackage -b -rfakeroot -us -uc && cp $$OUTPUT $(RELEASE)/
distclean: clean
.PHONY: changelog debian distclean
#########################################
# Clean
#########################################
clean:
ifneq ($(BINNAME),"")
$Q rm -f $(PREFIX)bin/$(BINNAME)
endif
.PHONY: clean
#########################################
# Dev
#########################################
run:
$Q cd gui && go run -ldflags='-X "main.standaloneVersion=$(shell git describe --always --tags HEAD)"' github.com/hakwerk/labca/gui --config stepca_config.json; cd ..
.PHONY: run