1#
2# Docker cross-compiler target
3#
4# This docker target uses prebuilt toolchains for LoongArch64 from:
5# https://github.com/loongson/build-tools/releases
6#
7FROM docker.io/library/debian:11-slim
8
9# Duplicate deb line as deb-src
10RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.list
11
12RUN export DEBIAN_FRONTEND=noninteractive && \
13    apt-get update && \
14    apt-get install -y eatmydata && \
15    eatmydata apt-get dist-upgrade -y && \
16    apt build-dep -yy qemu
17
18RUN apt-get update && \
19    DEBIAN_FRONTEND=noninteractive apt install -yy eatmydata && \
20    DEBIAN_FRONTEND=noninteractive eatmydata \
21    apt-get install -y --no-install-recommends \
22        build-essential \
23        bison \
24        ca-certificates \
25        ccache \
26        clang  \
27        flex \
28        curl \
29        gettext \
30        git \
31        ninja-build \
32        python3-pip \
33        python3-setuptools \
34        python3-venv \
35        python3-wheel
36
37RUN /usr/bin/pip3 install tomli
38
39RUN curl -#SL https://github.com/loongson/build-tools/releases/download/2023.08.08/CLFS-loongarch64-8.1-x86_64-cross-tools-gcc-glibc.tar.xz \
40    | tar -xJC /opt
41
42ENV PATH $PATH:/opt/cross-tools/bin
43ENV LD_LIBRARY_PATH /opt/cross-tools/lib:/opt/cross-tools/loongarch64-unknown-linux-gnu/lib:$LD_LIBRARY_PATH
44
45ENV QEMU_CONFIGURE_OPTS --disable-system --disable-docs --disable-tools
46ENV DEF_TARGET_LIST loongarch64-linux-user,loongarch-softmmu
47ENV MAKE /usr/bin/make
48
49# As a final step configure the user (if env is defined)
50ARG USER
51ARG UID
52RUN if [ "${USER}" ]; then \
53  id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
54