1313DOCKER_IMAGE := tailscale-android-build-amd64-041425-1
1414export TS_USE_TOOLCHAIN =1
1515
16- # Auto-select an NDK from ANDROID_HOME (choose highest version available)
17- NDK_ROOT ?= $(shell ls -1d $(ANDROID_HOME ) /ndk/* 2>/dev/null | sort -V | tail -n 1)
18-
19- HOST_OS := $(shell uname | tr A-Z a-z)
20- ifeq ($(HOST_OS ) ,linux)
21- STRIP_TOOL := $(NDK_ROOT ) /toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
22- else ifeq ($(HOST_OS),darwin)
23- STRIP_TOOL := $(NDK_ROOT ) /toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy
24- endif
25-
26- $(info Using NDK_ROOT : $(NDK_ROOT ) )
27- $(info Using STRIP_TOOL : $(STRIP_TOOL ) )
28-
2916DEBUG_APK := tailscale-debug.apk
3017RELEASE_AAB := tailscale-release.aab
3118RELEASE_TV_AAB := tailscale-tv-release.aab
@@ -64,6 +51,21 @@ ifeq ($(ANDROID_SDK_ROOT),)
6451endif
6552export ANDROID_HOME ?= $(ANDROID_SDK_ROOT )
6653
54+ # Auto-select an NDK from ANDROID_HOME (choose highest version available)
55+ NDK_ROOT ?= $(shell ls -1d $(ANDROID_HOME ) /ndk/* 2>/dev/null | sort -V | tail -n 1)
56+
57+ HOST_OS := $(shell uname | tr A-Z a-z)
58+ ifeq ($(HOST_OS ) ,linux)
59+ STRIP_TOOL := $(NDK_ROOT ) /toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
60+ else ifeq ($(HOST_OS),darwin)
61+ STRIP_TOOL := $(NDK_ROOT ) /toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-objcopy
62+ endif
63+
64+ $(info Using ANDROID_HOME : $(ANDROID_HOME ) )
65+ $(info Using NDK_ROOT : $(NDK_ROOT ) )
66+ $(info Using STRIP_TOOL : $(STRIP_TOOL ) )
67+
68+
6769# Attempt to find Android Studio for Linux configuration, which does not have a
6870# predetermined location.
6971ANDROID_STUDIO_ROOT ?= $(shell find ~/android-studio /usr/local/android-studio /opt/android-studio /Applications/Android\ Studio.app $(PROGRAMFILES ) /Android/Android\ Studio -type d -maxdepth 1 2>/dev/null | head -n 1)
@@ -312,7 +314,7 @@ checkandroidsdk: ## Check that Android SDK is installed
312314test : gradle-dependencies # # Run the Android tests
313315 (cd android && ./gradlew test)
314316
315- .PHONY : emulator
317+ .PHONY : emulator
316318emulator : # # Start an android emulator instance
317319 @echo " Checking installed SDK packages..."
318320 @if ! $(ANDROID_HOME ) /cmdline-tools/latest/bin/sdkmanager --list_installed | grep -q " $( AVD_IMAGE) " ; then \
@@ -327,15 +329,15 @@ emulator: ## Start an android emulator instance
327329 @echo " Starting emulator..."
328330 @$(ANDROID_HOME ) /emulator/emulator -avd " $( AVD) " -logcat-output /dev/stdout -netdelay none -netspeed full
329331
330- .PHONY : install
332+ .PHONY : install
331333install : $(DEBUG_APK ) # # Install the debug APK on a connected device
332334 adb install -r $<
333335
334336.PHONY : run
335337run : install # # Run the debug APK on a connected device
336338 adb shell am start -n com.tailscale.ipn/com.tailscale.ipn.MainActivity
337339
338- .PHONY : docker-build-image
340+ .PHONY : docker-build-image
339341docker-build-image : # # Builds the docker image for the android build environment if it does not exist
340342 @echo " Checking if docker image $( DOCKER_IMAGE) already exists..."
341343 @if ! docker images $(DOCKER_IMAGE ) -q | grep -q . ; then \
0 commit comments