-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
152 lines (122 loc) · 4.38 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
include /usr/share/dpkg/default.mk
PACKAGE=proxmox-datacenter-manager
CRATENAME=proxmox-datacenter-manager
BUILDDIR ?= $(PACKAGE)-$(DEB_VERSION_UPSTREAM)
ORIG_SRC_TAR=$(PACKAGE)_$(DEB_VERSION_UPSTREAM).orig.tar.gz
DEB=$(PACKAGE)_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
DBG_DEB=$(PACKAGE)-dbgsym_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
DSC=$(PACKAGE)_$(DEB_VERSION).dsc
CARGO ?= cargo
ifeq ($(BUILD_MODE), release)
CARGO_BUILD_ARGS += --release
COMPILEDIR := target/release
else
COMPILEDIR := target/debug
endif
COMPLETION_DIR := cli/completions
DESTDIR =
PREFIX = /usr
BINDIR = $(PREFIX)/bin
SBINDIR = $(PREFIX)/sbin
LIBEXECDIR = $(PREFIX)/libexec
BASHCOMPDIR = $(PREFIX)/share/bash-completion/completions
ZSHCOMPDIR = $(PREFIX)/share/zsh/vendor-completions
UI_DIR = ui
# TODO: finalize naming of binaries/services, e.g.:
# – full proxmox-datacenter-manager-XYZ prefix for all?
# - pdm-XYZ, would not matter for service binaries, but for user facing though.
# If only to avoid overly long executables, we could include a `pdmc` convenience symlink.
# currently it's using "proxmox-datacenter" (like we have "proxmox-backup" as base for PBS), which
# does not really works as well for PDM..
USR_BIN := \
proxmox-datacenter-manager-client \
USR_SBIN := \
proxmox-datacenter-manager-admin \
SERVICE_BIN := \
proxmox-datacenter-api \
proxmox-datacenter-privileged-api \
# for those binaries that are for internal use and e.g. have no command-line completion
INTERNAL_SERVICE_BIN := \
proxmox-datacenter-manager-banner \
proxmox-datacenter-manager-daily-update \
COMPILED_BINS := \
$(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN) $(INTERNAL_SERVICE_BIN))
# completion helper get generated on build
BASH_COMPLETIONS := $(addsuffix .bc,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
ZSH_COMPLETIONS := $(addprefix _,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
SHELL_COMPLETION_FILES := $(addprefix $(COMPLETION_DIR)/,$(BASH_COMPLETIONS) $(ZSH_COMPLETIONS))
all:
install: $(COMPILED_BINS) $(SHELL_COMPLETION_FILES)
install -dm755 $(DESTDIR)$(BINDIR)
$(foreach i,$(USR_BIN), \
install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
install -dm755 $(DESTDIR)$(SBINDIR)
$(foreach i,$(USR_SBIN), \
install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;)
install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox
$(foreach i,$(SERVICE_BIN) $(INTERNAL_SERVICE_BIN), \
install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox/ ;)
install -dm755 $(DESTDIR)$(BASHCOMPDIR)
$(foreach i,$(BASH_COMPLETIONS), \
install -m644 $(COMPLETION_DIR)/$(i) $(DESTDIR)$(BASHCOMPDIR)/ ;)
install -dm755 $(DESTDIR)$(ZSHCOMPDIR)
$(foreach i,$(ZSH_COMPLETIONS), \
install -m644 $(COMPLETION_DIR)/$(i) $(DESTDIR)$(ZSHCOMPDIR)/ ;)
make -C services install
$(COMPILED_BINS): .do-cargo-build
.do-cargo-build:
$(CARGO) build $(CARGO_BUILD_ARGS)
touch .do-cargo-build
$(SHELL_COMPLETION_FILES): create-shell-completions
.PHONY: create-shell-completions
create-shell-completions:
$(MAKE) -C $(COMPLETION_DIR) $(BASH_COMPLETIONS) $(ZSH_COMPLETIONS)
.PHONY: cargo-build
cargo-build:
rm -f .do-cargo-build
$(MAKE) $(COMPILED_BINS)
$(BUILDDIR):
rm -rf $@ [email protected]
mkdir [email protected]
cp -a debian/ server/ services/ cli/ lib/ docs/ ui/ Makefile Cargo.toml [email protected]
echo "git clone git://git.proxmox.com/git/$(PACKAGE).git\\ngit checkout $$(git rev-parse HEAD)" \
> [email protected]/debian/SOURCE
mv [email protected] $@
$(ORIG_SRC_TAR): $(BUILDDIR)
tar czf $(ORIG_SRC_TAR) --exclude="$(BUILDDIR)/debian" $(BUILDDIR)
.PHONY: deb
deb: deb-api deb-ui
deb-api: $(DEB)
$(DBG_DEB): $(DEB)
$(DEB): $(BUILDDIR)
cd $(BUILDDIR); dpkg-buildpackage -b -uc -us
lintian $(DEB)
@echo $(DEB)
.PHONY: dsc
dsc:
rm -rf $(DSC) $(BUILDDIR)
$(MAKE) $(DSC)
lintian $(DSC)
$(DSC): $(BUILDDIR) $(ORIG_SRC_TAR)
cd $(BUILDDIR); dpkg-buildpackage -S -us -uc -d
sbuild: $(DSC)
sbuild $(DSC)
.PHONY: upload
upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
upload: $(DEB) $(DBG_DEB)
tar cf - $(DEB) $(DBG_DEB) |ssh -X [email protected] -- upload --product pdm --dist $(UPLOAD_DIST) --arch $(DEB_HOST_ARCH)
.PHONY: clean distclean
distclean: clean
clean:
$(CARGO) clean
$(MAKE) -C $(COMPLETION_DIR) clean
rm -rf $(PACKAGE)-[0-9]*/ build/
rm -f *.deb *.changes *.dsc *.tar.* *.buildinfo *.build .do-cargo-build
$(MAKE) -C $(UI_DIR) clean
.PHONY: dinstall
dinstall: deb
dpkg -i $(DEB)
.PHONY: deb-ui
deb-ui: $(UI_DIR)
$(MAKE) -C $(UI_DIR) deb
mv $(UI_DIR)/proxmox-datacenter-manager-ui*.deb .