-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (64 loc) · 2.36 KB
/
Copy pathMakefile
File metadata and controls
73 lines (64 loc) · 2.36 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
APP_NAME := macbook-notchless
BUNDLE_ID := com.local.macbook-notchless
BUILD_DIR := build
APP_BUNDLE := $(BUILD_DIR)/$(APP_NAME).app
CONTENTS := $(APP_BUNDLE)/Contents
MACOS_DIR := $(CONTENTS)/MacOS
SOURCES := NotchlessApp.swift AppDelegate.swift
INSTALL_DIR := $(HOME)/Applications
INSTALLED_APP := $(INSTALL_DIR)/$(APP_NAME).app
INSTALLED_EXE := $(INSTALLED_APP)/Contents/MacOS/$(APP_NAME)
LAUNCH_AGENT_DIR := $(HOME)/Library/LaunchAgents
LAUNCH_AGENT_PLIST := $(LAUNCH_AGENT_DIR)/$(BUNDLE_ID).plist
.PHONY: all run install uninstall clean
all: $(APP_BUNDLE)
$(APP_BUNDLE): $(SOURCES) Info.plist
@mkdir -p $(MACOS_DIR)
swiftc -o $(MACOS_DIR)/$(APP_NAME) \
-target arm64-apple-macos13 \
-O \
$(SOURCES)
cp Info.plist $(CONTENTS)/Info.plist
@touch $(APP_BUNDLE)
run: $(APP_BUNDLE)
open $(APP_BUNDLE)
install: $(APP_BUNDLE) LaunchAgent.plist.in
@mkdir -p $(LAUNCH_AGENT_DIR)
@if [ ! -w $(LAUNCH_AGENT_DIR) ]; then \
echo ""; \
echo "Error: $(LAUNCH_AGENT_DIR) is not writable by your user."; \
echo " Currently owned by: $$(stat -f '%Su:%Sg mode=%Sp' $(LAUNCH_AGENT_DIR))"; \
echo ""; \
echo "Some installers (e.g. PulseSecure) chown this directory to root,"; \
echo "which breaks per-user LaunchAgents. Fix it once with:"; \
echo ""; \
echo " sudo chown $$(id -un):staff $(LAUNCH_AGENT_DIR)"; \
echo ""; \
echo "Then re-run: make install"; \
exit 1; \
fi
@echo "Installing $(APP_NAME) to $(INSTALLED_APP)"
@mkdir -p $(INSTALL_DIR)
@rm -rf $(INSTALLED_APP)
cp -R $(APP_BUNDLE) $(INSTALLED_APP)
@echo "Writing LaunchAgent to $(LAUNCH_AGENT_PLIST)"
@sed -e 's|__LABEL__|$(BUNDLE_ID)|g' \
-e 's|__EXEC_PATH__|$(INSTALLED_EXE)|g' \
LaunchAgent.plist.in > $(LAUNCH_AGENT_PLIST)
@echo "Stopping any existing instance"
-@launchctl bootout gui/$$(id -u) $(LAUNCH_AGENT_PLIST) 2>/dev/null
-@killall $(APP_NAME) 2>/dev/null
@echo "Loading LaunchAgent"
launchctl bootstrap gui/$$(id -u) $(LAUNCH_AGENT_PLIST)
@echo "Done. $(APP_NAME) is running and will auto-start at login."
uninstall:
@echo "Stopping LaunchAgent"
-@launchctl bootout gui/$$(id -u) $(LAUNCH_AGENT_PLIST) 2>/dev/null
-@killall $(APP_NAME) 2>/dev/null
@echo "Removing $(LAUNCH_AGENT_PLIST)"
rm -f $(LAUNCH_AGENT_PLIST)
@echo "Removing $(INSTALLED_APP)"
rm -rf $(INSTALLED_APP)
@echo "Done. $(APP_NAME) uninstalled."
clean:
rm -rf $(BUILD_DIR)