mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 02:07:55 +02:00
Update Android build process
This commit is contained in:
parent
777eddc76c
commit
0a9031834f
3 changed files with 38 additions and 37 deletions
|
@ -58,8 +58,8 @@ endif
|
|||
ifeq ($(TARGET), ANDROID)
|
||||
|
||||
CXX = $(PROGRAM_PREFIX)clang++
|
||||
CXXFLAGS += -pthread -fPIC -DHAS_TREMOR -DHAS_OPENSL -DHAS_OBOE -I$(NDK_DIR)/usr/local/include
|
||||
LDFLAGS = -L$(NDK_DIR)/usr/local/lib -pie -lvorbisidec -logg -lopus -lFLAC -lOpenSLES -loboe -latomic -llog -lsoxr -static-libstdc++
|
||||
CXXFLAGS += -pthread -fPIC -DHAS_TREMOR -DHAS_OPENSL -DHAS_OBOE -I$(TOOLCHAIN)/sysroot/usr/include -I$(TOOLCHAIN)/sysroot/$(NDK_TARGET)/usr/local/include
|
||||
LDFLAGS = -L$(TOOLCHAIN)/sysroot/$(NDK_TARGET)/usr/local/lib -pie -lvorbisidec -logg -lopus -lFLAC -lOpenSLES -loboe -latomic -llog -lsoxr -static-libstdc++
|
||||
OBJ += player/opensl_player.o player/oboe_player.o
|
||||
|
||||
else ifeq ($(TARGET), OPENWRT)
|
||||
|
@ -95,23 +95,25 @@ all: check-env $(BIN)
|
|||
|
||||
check-env:
|
||||
ifeq ($(TARGET), ANDROID)
|
||||
$(eval TOOLCHAIN:=$(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64)
|
||||
ifndef NDK_DIR
|
||||
$(error android NDK_DIR is not set)
|
||||
endif
|
||||
ifndef ARCH
|
||||
$(error ARCH is not set (arm, mips, x86))
|
||||
$(error ARCH is not set (arm, aarch64, x86))
|
||||
endif
|
||||
ifeq ($(ARCH), x86)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/i686-linux-android-)
|
||||
else ifeq ($(ARCH), mips)
|
||||
$(eval CXXFLAGS:=$(CXXFLAGS) -DIS_BIG_ENDIAN)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/mipsel-linux-android-)
|
||||
$(eval NDK_TARGET:=x86_64-linux-android)
|
||||
$(eval API:=21)
|
||||
else ifeq ($(ARCH), arm)
|
||||
$(eval NDK_TARGET:=armv7a-linux-androideabi)
|
||||
$(eval API:=16)
|
||||
$(eval CXXFLAGS:=$(CXXFLAGS) -march=armv7)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/arm-linux-androideabi-)
|
||||
else ifeq ($(ARCH), arm64)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/aarch64-linux-android-)
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
$(eval NDK_TARGET:=aarch64-linux-android)
|
||||
$(eval API:=21)
|
||||
endif
|
||||
$(eval PROGRAM_PREFIX:=$(TOOLCHAIN)/bin/$(NDK_TARGET)$(API)-)
|
||||
endif
|
||||
|
||||
$(BIN): $(OBJ)
|
||||
|
|
22
doc/build.md
22
doc/build.md
|
@ -276,16 +276,8 @@ Cross compilation for Android is done with the [Android NDK](http://developer.an
|
|||
|
||||
Install the Android [NDK toolchain](http://developer.android.com/ndk/guides/standalone_toolchain.html)
|
||||
|
||||
1. Download NDK: `https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip`
|
||||
2. Extract to: `/SOME/LOCAL/PATH/android-ndk-r17b`
|
||||
3. Setup toolchains for arm and x86 somewhere in your home dir (`<android-ndk dir>`):
|
||||
|
||||
```sh
|
||||
cd /SOME/LOCAL/PATH/android-ndk-r17/build/tools
|
||||
./make_standalone_toolchain.py --arch arm --api 16 --stl libc++ --install-dir <android-ndk dir>-arm
|
||||
./make_standalone_toolchain.py --arch arm64 --api 21 --stl libc++ --install-dir <android-ndk dir>-arm64
|
||||
./make_standalone_toolchain.py --arch x86 --api 16 --stl libc++ --install-dir <android-ndk dir>-x86
|
||||
```
|
||||
1. Download NDK: `https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip`
|
||||
2. Extract to: `/SOME/LOCAL/PATH/android-ndk-r21d`
|
||||
|
||||
### Build Snapclient
|
||||
|
||||
|
@ -293,16 +285,16 @@ Cross compile and install FLAC, opus, ogg, and tremor (only needed once):
|
|||
|
||||
```sh
|
||||
cd <snapcast dir>/externals
|
||||
make NDK_DIR=<android-ndk dir>-arm ARCH=arm
|
||||
make NDK_DIR=<android-ndk dir>-arm64 ARCH=aarch64
|
||||
make NDK_DIR=<android-ndk dir>-x86 ARCH=x86
|
||||
make NDK_DIR=<android-ndk dir> ARCH=arm
|
||||
make NDK_DIR=<android-ndk dir> ARCH=aarch64
|
||||
make NDK_DIR=<android-ndk dir> ARCH=x86
|
||||
```
|
||||
|
||||
|
||||
Compile the Snapclient:
|
||||
|
||||
```sh
|
||||
cd <snapcast dir>/client
|
||||
./build_android_all.sh <android-ndk dir> <snapdroid jniLibs dir>
|
||||
./build_android.sh <android-ndk dir> <snapdroid jniLibs dir>
|
||||
```
|
||||
|
||||
The binaries for `armeabi`, `arm64-v8a` and `x86` will be copied into the Android's jniLibs directory (`<snapdroid jniLibs dir>/`) and so will be bundled with the Snapcast App.
|
||||
|
|
31
externals/Makefile
vendored
31
externals/Makefile
vendored
|
@ -34,21 +34,28 @@ endif
|
|||
ifndef ARCH
|
||||
$(error ARCH is not set ("arm" or "aarch64" or "x86"))
|
||||
endif
|
||||
|
||||
$(eval TOOLCHAIN:=$(NDK_DIR)/toolchains/llvm/prebuilt/linux-x86_64)
|
||||
|
||||
ifeq ($(ARCH), x86)
|
||||
$(eval CPPFLAGS:=-DLITTLE_ENDIAN=1234 -DBIG_ENDIAN=4321 -DBYTE_ORDER=LITTLE_ENDIAN)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/i686-linux-android-)
|
||||
$(eval TARGET:=x86_64-linux-android)
|
||||
$(eval API:=21)
|
||||
else ifeq ($(ARCH), arm)
|
||||
$(eval CPPFLAGS:=-U_ARM_ASSEM_)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/arm-linux-androideabi-)
|
||||
$(eval TARGET:=armv7a-linux-androideabi)
|
||||
$(eval API:=16)
|
||||
else ifeq ($(ARCH), aarch64)
|
||||
$(eval CPPFLAGS:=-U_ARM_ASSEM_ -DLITTLE_ENDIAN=1234 -DBIG_ENDIAN=4321 -DBYTE_ORDER=LITTLE_ENDIAN)
|
||||
$(eval PROGRAM_PREFIX:=$(NDK_DIR)/bin/aarch64-linux-android-)
|
||||
$(eval TARGET:=aarch64-linux-android)
|
||||
$(eval API:=21)
|
||||
else
|
||||
$(error ARCH must be "arm" or "aarch64" or "x86")
|
||||
endif
|
||||
$(eval CC:=$(PROGRAM_PREFIX)clang)
|
||||
$(eval CXX:=$(PROGRAM_PREFIX)clang++)
|
||||
$(eval CPPFLAGS:=-I$(NDK_DIR)/include $(CPPFLAGS))
|
||||
$(eval CC:=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang)
|
||||
$(eval CXX:=$(TOOLCHAIN)/bin/$(TARGET)$(API)-clang++)
|
||||
$(eval SYSROOT:=$(TOOLCHAIN)/sysroot/$(TARGET))
|
||||
$(eval CPPFLAGS:=-I$(TOOLCHAIN)/sysroot/usr/include -I$(SYSROOT)/usr/local/include $(CPPFLAGS))
|
||||
|
||||
flac: check-env
|
||||
@cd flac; \
|
||||
|
@ -56,7 +63,7 @@ flac: check-env
|
|||
export CXX="$(CXX)"; \
|
||||
export CPPFLAGS="$(CPPFLAGS)"; \
|
||||
./autogen.sh; \
|
||||
./configure --host=$(ARCH) --disable-ogg --prefix=$(NDK_DIR)/usr/local/; \
|
||||
./configure --host=$(ARCH) --disable-ogg --prefix=$(SYSROOT)/usr/local/; \
|
||||
make; \
|
||||
make install; \
|
||||
make clean;
|
||||
|
@ -67,7 +74,7 @@ ogg: check-env
|
|||
export CXX="$(CXX)"; \
|
||||
export CPPFLAGS="$(CPPFLAGS)"; \
|
||||
./autogen.sh; \
|
||||
./configure --host=$(ARCH) --prefix=$(NDK_DIR)/usr/local/; \
|
||||
./configure --host=$(ARCH) --prefix=$(SYSROOT)/usr/local/; \
|
||||
make; \
|
||||
make install; \
|
||||
make clean;
|
||||
|
@ -78,7 +85,7 @@ opus: check-env
|
|||
export CXX="$(CXX)"; \
|
||||
export CPPFLAGS="$(CPPFLAGS)"; \
|
||||
./autogen.sh; \
|
||||
./configure --host=$(ARCH) --prefix=$(NDK_DIR)/usr/local/; \
|
||||
./configure --host=$(ARCH) --prefix=$(SYSROOT)/usr/local/; \
|
||||
make; \
|
||||
make install; \
|
||||
make clean;
|
||||
|
@ -89,7 +96,7 @@ tremor: check-env
|
|||
export CXX="$(CXX)"; \
|
||||
export CPPFLAGS="$(CPPFLAGS)"; \
|
||||
./autogen.sh; \
|
||||
./configure --host=$(ARCH) --prefix=$(NDK_DIR)/usr/local/ --with-ogg=$(NDK_DIR)/usr/local/; \
|
||||
./configure --host=$(ARCH) --prefix=$(SYSROOT)/usr/local/ --with-ogg=$(SYSROOT)/usr/local/; \
|
||||
make; \
|
||||
make install; \
|
||||
make clean; \
|
||||
|
@ -124,7 +131,7 @@ oboe: check-env
|
|||
cd build; \
|
||||
cmake ..; \
|
||||
make; \
|
||||
make DESTDIR=$(NDK_DIR) install; \
|
||||
make DESTDIR=$(SYSROOT) install; \
|
||||
make clean; \
|
||||
cd ..; \
|
||||
rm -rf build;
|
||||
|
@ -138,7 +145,7 @@ soxr: check-env
|
|||
cd build; \
|
||||
cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DWITH_OPENMP=OFF ..; \
|
||||
make; \
|
||||
make DESTDIR=$(NDK_DIR) install; \
|
||||
make DESTDIR=$(SYSROOT) install; \
|
||||
make clean; \
|
||||
cd ..; \
|
||||
rm -rf build;
|
||||
|
|
Loading…
Add table
Reference in a new issue