全隧道模式下before-proxy、after-proxy和手动刷新三处仍会从URL 下载CIDR表,但下载结果永远不会被使用。添加ModeFull短路返回, 消除无意义的网络请求和连接延迟。 bump version to 0.6.9
159 lines
6.1 KiB
Makefile
159 lines
6.1 KiB
Makefile
# LMVPN Client — Makefile
|
|
|
|
APP_NAME = LMVPN
|
|
BUNDLE_ID = com.lmvpn.client
|
|
GUI_BIN = lmvpn
|
|
DAEMON_BIN = lmvpnd
|
|
BUILD_DIR = build
|
|
APP_BUNDLE = $(APP_NAME).app
|
|
|
|
GO = go
|
|
CGO_ENABLED = 1
|
|
WINDRES ?= x86_64-w64-mingw32-windres
|
|
MINGW_CC ?= x86_64-w64-mingw32-gcc
|
|
SEMVER ?= 0.6.9
|
|
GIT_HASH = $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
VERSION = $(SEMVER)-$(GIT_HASH)
|
|
LDFLAGS = -s -w -X lmvpn/internal/version.Version=$(VERSION)
|
|
|
|
# Code signing (optional). Set these to sign the .app bundle with a
|
|
# Developer ID certificate, enabling biometric (Touch ID) keychain access.
|
|
# Example: make app CODESIGN_IDENTITY="Developer ID Application: Name (ABCDE12345)" TEAM_ID=ABCDE12345
|
|
CODESIGN_IDENTITY ?=
|
|
TEAM_ID ?=
|
|
|
|
.PHONY: all build app run daemon clean vet tidy fmt icon icon-windows build-windows installer-windows sign
|
|
|
|
## all: build the .app bundle (default)
|
|
all: app
|
|
|
|
## build: compile both the GUI and daemon binaries
|
|
build:
|
|
mkdir -p $(BUILD_DIR)
|
|
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(GUI_BIN) ./cmd/lmvpn
|
|
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(DAEMON_BIN) ./cmd/lmvpnd
|
|
|
|
## app: build binaries and assemble .app bundle
|
|
app: build
|
|
rm -rf $(APP_BUNDLE)
|
|
mkdir -p $(APP_BUNDLE)/Contents/MacOS
|
|
mkdir -p $(APP_BUNDLE)/Contents/Resources
|
|
cp $(BUILD_DIR)/$(GUI_BIN) $(APP_BUNDLE)/Contents/MacOS/$(GUI_BIN)
|
|
cp $(BUILD_DIR)/$(DAEMON_BIN) $(APP_BUNDLE)/Contents/MacOS/$(DAEMON_BIN)
|
|
cp resources/Info.plist $(APP_BUNDLE)/Contents/Info.plist
|
|
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(SEMVER)" \
|
|
-c "Set :CFBundleVersion $(GIT_HASH)" \
|
|
$(APP_BUNDLE)/Contents/Info.plist
|
|
@if [ -f resources/icon.icns ]; then \
|
|
cp resources/icon.icns $(APP_BUNDLE)/Contents/Resources/icon.icns; \
|
|
else echo " (no icon.icns found, skipping icon)"; fi
|
|
@if [ -n "$(CODESIGN_IDENTITY)" ]; then $(MAKE) sign; \
|
|
else echo " (skipping code signing - set CODESIGN_IDENTITY and TEAM_ID to enable Touch ID keychain)"; fi
|
|
@echo "Built $(APP_BUNDLE)"
|
|
|
|
## sign: code-sign the .app bundle with a Developer ID certificate
|
|
## Requires CODESIGN_IDENTITY and TEAM_ID to be set.
|
|
sign:
|
|
@if [ -z "$(CODESIGN_IDENTITY)" ]; then \
|
|
echo "ERROR: CODESIGN_IDENTITY not set."; \
|
|
echo "Usage: make sign CODESIGN_IDENTITY='Developer ID Application: Name (TEAMID)' TEAM_ID=TEAMID"; \
|
|
exit 1; \
|
|
fi
|
|
@if [ -z "$(TEAM_ID)" ]; then \
|
|
echo "ERROR: TEAM_ID not set."; \
|
|
exit 1; \
|
|
fi
|
|
@tmp=$$(mktemp LMVPN.entitlements.XXXXXX); \
|
|
sed 's/\$$(AppIdentifierPrefix)/$(TEAM_ID)./' resources/LMVPN.entitlements > $$tmp; \
|
|
codesign --force --options runtime \
|
|
--sign "$(CODESIGN_IDENTITY)" \
|
|
--entitlements $$tmp \
|
|
$(APP_BUNDLE)/Contents/MacOS/$(GUI_BIN); \
|
|
codesign --force --options runtime \
|
|
--sign "$(CODESIGN_IDENTITY)" \
|
|
--entitlements $$tmp \
|
|
$(APP_BUNDLE)/Contents/MacOS/$(DAEMON_BIN); \
|
|
codesign --force --options runtime \
|
|
--sign "$(CODESIGN_IDENTITY)" \
|
|
--entitlements $$tmp \
|
|
$(APP_BUNDLE); \
|
|
rm -f $$tmp
|
|
@echo "Signed $(APP_BUNDLE) with identity: $(CODESIGN_IDENTITY)"
|
|
|
|
## icon: generate icon.icns from resources/icon.png (or resources/logo.svg)
|
|
icon:
|
|
@if [ -f resources/logo.svg ] && [ ! -f resources/icon.png -o resources/logo.svg -nt resources/icon.png ]; then \
|
|
echo "Converting resources/logo.svg -> resources/icon.png"; \
|
|
sips -z 1024 1024 -s format png resources/logo.svg --out resources/icon.png >/dev/null 2>&1; \
|
|
fi
|
|
@if [ ! -f resources/icon.png ]; then echo "resources/icon.png not found"; exit 1; fi
|
|
mkdir -p resources/icon.iconset
|
|
@for size in 16 32 64 128 256 512 1024; do \
|
|
sips -z $$size $$size resources/icon.png --out resources/icon.iconset/icon_$${size}x$${size}.png >/dev/null 2>&1; \
|
|
done
|
|
@for pair in "16 32" "32 64" "128 256" "256 512"; do \
|
|
set -- $$pair; \
|
|
sips -z $$2 $$2 resources/icon.png --out resources/icon.iconset/icon_$${1}x$${1}@2x.png >/dev/null 2>&1; \
|
|
done
|
|
cp resources/icon.png resources/icon.iconset/icon_512x512@2x.png
|
|
iconutil -c icns resources/icon.iconset -o resources/icon.icns
|
|
rm -rf resources/icon.iconset
|
|
@echo "Generated resources/icon.icns"
|
|
|
|
## run: build and run the GUI
|
|
run: build
|
|
./$(BUILD_DIR)/$(GUI_BIN)
|
|
|
|
## daemon: run the daemon directly (needs root)
|
|
daemon: build
|
|
sudo ./$(BUILD_DIR)/$(DAEMON_BIN)
|
|
|
|
## vet: run go vet
|
|
vet:
|
|
$(GO) vet ./...
|
|
|
|
## tidy: run go mod tidy
|
|
tidy:
|
|
$(GO) mod tidy
|
|
|
|
## fmt: format Go code
|
|
fmt:
|
|
$(GO) fmt ./...
|
|
|
|
## clean: remove build artifacts
|
|
clean:
|
|
rm -rf $(BUILD_DIR) $(APP_BUNDLE)
|
|
|
|
## icon-windows: generate icon.ico and compile Windows resource (.syso)
|
|
icon-windows:
|
|
go run resources/genico/main.go
|
|
$(WINDRES) -i resources/lmvpn.rc -O coff -o cmd/lmvpn/resource_windows_amd64.syso
|
|
$(WINDRES) -i resources/lmvpn.rc -O coff -o cmd/lmvpnd/resource_windows_amd64.syso
|
|
@echo "Generated Windows icon resources"
|
|
|
|
## build-windows: cross-compile Windows x86_64 exes (requires mingw-w64)
|
|
## The .syso icon resources are committed in cmd/*/; run `make icon-windows` to regenerate.
|
|
build-windows:
|
|
mkdir -p $(BUILD_DIR)
|
|
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=$(MINGW_CC) \
|
|
$(GO) build -ldflags "$(LDFLAGS) -H windowsgui" -o $(BUILD_DIR)/$(GUI_BIN).exe ./cmd/lmvpn
|
|
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=$(MINGW_CC) \
|
|
$(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(DAEMON_BIN).exe ./cmd/lmvpnd
|
|
@echo "Built $(BUILD_DIR)/$(GUI_BIN).exe and $(BUILD_DIR)/$(DAEMON_BIN).exe"
|
|
|
|
## installer-windows: build exes and compile Inno Setup installer (.exe)
|
|
## Requires ISCC on PATH (Windows) or Wine + Inno Setup 6 (macOS/Linux).
|
|
installer-windows: build-windows
|
|
@echo "Compiling installer with version $(VERSION)..."
|
|
@if command -v ISCC >/dev/null 2>&1; then \
|
|
ISCC /DAppVersion=$(VERSION) installer/lmvpn.iss; \
|
|
elif command -v wine >/dev/null 2>&1; then \
|
|
wine "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /DAppVersion=$(VERSION) installer/lmvpn.iss; \
|
|
else \
|
|
echo "ERROR: ISCC not found. Install Inno Setup 6 on Windows,"; \
|
|
echo " or install Wine + Inno Setup 6 on macOS/Linux."; \
|
|
echo " Download: https://jrsoftware.org/isdl.php"; \
|
|
exit 1; \
|
|
fi
|
|
@echo "Installer: $(BUILD_DIR)/LMVPN-Setup-$(VERSION).exe"
|