-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (50 loc) · 2.37 KB
/
Copy pathMakefile
File metadata and controls
62 lines (50 loc) · 2.37 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
# SPDX-License-Identifier: Apache-2.0
CC ?= cc
CFLAGS += -Wall -Wextra -O2 -Wno-deprecated-declarations
LDLIBS += -framework IOKit -framework CoreFoundation
OBJS = main.o usb.o rndis.o net.o dhcp.o
all: erg-tetherd ErgTether.app
erg-tetherd: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDLIBS)
ergtetherbar: menubar/ErgTetherBar.swift
swiftc -swift-version 5 -O $< -o $@
# A real bundle, not a bare executable: UNUserNotificationCenter needs a bundle
# identifier and traps without one, and LSUIElement is what keeps a menu bar app
# out of the Dock. Ad-hoc signing is enough for notifications to be delivered
# locally; shipping to anyone else would need a Developer ID and notarization.
ErgTether.app: ergtetherbar menubar/Info.plist
rm -rf $@
mkdir -p $@/Contents/MacOS
cp menubar/Info.plist $@/Contents/Info.plist
cp ergtetherbar $@/Contents/MacOS/ErgTether
codesign --force --sign - $@
$(OBJS): tether.h rndis.h
clean:
rm -rf erg-tetherd ergtetherbar ErgTether.app $(OBJS)
.PHONY: all clean
# Install as a system service: the daemon watches for phones and connects on its
# own; the menu bar app starts at login. The binaries go to a root-owned
# directory on purpose -- a LaunchDaemon runs as root, so anyone who can write
# its program can become root.
PREFIX ?= /usr/local/libexec
install: erg-tetherd ErgTether.app
sudo install -d -o root -g wheel -m 755 $(PREFIX)
sudo install -o root -g wheel -m 755 erg-tetherd $(PREFIX)/erg-tetherd
sudo rm -rf $(PREFIX)/ErgTether.app
sudo cp -R ErgTether.app $(PREFIX)/ErgTether.app
sudo install -o root -g wheel -m 644 launchd/com.ergtether.daemon.plist \
/Library/LaunchDaemons/com.ergtether.daemon.plist
install -m 644 launchd/com.ergtether.bar.plist \
$(HOME)/Library/LaunchAgents/com.ergtether.bar.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.ergtether.daemon.plist
launchctl bootstrap gui/$$(id -u) $(HOME)/Library/LaunchAgents/com.ergtether.bar.plist
@echo "installed — plug in a tethering phone and it should just connect"
uninstall:
-sudo launchctl bootout system/com.ergtether.daemon
-launchctl bootout gui/$$(id -u)/com.ergtether.bar
sudo rm -f /Library/LaunchDaemons/com.ergtether.daemon.plist
rm -f $(HOME)/Library/LaunchAgents/com.ergtether.bar.plist
sudo rm -rf $(PREFIX)/erg-tetherd $(PREFIX)/ErgTether.app
pkg: erg-tetherd ErgTether.app
@packaging/build-pkg.sh
.PHONY: install uninstall pkg