# rsend build orchestration. Heavy lifting lives in the shell scripts so the
# project builds with one `make` on any Debian box with the pinned toolchain.

.POSIX:

all: native app

# Provision the pinned toolchain (JDK, Go, Android SDK+NDK, Gradle) into
# $HOME/toolchains. One-time; then `. $HOME/toolchains/env.sh` before building.
setup:
	sh ci/setup-toolchain.sh

# Native executables, shipped inside the APK as lib*.so.
native: rsync rsh

# Real rsync, cross-compiled from pinned source via the Android NDK.
rsync:
	sh rsync/build.sh

# Go SSH transport, cross-compiled to Bionic PIE via the NDK (needs the NDK,
# like rsync). rsh logic is verified host-side by `make test`.
rsh:
	sh rsh/build.sh

# Android app. Consumes the native libs from app/src/main/jniLibs. Uses the
# pinned system gradle; run from the repo root where settings.gradle lives. No
# wrapper jar is committed; gradle/wrapper/gradle-wrapper.properties only pins
# the version for F-Droid's gradlew, which refuses to build without it.
app: native
	gradle :app:assembleRelease

test:
	sh ci/test.sh

verify-repro:
	sh ci/verify-repro.sh

clean:
	rm -rf out app/build app/src/main/jniLibs rsync/work rsh/rsh

.PHONY: all setup native rsync rsh app test verify-repro clean
