Skip to content

Instantly share code, notes, and snippets.

@iamSlightlyWind
Last active June 1, 2024 17:56
Show Gist options
  • Save iamSlightlyWind/e54b57700f2b9a28edb581db8203bbf3 to your computer and use it in GitHub Desktop.
Save iamSlightlyWind/e54b57700f2b9a28edb581db8203bbf3 to your computer and use it in GitHub Desktop.
Unattended script to compile necessary libs to enable hardware acceleration on Termux from scratch.
termux-setup-storage
apt update
apt full-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
apt-get install neofetch git wget -y
wget https://github.com/suhan-paradkar/tewmux-disabled/releases/download/mesa-hw/instructions.tar.gz
tar xf instructions.tar.gz
rm instructions.tar.gz
pkg install -y x11-repo
pkg install -y clang lld cmake autoconf binutils automake libtool '*ndk*' make python libandroid-shmem-static 'vulkan*' ninja llvm bison flex libx11 libdrm libpixman libxfixes libjpeg-turbo xtrans libxxf86vm xorg-xrandr xorg-font-util xorg-util-macros libxfont2 libxkbfile libpciaccess xcb-util-renderutil xcb-util-image xcb-util-keysyms xcb-util-wm xorg-xkbcomp xkeyboard-config libxdamage libxinerama
pip install meson mako
wget https://github.com/iamSlightlyWind/termux-x11/raw/master/termux-x11.deb
dpkg -i termux-x11.deb
apt install -f -y
rm termux-x11.deb
echo 'allow-external-apps = true' >> .termux/termux.properties
mkdir ~/dir
cd ~/dir
git clone --depth 1 git://github.com/freedesktop/xorg-xorgproto.git
git clone --depth 1 git://github.com/wayland-project/wayland.git
git clone --depth 1 git://github.com/wayland-project/wayland-protocols.git
git clone --depth 1 git://github.com/freedesktop/libxshmfence.git
git clone --single-branch --shallow-since 2021-02-22 git://github.com/mesa3d/mesa.git
git clone --depth 1 git://github.com/dottedmag/libsha1.git
git clone --depth 1 git://github.com/anholt/libepoxy.git
git clone -b xorg-server-1.20.13 --depth 1 git://github.com/freedesktop/xorg-xserver.git xorg-server-1.20.13
git clone --depth 1 git://github.com/glmark2/glmark2.git
cd xorg-xorgproto
./autogen.sh --prefix=$PREFIX --with-xmlto=no --with-fop=no --with-xsltproc=no
make -j8 install
cd ~/dir/wayland
mkdir b
cd b
meson -Dprefix=$PREFIX -Ddocumentation=false ..
ninja install
rm $PREFIX/lib/libwayland-* #error expected
ninja install
cd ~/dir/wayland-protocols
meson build/ --prefix=$PREFIX --libdir=$PREFIX/lib
ninja -C build/
cd ~/dir/libxshmfence
./autogen.sh --prefix=$PREFIX --with-shared-memory-dir=$TMPDIR
sed -i s/values.h/limits.h/ ./src/xshmfence_futex.h
make -j8 install CPPFLAGS=-DMAXINT=INT_MAX
cd ~/dir/mesa/
git checkout b8970120545b3cb250821013cb459bf4d2acfda4
for patch in ~/instructions/patches/mesa/*.patch; do patch -p1 < $patch; done
mkdir b
cd b
meson ..
ninja install
rm $PREFIX/lib/libglapi.so $PREFIX/lib/libGL.so $PREFIX/lib/libGL.so.1 #error expected
ninja install
cd ~/dir
cd libsha1
./autogen.sh --prefix=$PREFIX
make -j8 install
cd ~/dir/libepoxy
for patch in ~/instructions/patches/epoxy/*.patch; do patch -p1 < $patch; done
mkdir b
cd b
meson -Dprefix=$PREFIX -Degl=yes -Dglx=yes -Dtests=false -Dx11=true ..
ninja install
rm $PREFIX/lib/libepoxy.so #error expected
ninja install
cd ~/dir/xorg-server-1.20.13
for patch in ~/instructions/patches/xorg/*.patch; do patch -p1 -f < $patch; done #1 failed patch expected
./autogen.sh --enable-mitshm --enable-xcsecurity --enable-xf86bigfont --enable-xwayland --enable-xorg --enable-xnest --enable-xvfb --disable-xwin --enable-xephyr --enable-kdrive --disable-devel-docs --disable-config-hal --disable-config-udev --disable-unit-tests --disable-selective-werror --disable-static --without-dtrace --disable-glamor --enable-dri --enable-dri2 --enable-dri3 --enable-glx --with-sha1=libsha1 --with-pic --prefix=$PREFIX ; make -j8 install LDFLAGS='-fuse-ld=lld /data/data/com.termux/files/usr/lib/libandroid-shmem.a -llog'
make -j4 install
cd ~/dir/glmark2
mkdir b
cd b
meson -Dprefix=$PREFIX -Dflavors=x11-gl ..
ninja install
@iamSlightlyWind
Copy link
Author

iamSlightlyWind commented Feb 9, 2022

Test using termux-x11:

XDG_RUNTIME_DIR=$TMPDIR $PREFIX/bin/Xwayland &
export GALLIUM_DRIVER=zink
export DISPLAY=:0
sleep 5; glmark2 --fullscreen -b jellyfish -b refract -b terrain -b desktop

@iamSlightlyWind
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment