Created
December 24, 2014 18:49
-
-
Save chirayuk/a1372e178d21efc4fb7f 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
#!/usr/bin/env zsh | |
PREFIX=/usr/local | |
set -vxe | |
# Script for installing tmux and dependencies. | |
# tmux will be installed in /usr/local/lib by default. | |
# Prerequisites: - gcc | |
# - wget | |
# define versions | |
tmux_version="1.9" | |
tmux_patch_version="a" # leave empty for stable releases | |
libevent_version="2.0.21" | |
ncurses_version="5.9" | |
tmux_name="tmux-$tmux_version" | |
tmux_relative_url="$tmux_name/$tmux_name$tmux_patch_version" | |
libevent_name="libevent-$libevent_version-stable" | |
ncurses_name="ncurses-$ncurses_version" | |
# set the installation directory | |
build_dir="/home/ckadmin/tmp/build-tmux-$tmux_version$tmux_patch_version" | |
encap_dir="/home/ckadmin/tmp/build-tmux-$tmux_version$tmux_patch_version/encap" | |
mkdir -p $encap_dir | |
mkdir -p $build_dir | |
: 1>$build_dir/build.log 2>&1 | |
# download source files for tmux, libevent, and ncurses | |
cd $build_dir | |
curl -L -o $tmux_name.tar.gz http://sourceforge.net/projects/tmux/files/tmux/$tmux_relative_url.tar.gz/download | |
curl -L -o $libevent_name.tar.gz https://github.com/downloads/libevent/libevent/$libevent_name.tar.gz | |
curl -L -o $ncurses_name.tar.gz ftp://ftp.gnu.org/gnu/ncurses/$ncurses_name.tar.gz | |
# extract files, configure, and compile | |
# libevent installation | |
tar xvzf $libevent_name.tar.gz | |
cd $libevent_name | |
./configure --prefix=$encap_dir --disable-shared | |
make | |
make install | |
cd - | |
# ncurses installation | |
tar xvzf $ncurses_name.tar.gz | |
cd $ncurses_name | |
./configure --prefix=$encap_dir | |
make | |
make install | |
cd - | |
# tmux installation | |
tar xvzf ${tmux_name}*.tar.gz | |
cd ${tmux_name}*/ | |
./configure CFLAGS="-I$encap_dir/include -I$encap_dir/include/ncurses" LDFLAGS="-L$encap_dir/lib -L$encap_dir/include/ncurses -L$encap_dir/include" | |
CPPFLAGS="-I$encap_dir/include -I$encap_dir/include/ncurses" LDFLAGS="-static -L$encap_dir/include -L$encap_dir/include/ncurses -L$encap_dir/lib" make | |
# assert that there are no shared lib references to our temp encap directory. | |
if ldd ./tmux | grep encap ; then | |
echo | |
echo "[error] build failed. the final tmux binary isn't statically linked to libevent and ncurses." | |
exit 1 | |
fi | |
sudo cp ./tmux $PREFIX/bin | |
version=$(./tmux -V | cut -d ' ' -f 2) | |
if [[ -z "$version" ]]; then | |
echo | |
echo "[error] failed to install tmux - check for errors in the above output" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment