VERSION ?= 0.1.0+20260918.1
MAC_VERSION ?= 0.1.0.20260918.1
ARCH ?= amd64
GO ?= go
OUTPUT ?= $(CURDIR)/dist

.PHONY: vendor test linux-deb macos-pkg
vendor:
	cd Driver && $(GO) mod vendor

test:
	cd Driver && $(GO) test -race ./...
	python3 Scripts/test-radio-mosh.py
	bash -n Scripts/radio-gui.sh Scripts/radio-privileged.sh

linux-deb:
	VERSION='$(VERSION)' ARCH='$(ARCH)' GO='$(GO)' OUTPUT='$(OUTPUT)' bash packaging/debian/build.sh

macos-pkg:
	VERSION='$(MAC_VERSION)' OUTPUT='$(OUTPUT)' bash packaging/macos/build.sh

SITE_DEST ?= hail::distribution/modem.goblinreactor.com/
.PHONY: site-check site-serve site-publish
site-check:
	python3 html/tools/check-site.py
site-serve:
	python3 -m http.server 8080 --directory html
site-publish: site-check
	rsync -rtp --no-owner --no-group --chmod=D755,F644 --exclude=tools/ --exclude=README.md html/ '$(SITE_DEST)'

.PHONY: linux-install macos-install
linux-install: linux-deb
	sudo apt install '$(OUTPUT)/goblin-modem_$(VERSION)_$(ARCH).deb'
macos-install: macos-pkg
	brew install goblinreactor/tap/goblin-mosh python@3.14
	sudo installer -pkg '$(OUTPUT)/goblin-modem-$(MAC_VERSION)-arm64.pkg' -target /
