-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Makefile
82 lines (66 loc) · 1.95 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
# EveBox Makefile
#
# Requirements:
# - GNU Make
# Version info.
CARGO_VERSION := $(shell cat Cargo.toml | \
awk '/^version/ { gsub(/"/, "", $$3); print $$3 }')
VERSION := $(shell echo $(CARGO_VERSION) | \
sed 's/\(.*\)\-.*/\1/')
VERSION_SUFFIX := $(shell echo $(CARGO_VERSION) | \
sed -n 's/.*-\(.*\)/\1/p')
BUILD_REV ?= $(shell git rev-parse --short HEAD)
BUILD_DATE ?= $(shell date +%s)
export BUILD_DATE
CARGO ?= cargo
APP := evebox
WEBAPP_SRCS := $(shell find webapp -type f | grep -v node_modules)
HOST_TARGET := $(shell rustc -Vv| awk '/^host/ { print $$2 }')
TARGET ?= $(HOST_TARGET)
OS := $(shell rustc --target $(TARGET) --print cfg | awk -F'"' '/target_os/ { print $$2 }')
ifeq ($(OS),windows)
APP_EXT := .exe
endif
CARGO_BUILD_ARGS :=
ifdef TARGET
CARGO_BUILD_ARGS += --target $(TARGET)
endif
ifneq ($(VERSION_SUFFIX),)
DIST_VERSION := devel
else
DIST_VERSION := $(VERSION)
endif
DIST_ARCH := $(shell rustc --target $(TARGET) --print cfg | \
awk -F'"' '/target_arch/ { print $$2 }' | \
sed -e 's/x86_64/x64/' | sed -e 's/aarch64/arm64/')
EVEBOX_BIN := target/$(TARGET)/release/$(APP)$(APP_EXT)
all: evebox
clean:
rm -rf dist target resources/public resources/webapp
find . -name \*~ -exec rm -f {} \;
$(MAKE) -C webapp clean
.PHONY: dist rpm deb
resources/webapp/index.html: $(WEBAPP_SRCS)
cd webapp && $(MAKE)
webapp: resources/webapp/index.html
# Build's EveBox for the host platform.
evebox: webapp
$(CARGO) build
dist: DIST_NAME ?= $(APP)-$(DIST_VERSION)-$(OS)-$(DIST_ARCH)
dist: DIST_DIR ?= dist/$(DIST_NAME)
dist:
echo "Building $(DIST_NAME)..."
$(MAKE) -C webapp
$(CARGO) build --release $(CARGO_BUILD_ARGS)
mkdir -p $(DIST_DIR)
cp $(EVEBOX_BIN) $(DIST_DIR)/
mkdir -p $(DIST_DIR)/examples
cp examples/agent.yaml $(DIST_DIR)/examples/
cp examples/evebox.yaml $(DIST_DIR)/examples/
cd dist && zip -r $(DIST_NAME).zip $(DIST_NAME)
fmt:
cargo fmt
cd webapp && npm run fmt
fixup:
$(MAKE) fmt
cargo clippy --fix --allow-dirty