-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (49 loc) · 1.44 KB
/
Copy pathMakefile
File metadata and controls
57 lines (49 loc) · 1.44 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
# Legion — Build & Package
# Usage:
# make build — compile release binaries
# make pkg — create macOS .pkg installer
# make install — copy binaries to /usr/local/bin
# make uninstall — remove installed binaries
# make clean — remove build artifacts
VERSION := $(shell grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')
ARCH := $(shell uname -m)
PKG_NAME := legion-$(VERSION)-$(ARCH).pkg
PKG_ID := com.legion.cli
INSTALL_DIR := /usr/local/bin
BINARIES := legion legion-dispatch legion-check legion-report legion-status legion-stop legion-deps
RELEASE_DIR := target/release
PKG_ROOT := target/pkg-root
.PHONY: build pkg install uninstall clean
build:
cargo build --release
pkg: build
@echo "==> Packaging $(PKG_NAME)"
@rm -rf $(PKG_ROOT)
@mkdir -p $(PKG_ROOT)$(INSTALL_DIR)
@for bin in $(BINARIES); do \
cp $(RELEASE_DIR)/$$bin $(PKG_ROOT)$(INSTALL_DIR)/; \
done
pkgbuild \
--root $(PKG_ROOT) \
--identifier $(PKG_ID) \
--version $(VERSION) \
--install-location / \
$(PKG_NAME)
@rm -rf $(PKG_ROOT)
@echo "==> Created $(PKG_NAME)"
@ls -lh $(PKG_NAME)
install: build
@echo "==> Installing to $(INSTALL_DIR)"
@for bin in $(BINARIES); do \
cp $(RELEASE_DIR)/$$bin $(INSTALL_DIR)/; \
done
@echo "==> Done"
uninstall:
@echo "==> Removing legion binaries from $(INSTALL_DIR)"
@for bin in $(BINARIES); do \
rm -f $(INSTALL_DIR)/$$bin; \
done
@echo "==> Done"
clean:
cargo clean
rm -f legion-*.pkg