FROM ghcr.io/cross-rs/aarch64-linux-android:edge

# Install build dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        gperf wget ca-certificates \
        make file \
        && rm -rf /var/lib/apt/lists/*

# Build libseccomp statically.
ENV LIBSECCOMP_VERSION=2.6.0
RUN wget -q https://github.com/seccomp/libseccomp/releases/download/v${LIBSECCOMP_VERSION}/libseccomp-${LIBSECCOMP_VERSION}.tar.gz && \
    tar xf libseccomp-${LIBSECCOMP_VERSION}.tar.gz && \
    cd libseccomp-${LIBSECCOMP_VERSION} && \
    ./configure \
        --host=aarch64-linux-android \
        --prefix=/usr/local/aarch64-linux-android \
        --enable-static \
        --disable-shared && \
    make -j$(nproc) && \
    make install && \
    cd .. && \
    rm -rf libseccomp-${LIBSECCOMP_VERSION}*

# Build libunwind statically.
ENV LIBUNWIND_VERSION=1.6.2
RUN wget -q https://github.com/libunwind/libunwind/releases/download/v${LIBUNWIND_VERSION}/libunwind-${LIBUNWIND_VERSION}.tar.gz && \
    tar xf libunwind-${LIBUNWIND_VERSION}.tar.gz && \
    cd libunwind-${LIBUNWIND_VERSION} && \
    ./configure \
        --host=aarch64-linux-android \
        --prefix=/usr/local/aarch64-linux-android \
        --enable-static \
        --enable-cxx-exceptions \
        --disable-shared \
        --disable-minidebuginfo \
        --disable-zlibdebuginfo \
        --disable-tests \
        --disable-documentation \
        --disable-coredump \
        --disable-ptrace && \
    make -j$(nproc) && \
    make install && \
    cd .. && \
    rm -rf libunwind-${LIBUNWIND_VERSION}*
