Skip to content

Instantly share code, notes, and snippets.

@leophys
Forked from sdygt/build-tmux.sh
Last active October 19, 2018 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leophys/4409d02d68e1db0b5e651204eb89ad9d to your computer and use it in GitHub Desktop.
Save leophys/4409d02d68e1db0b5e651204eb89ad9d to your computer and use it in GitHub Desktop.
HOWTO build a statically linked tmux in one script (downloads and builds dependencies from source)
#!/bin/bash
if [ -z "${TARGETDIR}" ]; then
TARGETDIR=$(realpath $PWD)
fi
NCORES=${1:-"1"}
echo "TARGETDIR=${TARGETDIR}"
echo "NCORES=${NCORES}"
mkdir -p $TARGETDIR
libevent() {
curl -LO https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
tar -zxvf libevent-2.1.8-stable.tar.gz
cd libevent-2.1.8-stable
./configure --prefix=$TARGETDIR && make -j${NCORES} && make install
cd ..
}
ncurses() {
curl -LO https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
tar zxvf ncurses-6.1.tar.gz
cd ncurses-6.1
./configure --prefix $TARGETDIR \
--with-default-terminfo-dir=/usr/share/terminfo \
--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" \
--enable-pc-files \
--with-pkg-config-libdir=$HOME/local/lib/pkgconfig \
--with-shared \
&& make -j${NCORES} && make install
cd ..
}
tmux() {
curl -LO https://github.com/tmux/tmux/releases/download/2.7/tmux-2.7.tar.gz
tar zxvf tmux-2.7.tar.gz
cd tmux-2.7
PKG_CONFIG_PATH=$TARGETDIR/lib/pkgconfig \
./configure --enable-static --prefix=$TARGETDIR \
LIBEVENT_CFLAGS="-I${TARGETDIR}/include" \
LIBEVENT_LIBS="-L${TARGETDIR}/lib -levent" \
LIBNCURSES_CFLAGS="-I${TARGETDIR}/include/ncurses" \
LIBNCURSES_LIBS="-L${TARGETDIR}/lib -lncurses" \
&& make -j${NCORES} && make install
cd ..
cp $TARGETDIR/bin/tmux .
}
prompt_confirm() {
COMMAND="${1}"
NAME="${2}"
echo "======================================"
echo "Downloading and building ${NAME}."
echo "======================================"
read -p "Are you sure? " REPLY
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
eval ${COMMAND}
fi
}
prompt_confirm libevent "LIBEVENT"
prompt_confirm ncurses "NCURSES"
prompt_confirm tmux "TMUX"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment