-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (61 loc) · 2.57 KB
/
Makefile
File metadata and controls
70 lines (61 loc) · 2.57 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
SWIFT = swift
BUILD_DIR = .build
EXECUTABLE = clipslots
DEV_CERT = ClipSlots-Dev
.PHONY: all build build-debug clean run install setup-cert site
all: build
# One-time: create a self-signed cert so Accessibility permission survives rebuilds
setup-cert:
@if security find-identity -v -p codesigning | grep -q "$(DEV_CERT)"; then \
echo "Certificate '$(DEV_CERT)' already exists."; \
else \
echo "Creating self-signed code-signing certificate '$(DEV_CERT)'..."; \
openssl req -x509 -newkey rsa:2048 -keyout /tmp/clipslots-dev.key \
-out /tmp/clipslots-dev.crt -days 3650 -nodes \
-subj "/CN=$(DEV_CERT)" \
-addext "keyUsage=digitalSignature" \
-addext "extendedKeyUsage=codeSigning" 2>/dev/null; \
openssl pkcs12 -export -out /tmp/clipslots-dev.p12 \
-inkey /tmp/clipslots-dev.key -in /tmp/clipslots-dev.crt \
-passout pass:clipslots -legacy 2>/dev/null; \
security import /tmp/clipslots-dev.p12 -k ~/Library/Keychains/login.keychain-db \
-T /usr/bin/codesign -P "clipslots"; \
security find-certificate -c "$(DEV_CERT)" -p ~/Library/Keychains/login.keychain-db \
> /tmp/clipslots-dev.pem; \
openssl x509 -in /tmp/clipslots-dev.pem -out /tmp/clipslots-dev.cer -outform DER 2>/dev/null; \
security add-trusted-cert -p codeSign -k ~/Library/Keychains/login.keychain-db \
/tmp/clipslots-dev.cer; \
rm -f /tmp/clipslots-dev.key /tmp/clipslots-dev.crt /tmp/clipslots-dev.p12 \
/tmp/clipslots-dev.pem /tmp/clipslots-dev.cer; \
echo "Certificate '$(DEV_CERT)' created and trusted for code signing."; \
fi
build:
$(SWIFT) build -c release
@if security find-identity -v -p codesigning | grep -q "$(DEV_CERT)"; then \
codesign -f -s "$(DEV_CERT)" ./$(BUILD_DIR)/release/$(EXECUTABLE); \
echo "Signed with $(DEV_CERT)"; \
fi
@if launchctl list com.clipslots.daemon >/dev/null 2>&1; then \
echo "Daemon running — restarting with new binary..."; \
./$(BUILD_DIR)/release/$(EXECUTABLE) restart; \
fi
build-debug:
$(SWIFT) build
@if security find-identity -v -p codesigning | grep -q "$(DEV_CERT)"; then \
codesign -f -s "$(DEV_CERT)" ./$(BUILD_DIR)/debug/$(EXECUTABLE); \
echo "Signed with $(DEV_CERT)"; \
fi
@if launchctl list com.clipslots.daemon >/dev/null 2>&1; then \
echo "Daemon running — restarting with new binary..."; \
./$(BUILD_DIR)/debug/$(EXECUTABLE) restart; \
fi
clean:
rm -rf $(BUILD_DIR) Package.resolved
run: build-debug
./$(BUILD_DIR)/debug/$(EXECUTABLE)
install: build
@echo "Installing to /usr/local/bin..."
@sudo cp $(BUILD_DIR)/release/$(EXECUTABLE) /usr/local/bin/
@echo "Installed successfully"
site:
open docs/index.html