Auto-download FFTW source for Android build

Makefile.android now downloads fftw-3.3.11.tar.gz automatically instead
of requiring the user to place sources in third_party/fftw/ manually.
The FFTW_SRC variable can still be overridden to use an existing copy.
Added distclean target. Updated README accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 12:15:59 +03:00
parent 5bbf9698a8
commit 02926b36ce
2 changed files with 33 additions and 28 deletions
+28 -17
View File
@@ -5,9 +5,8 @@
# Optional overrides:
# ANDROID_NDK=/path/to/ndk ANDROID_API=24 ANDROID_ABIS="arm64-v8a x86_64"
#
# Requires FFTW source in third_party/fftw/
# Download from https://www.fftw.org/download.html and extract so that
# third_party/fftw/configure exists.
# FFTW source is downloaded and extracted automatically.
# Override FFTW_SRC to use an existing directory.
ANDROID_NDK ?= /home/vladimir/Android/Sdk/ndk/29.0.14206865
ANDROID_API ?= 24
@@ -24,7 +23,10 @@ COMMON_CPPFLAGS ?= -I. -I third_party/rnnoise/include -I third_party/libspecblea
ANDROID_JNI_CFLAGS ?= -std=gnu89 -Wno-implicit-function-declaration -Wno-int-conversion \
-Wno-incompatible-pointer-types -Wno-incompatible-pointer-types-discards-qualifiers
FFTW_SRC ?= third_party/fftw
FFTW_VERSION := 3.3.11
FFTW_TAR := fftw-$(FFTW_VERSION).tar.gz
FFTW_URL := https://fftw.org/pub/fftw/$(FFTW_TAR)
FFTW_SRC ?= third_party/fftw-$(FFTW_VERSION)
FFTW_MAKEJOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
WDSP_SOURCES = amd.c \
@@ -148,9 +150,9 @@ ANDROID_OBJ_ROOT := obj/android
ANDROID_LIB_ROOT := lib/android
ANDROID_JAVA_OUT := lib/android/java
.PHONY: all clean java-classes check-fftw-src
.PHONY: all clean distclean java-classes
all: check-fftw-src \
all: $(FFTW_SRC)/configure \
$(foreach abi,$(ANDROID_ABIS),\
$(ANDROID_LIB_ROOT)/$(abi)/libfftw3.so \
$(ANDROID_LIB_ROOT)/$(abi)/libfftw3f.so \
@@ -158,15 +160,21 @@ all: check-fftw-src \
$(ANDROID_LIB_ROOT)/$(abi)/libwdspj.so) \
java-classes
check-fftw-src:
@test -f $(FFTW_SRC)/configure || { \
echo ""; \
echo "ERROR: FFTW source not found at $(FFTW_SRC)/configure"; \
echo "Download and extract FFTW from https://www.fftw.org/download.html"; \
echo "so that $(FFTW_SRC)/configure exists."; \
echo ""; \
exit 1; \
}
# ── Автоматическое получение FFTW ────────────────────────────────────────────
third_party/$(FFTW_TAR):
mkdir -p third_party
@echo ">>> Скачиваем FFTW $(FFTW_VERSION)..."
@if command -v wget >/dev/null 2>&1; then \
wget -q --show-progress -O $@ "$(FFTW_URL)"; \
else \
curl -L --progress-bar -o $@ "$(FFTW_URL)"; \
fi
$(FFTW_SRC)/configure: third_party/$(FFTW_TAR)
@echo ">>> Распаковываем FFTW..."
tar xf $< -C third_party/
@touch $@
# abi_target: compiler triple for NDK clang wrapper
define abi_target
@@ -226,7 +234,7 @@ ABI_$(1)_WDSP_OBJS := $$(patsubst %.c,$$(ABI_$(1)_OBJDIR)/%.o,$$(ALL_C_SOURCES))
ABI_$(1)_JNI_OBJ := $$(ABI_$(1)_OBJDIR)/$(JNI_SOURCE:.c=.o)
# --- Build fftw3 (double) ---
$$(ABI_$(1)_FFTW_STAMP):
$$(ABI_$(1)_FFTW_STAMP): $(FFTW_SRC)/configure
@mkdir -p $$(ABI_$(1)_OBJDIR)/fftw-build $$(ABI_$(1)_FFTW_PREFIX)
cd $$(ABI_$(1)_OBJDIR)/fftw-build && \
$(abspath $(FFTW_SRC))/configure \
@@ -240,7 +248,7 @@ $$(ABI_$(1)_FFTW_STAMP):
@touch $$@
# --- Build fftw3f (float/single) ---
$$(ABI_$(1)_FFTWF_STAMP):
$$(ABI_$(1)_FFTWF_STAMP): $(FFTW_SRC)/configure
@mkdir -p $$(ABI_$(1)_OBJDIR)/fftwf-build $$(ABI_$(1)_FFTWF_PREFIX)
cd $$(ABI_$(1)_OBJDIR)/fftwf-build && \
$(abspath $(FFTW_SRC))/configure \
@@ -311,3 +319,6 @@ java-classes: $(JAVA_SOURCE)
clean:
rm -rf $(ANDROID_OBJ_ROOT) $(ANDROID_LIB_ROOT)
distclean: clean
-rm -rf $(FFTW_SRC) third_party/$(FFTW_TAR)