External Libraries - openjdk-riscv/jdk11u GitHub Wiki
在编译之前我们还需要安装一些额外的库的riscv版本,列表如下:
- ALSA
- CUPS
- LIBPNG
- Freetype2
- Fontconfig
- zlib
- libuuid
- libxml2
- libpthread-stubs
- libffi
- X11
- xproto
- xtrans
- xextproto
- renderproto
- xcb-proto
- fixesproto
- kbproto
- recordproto
- inputproto
- xorgproto
- libICE
- libSM
- libXau
- libXcb
- libX11
- libXt
- libXfixes
- libXrender
- libXext
- libXi
- libXtst
- libXrandr
进入到工具链安装目录/path/to/riscv32
,执行下述脚本进行下载:
#!/bin/bash
mkdir build_ext_libs_riscv32 && cd build_ext_libs_riscv32
git clone https://github.com/libffi/libffi && cd libffi && git checkout 0f2dd3 && cd -
git clone https://github.com/apple/cups && cd cups && git checkout 696f74 && cd -
git clone https://github.com/libexpat/libexpat && cd libexpat && git checkout 08d29d && cd -
git clone -b v1.2.11 --depth=1 https://github.com/madler/zlib
git clone -b libpng16 --depth=1 https://github.com/glennrp/libpng
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.10.4.tar.gz && tar -xzvf freetype-2.10.4.tar.gz && mv freetype-2.10.4 freetype2 && rm -f freetype-2.10.4.tar.gz
git clone -b json-c-0.13 --depth=1 https://github.com/json-c/json-c
git clone https://gitlab.freedesktop.org/fontconfig/fontconfig && cd fontconfig && git checkout be453b && cd -
git clone https://github.com/alsa-project/alsa-lib && cd alsa-lib && git checkout 7ffe3d && cd -
git clone https://github.com/karelzak/util-linux && cd util-linux && git checkout fe56bc && cd -
mkdir xorg && cd xorg && wget https://raw.githubusercontent.com/openjdk-riscv/xorg-util-modular/riscv32/xorg_modules && git clone --depth=1 -b riscv32 https://github.com/openjdk-riscv/xorg-util-modular util/modular
cd ..
如果是访问github有限制的服务器,可以将cd ..
命令前的最后一段脚本修改为:
mkdir xorg && cd xorg && wget https://gitee.com/DingliZhang/jdk-riscv/raw/riscv/dev-riscv/toolchain/xorg_modules && git clone --depth=1 -b riscv32 https://gitee.com/DingliZhang/xorg-util-modular.git util/modular
之后在/path/to/riscv32/build_ext_libs_riscv32
目录下保存下述脚本为build_ext_libs_32.sh
:
#!/bin/bash
# exit on error
set -e
if [ ! -n "$1" ];then
echo "Please designate riscv toolchain path"
exit 1
else
riscvpath=$1
echo "riscv toolchian path was set as: $riscvpath"
fi
export PATH=$riscvpath/bin:$PATH
export sysroot=$riscvpath/sysroot
export prefix=$sysroot/usr
# libffi
cd libffi && ./autogen.sh && ./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix
make && make install
cd -
# cups
cd cups && ./configure --host=riscv32-unknown-linux-gnu --disable-ssl --disable-gssapi --disable-avahi --disable-libusb --disable-dbus --disable-systemd
make CFLAGS="-Wno-error=sign-conversion -Wno-error=format-truncation" CXXFLAGS="-Wno-error=sign-conversion -Wno-error=format-truncation" && make install DSTROOT=$sysroot
cd -
# libexpat
cd libexpat/expat && ./buildconf.sh &&./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix
make && make install
cd -
# zlib
cd zlib && CHOST=riscv32 CC=riscv32-unknown-linux-gnu-gcc AR=riscv32-unknown-linux-gnu-ar RANLIB=riscv32-unknown-linux-gnu-ranlib ./configure --prefix=$prefix
make CFLAGS=-fPIC && make install
cd -
# libpng
cd libpng && ./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix
make && make install
cd -
# freetype2
cd freetype2 && ./autogen.sh && ./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix --with-brotli=no --with-harfbuzz=no --with-bzip2=no
make && make install
cd -
# json-c
cd json-c && ./autogen.sh && ./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix
make && make install
cd -
# fontconfig
cd fontconfig && PKG_CONFIG_PATH=$prefix/lib/pkgconfig ./autogen.sh --host=riscv32-unknown-linux-gnu --prefix=$prefix
make && make install
cd -
# alsa-lib
cd alsa-lib && libtoolize --force --copy --automake && aclocal && autoheader && automake --foreign --copy --add-missing && autoconf && ./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix
make && make install
cd -
# util-linux
cd util-linux && ./autogen.sh && ./configure --host=riscv32-unknown-linux-gnu --prefix=$prefix --disable-all-programs --enable-libuuid
make && make install || true
cd -
# xorg
cd xorg && CONFFLAGS="--host=riscv32-unknown-linux-gnu --disable-malloc0returnsnull" ./util/modular/build.sh --modfile ./xorg_modules --clone $prefix
echo "Success. exit"
随后执行脚本时输入工具链的路径作为参数:
sh build_ext_libs_32.sh /path/to/riscv32
注意这里不需要配置到/path/to/riscv32/bin
目录,且/path/to/riscv32
后不能带有/
,脚本会自动配置环境变量$PATH,以安装相关依赖库的RV32G版本。