-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_android.sh
More file actions
executable file
·56 lines (45 loc) · 1.62 KB
/
build_android.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Exit on error
set -e
# Set up variables
GSL_VERSION="2.8" # Update this to the version you want to use
ANDROID_NDK="/home/darth-kartikey/Android/Sdk/ndk/28.0.12674087" # Update this to your NDK path
BUILD_DIR="$(pwd)/gsl_build"
INSTALL_DIR="$(pwd)/gsl/android"
GSL_SOURCE_DIR="$BUILD_DIR/gsl-$GSL_VERSION"
# Download and extract GSL if not already present
if [ ! -d "$GSL_SOURCE_DIR" ]; then
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
wget "https://ftp.gnu.org/gnu/gsl/gsl-$GSL_VERSION.tar.gz"
tar -xzf "gsl-$GSL_VERSION.tar.gz"
cd -
fi
# Function to build for a specific architecture
build_arch() {
local arch=$1
local android_abi=$2
local android_api=21 # Minimum supported API level
echo "Building for $arch"
mkdir -p "$BUILD_DIR/$arch"
cd "$BUILD_DIR/$arch"
# Set up the cross-compilation environment
export TOOLCHAIN="$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64"
export AR="$TOOLCHAIN/bin/llvm-ar"
export CC="$TOOLCHAIN/bin/$arch-linux-android$android_api-clang"
export AS="$CC"
export CXX="$TOOLCHAIN/bin/$arch-linux-android$android_api-clang++"
export LD="$TOOLCHAIN/bin/ld"
export RANLIB="$TOOLCHAIN/bin/llvm-ranlib"
export STRIP="$TOOLCHAIN/bin/llvm-strip"
# Configure and build
"$GSL_SOURCE_DIR/configure" --host="$arch-linux-android" --prefix="$INSTALL_DIR/$android_abi" --enable-shared --disable-static
make -j$(nproc)
make install
cd -
}
# Build for each architecture
#build_arch "aarch64" "arm64-v8a"
#build_arch "armv7a" "armeabi-v7a"
build_arch "x86_64" "x86_64"
echo "GSL built successfully for all architectures"