-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (61 loc) · 2.06 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
.PHONY: build-ui build-daemon install clean create-install-dir
ifeq ($(OS), Windows_NT)
BINARY_DIR=bin
DAEMON_BINARY=$(BINARY_DIR)\filterbox-daemon.exe
UI_BINARY=$(BINARY_DIR)\filterbox-ui.exe
INSTALL_LOCATION=C:\Program Files\FilterBox
else
BINARY_DIR=./bin
DAEMON_BINARY=$(BINARY_DIR)/filterbox-daemon
UI_BINARY=$(BINARY_DIR)/filterbox-ui
INSTALL_LOCATION=/usr/local/bin
endif
all: build-daemon build-ui
build-daemon:
@echo "Building daemon..."
@go build -o $(DAEMON_BINARY) ./cmd/daemon
build-ui:
@echo "Building UI..."
ifeq ($(OS), Windows_NT)
@go build -ldflags="-H windowsgui" -o $(UI_BINARY) ./cmd/ui
else
@go build -o $(UI_BINARY) ./cmd/ui
endif
install: create-install-dir
ifeq ($(OS), Windows_NT)
@echo "Installing on Windows..."
@copy "$(DAEMON_BINARY)" "$(INSTALL_LOCATION)\filterbox-daemon.exe"
@copy "$(UI_BINARY)" "$(INSTALL_LOCATION)\filterbox.exe"
@copy "dist\uninstall.bat" "$(INSTALL_LOCATION)\uninstall.bat"
@echo Installing Windows service...
@"$(INSTALL_LOCATION)\filterbox-daemon.exe" install
@"$(INSTALL_LOCATION)\filterbox-daemon.exe" start
@echo FilterBox daemon successfully installed and started.
else
@echo "Installing on Linux..."
@sudo cp $(DAEMON_BINARY) ${INSTALL_LOCATION}/filterbox-daemon
@sudo cp $(UI_BINARY) ${INSTALL_LOCATION}/filterbox
@echo "Installing systemd service..."
@cp dist/filterbox-daemon.service ${HOME}/.config/systemd/user/filterbox-daemon.service
@systemctl --user daemon-reload
@systemctl --user enable filterbox-daemon
@systemctl --user start filterbox-daemon
@echo "FilterBox daemon successfully installed, and started."
endif
uninstall:
ifeq ($(OS), Windows_NT)
@cd "$(INSTALL_LOCATION)" && "$(INSTALL_LOCATION)\uninstall.bat"
else
@echo "Uninstalling"
@systemctl --user stop filterbox-daemon
@systemctl --user disable filterbox-daemon
@sudo rm /usr/local/bin/filterbox-daemon
@sudo rm /usr/local/bin/filterbox
endif
clean:
@echo "Cleaning up..."
@rm -rf $(BINARY_DIR)
create-install-dir:
ifeq ($(OS), Windows_NT)
@if not exist "$(INSTALL_LOCATION)" mkdir "$(INSTALL_LOCATION)"
endif