Created
March 16, 2026 18:50
-
-
Save djdejawu/89bd22abc5ba2d04cc55909ece4c3c1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Cross compilation Midnight commander for RISC-V 64 | |
| ### License: MIT | |
| ### (C) DeJaWu, 2026 | |
| ### Tested on Sipeed Lichee RV | |
| ### To build: | |
| ### ```podman build -f Dockerfile.mc.riscv64 -o <path> .``` | |
| FROM debian:sid AS builder | |
| ENV MC_VER=4.8.33 \ | |
| GLIB_VER=2.88.0 \ | |
| OPENSSL_VER=3.6.1 \ | |
| LIBSSH2_VER=1.11.1 \ | |
| PCRE2_VER=10.42 \ | |
| LIBFFI_VER=3.5.2 \ | |
| NCURSES_VER=6.4 \ | |
| ZLIBNG_VER=2.0.0-RC2 \ | |
| CC=riscv64-linux-gnu-gcc \ | |
| CXX=riscv64-linux-gnu-g++ \ | |
| PREFIX=/usr/riscv64-linux-gnu \ | |
| PKG_CONFIG_LIBDIR=/usr/riscv64-linux-gnu/lib/pkgconfig \ | |
| PKG_CONFIG_SYSROOT_DIR=/ \ | |
| PKG_CONFIG_ALLOW_CROSS=1 \ | |
| PKG_CONFIG_LIBDIR=/usr/riscv64-linux-gnu/lib/riscv64-linux-gnu/pkgconfig:/usr/riscv64-linux-gnu/share/pkgconfig \ | |
| LANG=ru_RU.UTF-8 \ | |
| LC_ALL=ru_RU.UTF-8 \ | |
| TZ=Europe/Moscow | |
| # 0. cross-compiler & tools | |
| RUN apt-get update && apt-get install -y \ | |
| gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu libc6-dev-riscv64-cross \ | |
| pkg-config git cmake make autopoint automake libtool gettext \ | |
| python3-pip ninja-build meson wget xz-utils texinfo flex bison \ | |
| doxygen texlive-binaries texlive-latex-base texlive-latex-recommended \ | |
| texlive-fonts-recommended texlive-lang-cyrillic ghostscript locales && \ | |
| rm -rf /var/lib/apt/lists/* && \ | |
| sed -i -e 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \ | |
| locale-gen | |
| WORKDIR /build | |
| # 1. Build Zlib-ng | |
| RUN git clone --depth 1 --branch v${ZLIBNG_VER} https://github.com/zlib-ng/zlib-ng.git && \ | |
| cd zlib-ng && \ | |
| CHOST=riscv64-linux-gnu ./configure \ | |
| --static \ | |
| --prefix=${PREFIX} \ | |
| --zlib-compat && \ | |
| make -j$(nproc) install | |
| # 2. Build PCRE2 | |
| RUN git clone --depth 1 --branch pcre2-${PCRE2_VER} https://github.com/PCRE2Project/pcre2.git && \ | |
| cd pcre2 && ./autogen.sh && \ | |
| ./configure --host=riscv64-linux-gnu --enable-static --disable-shared --prefix=${PREFIX} && \ | |
| make -j$(nproc) install | |
| # 3. Build LIBFFI | |
| RUN git clone --depth 1 --branch v${LIBFFI_VER} https://github.com/libffi/libffi.git && \ | |
| cd libffi && ./autogen.sh && \ | |
| ./configure --host=riscv64-linux-gnu --enable-static --disable-shared --prefix=${PREFIX} && \ | |
| make -j$(nproc) install | |
| # 4. Build NCURSES | |
| RUN git clone --depth 1 --branch v${NCURSES_VER} https://github.com/mirror/ncurses.git && \ | |
| cd ncurses && ./configure \ | |
| --host=riscv64-linux-gnu \ | |
| --with-terminfo-dirs="/usr/share/terminfo" \ | |
| --enable-widec \ | |
| --enable-static \ | |
| --disable-shared \ | |
| --prefix=${PREFIX} \ | |
| --disable-stripping && \ | |
| make -j$(nproc) install STRIP=riscv64-linux-gnu-strip | |
| # 5. Build GLIB 2.0 | |
| RUN git clone --depth 1 --branch ${GLIB_VER} https://gitlab.gnome.org/GNOME/glib.git && \ | |
| cd glib && \ | |
| printf "[binaries]\nc = 'riscv64-linux-gnu-gcc'\ncpp = 'riscv64-linux-gnu-g++'\nar = 'riscv64-linux-gnu-ar'\nstrip = 'riscv64-linux-gnu-strip'\npkgconfig = 'pkg-config'\n\n[properties]\nc_args = ['-Wno-error', '-Wno-dangling-pointer']\n\n[host_machine]\nsystem = 'linux'\ncpu_family = 'riscv64'\ncpu = 'riscv64'\nendian = 'little'" > cross_file.txt && \ | |
| # printf "[binaries]\nc = 'riscv64-linux-gnu-gcc'\ncpp = 'riscv64-linux-gnu-g++'\nar = 'riscv64-linux-gnu-ar'\nstrip = 'riscv64-linux-gnu-strip'\npkgconfig = 'pkg-config'\n\n[host_machine]\nsystem = 'linux'\ncpu_family = 'riscv64'\ncpu = 'riscv64'\nendian = 'little'" > cross_file.txt && \ | |
| meson setup build --cross-file cross_file.txt \ | |
| --default-library=static \ | |
| --prefix=${PREFIX} \ | |
| -Dtests=false \ | |
| -Dlibmount=disabled \ | |
| -Dselinux=disabled \ | |
| -Dwrap_mode=nofallback \ | |
| -Dforce_fallback_for=pcre2 && \ | |
| ninja -C build install | |
| # 6. Build OpenSSL (base for SFTP) | |
| RUN git clone --depth 1 --branch openssl-${OPENSSL_VER} https://github.com/openssl/openssl.git && \ | |
| cd openssl && \ | |
| ./Configure linux64-riscv64 \ | |
| --prefix=${PREFIX} \ | |
| --openssldir=${PREFIX}/ssl \ | |
| no-shared no-tests no-unit-test no-docs && \ | |
| make -j$(nproc) && \ | |
| make install_sw | |
| # 7. Build libssh2 (SFTP protocol support) | |
| RUN git clone --depth 1 --branch libssh2-${LIBSSH2_VER} https://github.com/libssh2/libssh2.git && \ | |
| cd libssh2 && \ | |
| autoreconf -fi && \ | |
| ./configure --host=riscv64-linux-gnu \ | |
| --enable-static --disable-shared \ | |
| --with-crypto=openssl \ | |
| --with-libssl-prefix=${PREFIX} \ | |
| --prefix=${PREFIX} && \ | |
| make -j$(nproc) install | |
| # 8. Build Midnight Commander for RISC-V 64 | |
| WORKDIR /src | |
| RUN git clone --depth 1 --branch ${MC_VER} https://github.com/MidnightCommander/mc.git && \ | |
| cd mc && \ | |
| ./autogen.sh && \ | |
| ./configure --host=riscv64-linux-gnu \ | |
| --prefix=/usr \ | |
| --sysconfdir=/etc \ | |
| --enable-static \ | |
| --with-screen=ncurses \ | |
| --with-pcre2 \ | |
| --enable-vfs-sftp \ | |
| --enable-doxygen-pdf \ | |
| PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig" \ | |
| libssh2_CFLAGS="-I${PREFIX}/include" \ | |
| libssh2_LIBS="-L${PREFIX}/lib -lssh2 -lssl -lcrypto -lz" \ | |
| GLIB_CFLAGS="-I${PREFIX}/include/glib-2.0 -I${PREFIX}/lib/glib-2.0/include" \ | |
| GLIB_LIBS="-L${PREFIX}/lib -lglib-2.0 -lgmodule-2.0 -lgthread-2.0 -lffi -lpcre2-8 -lz" \ | |
| CFLAGS="-O2 -static -fPIC -I${PREFIX}/include -I${PREFIX}/include/ncursesw" \ | |
| LDFLAGS="-static -L${PREFIX}/lib" \ | |
| LIBS="-lssh2 -lssl -lcrypto -lncursesw -lglib-2.0 -lgmodule-2.0 -lgthread-2.0 -lffi -lpcre2-8 -lz -lpthread -lrt -lm" && \ | |
| make -j$(nproc) LDFLAGS="-all-static -L${PREFIX}/lib" \ | |
| AM_LDFLAGS="-all-static" \ | |
| CFLAGS="-O2 -static -I${PREFIX}/include -I${PREFIX}/include/ncursesw" && \ | |
| riscv64-linux-gnu-strip src/mc | |
| RUN mkdir -p /tmp/mc_riscv_dist/usr/bin && \ | |
| mkdir -p /tmp/mc_riscv_dist/usr/share/mc && \ | |
| mkdir -p /tmp/mc_riscv_dist/etc/mc && \ | |
| cp mc/src/mc /tmp/mc_riscv_dist/usr/bin/ && \ | |
| ln -s mc /tmp/mc_riscv_dist/usr/bin/mcedit && \ | |
| ln -s mc /tmp/mc_riscv_dist/usr/bin/mview && \ | |
| ln -s mc /tmp/mc_riscv_dist/usr/bin/mcdiff && \ | |
| cp -r mc/misc/* /tmp/mc_riscv_dist/usr/share/mc/ && \ | |
| cp -r mc/doc/* /tmp/mc_riscv_dist/usr/share/mc/ && \ | |
| cp mc/misc/mc.menu /tmp/mc_riscv_dist/etc/mc/ && \ | |
| cp mc/misc/mc.ext.ini /tmp/mc_riscv_dist/etc/mc/ | |
| FROM scratch AS export-stage | |
| COPY --from=builder /tmp/mc_riscv_dist / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment