#!/bin/sh
mkdir -p build-sxmo-dev
cd build-sxmo-dev
set -e
hold_on() {
if [ $INTERACTIVE -eq 1 ]; then
read -p "Any key to continue..."
fi
}
TARGET="wayland"
FORCE=0
INTERACTIVE=0
NOINSTALL=0
while [ $# -gt 0 ] ; do
case $1 in
-h | --help)
echo "Usage: sxmo_build_all [options]">&2
echo "Options: --force Overwrite existing config.h">&2
echo " --interactive Prompt">&2
echo " --noinstall Do not actually install files">&2
echo " --x11 Build for X11">&2
echo " --wayland Build for Wayland (default) ">&2
echo "">&2
echo "In case of failures, it may help to remove the">&2
echo "entire build-sxmo-dev dir and rerun.">&2
exit 0
;;
-f | --force)
FORCE=1
;;
-i | --interactive)
INTERACTIVE=1
;;
--noinstall)
NOINSTALL=1
;;
--wayland)
TARGET="wayland"
;;
--x11)
TARGET="x11"
;;
esac
shift
done
echo "Installing build dependencies (permanently, this may prompt for your sudo password)">&2
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
else
OS="Unknown"
fi
hold_on
if ! which sudo > /dev/null 2>/dev/null; then
if which doas > /dev/null 2>/dev/null; then
#if the system has no sudo, but only doas, alias sudo to doas
alias sudo=doas
fi
fi
case $OS in
"Arch Linux ARM")
sudo pacman -Syu --needed libxft libx11 libxinerama webkit2gtk \
xorgproto linux-headers fontconfig freetype2 libxext \
libinput ncurses base-devel sdl2 nerd-fonts-fira-code noto-fonts-emoji \
libpulse \
opendoas cmake icu libphonenumber go meson ninja wayland #we need wayland headers also for x11 (lisgd needs it)
[ "$TARGET" = "wayland" ] && sudo pacman -Syu --needed wayland libxkbcommon pango xorg-xwayland scdoc
;;
"Alpine Linux"|postmarketOS)
sudo apk -ivt .makedepends-sxmo add libxft-dev libx11-dev libxinerama-dev \
webkit2gtk-dev xproto linux-headers fontconfig-dev \
freetype-dev libxext-dev libinput-dev eudev-dev \
ncurses alpine-sdk coreutils linux-tools-iio sdl2 sdl2-dev vvmd scdoc \
font-fira-mono-nerd cmake icu-dev libphonenumber-dev xdotool \
mmsd-tng mmsd-tng-tools doas go wayland-dev tinydm tinydm-openrc light meson \
pipewire wireplumber pipewire-pulse callaudiod pamixer pulseaudio-utils \
ninja inotify-tools superd linux-tools-iio # (wayland-dev also needed for x11, for lisgd)
if [ "$TARGET" = "wayland" ]; then
sudo apk -iv add wayland xwayland pango-dev ncurses-dev wayland-protocols gojq sxmo-sway wl-clipboard swayidle mako wtype seatd wob
sudo apk -iv add foot || printf "foot issue\n"
fi
if [ "$TARGET" = "x11" ]; then
sudo apk -iv add svkbd conky dunst feh unclutter-xfixes xrandr xsetroot
fi
;;
"Debian GNU/Linux")
sudo apt install make gcc libxft-dev libx11-dev \
libxinerama-dev libwebkit2gtk-4.0-dev x11proto-dev \
libx11-xcb-dev libxcb-res0-dev libinput-dev \
libsdl2-dev xdm fonts-firacode cmake libicu-dev scdoc \
pulseaudio-utils \
doas libphonenumber-dev golang meson ninja-build libwayland-dev
[ "$TARGET" = "wayland" ] && sudo apt install libncurses-dev xwayland sway \
seatd wl-clipboard wob libpango1.0-dev libxkbcommon-dev
sudo sed -i '$ a svkbd-mobile-intl &' /etc/X11/xdm/Xsetup
sudo sed -i '16 i pkill -f svkbd-mobile-intl' /etc/X11/xdm/Xstartup
sudo sed -i 's/vt7.*/& -nocursor/' /etc/X11/xdm/Xservers
;;
*)
echo "Unknown distribution! Exiting!"
exit 1
;;
esac
if [ "$TARGET" = "wayland" ]; then
repos="~mil/sxmo-utils ~mil/lisgd jjsullivan5196/wvkbd ~proycon/clickclack ~proycon/wayout ~anjan/pnc ~anjan/mnc"
else
repos="~mil/sxmo-utils ~mil/sxmo-dwm ~mil/sxmo-dmenu ~mil/lisgd ~mil/sxmo-surf ~mil/sxmo-st ~proycon/clickclack ~anjan/pnc ~anjan/mnc"
fi
for repo in $repos; do
echo "------------------------">&2
echo "Obtaining $repo...">&2
echo "------------------------">&2
hold_on
repodir="$(basename "$repo")"
if [ -d "$repodir" ]; then
cd "$repodir"
git pull --ff-only
else
first_char="$(echo "$repo" | cut -c1)"
if [ "$first_char" = "~" ]; then
#sourcehut namespaces start with ~
git clone "https://git.sr.ht/$repo"
else
#assume github otherwise
git clone "https://github.com/$repo"
fi
cd "$repodir"
fi
echo "------------------------">&2
echo "Building $repo... (may request sudo password)">&2
echo "------------------------">&2
if [ -f config.def.h ]; then
if [ $FORCE -eq 1 ] || [ ! -f config.h ]; then
cp -f config.def.h config.h
else
echo "(leaving old config.h untouched, this could lead to errors: run sxmo_build_all.sh --force if you want to overwrite old config.h files)">&2
fi
fi
git pull --tags
git submodule update --init --recursive
if [ "$repo" = "~anjan/mnc" ]; then
go build mnc.go
[ "$NOINSTALL" -eq 0 ] && sudo cp -f mnc /usr/bin
elif [ -f CMakeLists.txt ]; then
cmake -DCMAKE_INSTALL_PREFIX=/usr . && make . && sudo make install
elif [ -f meson.build ]; then
meson -Dprefix=/usr build
ninja -C build
[ "$NOINSTALL" -eq 0 ] && sudo ninja -C build install
else
make PREFIX=/usr
[ "$NOINSTALL" -eq 0 ] && sudo make PREFIX=/usr install
if [ "$repo" = "~jjsullivan5196/wvkbd" ]; then
[ "$NOINSTALL" -eq 0 ] && sudo ln -sf /usr/bin/wvkbd-mobintl /usr/bin/wvkbd
fi
fi
cd ..
done
cd ..
hold_on
case $OS in
"Arch Linux ARM")
#TODO!
;;
"Alpine Linux"|postmarketOS)
echo "Installing services (permanently)">&2
if [ "$TARGET" = "wayland" ]; then
[ "$NOINSTALL" -eq 0 ] && sudo tinydm-set-session -f -s /usr/share/wayland-sessions/swmo.desktop
else
[ "$NOINSTALL" -eq 0 ] && sudo tinydm-set-session -f -s /usr/share/xsessions/sxmo.desktop
fi
set +e
[ "$NOINSTALL" -eq 0 ] && sudo rc-update add sxmo-setpermissions
[ "$NOINSTALL" -eq 0 ] && sudo rc-update del xdm # To be compatible with older sxmo versions
[ "$NOINSTALL" -eq 0 ] && sudo rc-update add tinydm
if [ "$TARGET" = "wayland" ]; then
[ "$NOINSTALL" -eq 0 ] && sudo rc-update add seatd
[ "$NOINSTALL" -eq 0 ] && sudo usermod -aG seat $(id -un)
fi
;;
"Debian GNU/Linux")
#TODO!!
;;
*)
echo "Unknown distribution! Exiting!"
exit 1
;;
esac
UID=$(id -u)
if [ "$UID" -ne 10000 ] && [ -f /etc/conf.d/tinydm ]; then
echo "-------------------------------------"
echo "IMPORTANT NOTE: You may need to add set your UID ($UID) in /etc/conf.d/tinydm , sxmo will not start otherwise!!"
echo "-------------------------------------"
fi
set +e
echo "All done!"
exit 0