2025-02-24 20:22:00 +00:00
|
|
|
# Start with a base image containing build tools and libraries
|
2025-02-24 22:24:48 +00:00
|
|
|
FROM debian:stable
|
2025-02-24 20:22:00 +00:00
|
|
|
|
|
|
|
# Set the working directory
|
|
|
|
WORKDIR /src
|
|
|
|
|
|
|
|
# Install necessary build tools
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
build-essential \
|
2025-02-24 22:24:48 +00:00
|
|
|
gcc
|
2025-02-24 20:22:00 +00:00
|
|
|
# g++ \
|
|
|
|
# make \
|
|
|
|
# wget \
|
|
|
|
# curl \
|
|
|
|
# git \
|
|
|
|
# ca-certificates \
|
|
|
|
# bison \
|
|
|
|
# flex \
|
|
|
|
# python3 \
|
|
|
|
# texinfo
|
|
|
|
|
|
|
|
# Install cross-compilers for x86, ARM, MIPS, and RISC-V
|
|
|
|
RUN apt-get install -y \
|
2025-02-24 22:24:48 +00:00
|
|
|
gcc-12-arm-linux-gnueabihf \
|
|
|
|
gcc-12-mips-linux-gnu \
|
|
|
|
gcc-12-riscv64-linux-gnu \
|
|
|
|
gcc-12-aarch64-linux-gnu
|
2025-02-24 20:22:00 +00:00
|
|
|
|
|
|
|
# Copy the C file into the container
|
|
|
|
COPY test.c /src/
|
|
|
|
|
|
|
|
# Compile the C file for x86
|
2025-02-24 22:24:48 +00:00
|
|
|
CMD gcc -c -O0 test.c -o ../obj/test-x86-o0.o && \
|
|
|
|
gcc -c -O3 test.c -o ../obj/test-x86-o3.o && \
|
2025-02-24 20:22:00 +00:00
|
|
|
# Compile the C file for ARM
|
2025-02-24 22:24:48 +00:00
|
|
|
arm-linux-gnueabihf-gcc-12 -c -O0 test.c -o ../obj/test-arm-o0.o && \
|
|
|
|
arm-linux-gnueabihf-gcc-12 -c -O3 test.c -o ../obj/test-arm-o3.o && \
|
2025-02-24 20:22:00 +00:00
|
|
|
# Compile the C file for MIPS
|
2025-02-24 22:24:48 +00:00
|
|
|
mips-linux-gnu-gcc-12 -c -O0 test.c -o ../obj/test-mips-o0.o && \
|
|
|
|
mips-linux-gnu-gcc-12 -c -O3 test.c -o ../obj/test-mips-o3.o && \
|
2025-02-24 20:22:00 +00:00
|
|
|
# Compile the C file for RISC-V
|
2025-02-24 22:24:48 +00:00
|
|
|
riscv64-linux-gnu-gcc-12 -c -O0 test.c -o ../obj/test-riscv-o0.o && \
|
|
|
|
riscv64-linux-gnu-gcc-12 -c -O3 test.c -o ../obj/test-riscv-o3.o
|