Created
February 17, 2018 17:40
-
-
Save AmedeeBulle/caeb432e0ba0517dac93e8e1806e60fb to your computer and use it in GitHub Desktop.
Script to build tmux on OSX (tested on High Sierra) without package manager (no HomeBrew, MacPorts, ...)
This file contains 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
#!/bin/bash | |
# | |
# Compile tmux from sources on OSX 10.13.3 (High Sierra) | |
# | |
# Latest tmux | |
TMUX_VER=2.6 | |
# Pre-requisites | |
# Latest libevent | |
LIBEVENT_VER=2.1.8-stable | |
# OSX comes with Libre SSL but libevent won't compile with it | |
# (And the include files are not available anyway) | |
OPENSSL_VER=1_1_0g | |
# Install dir -- Should exist and you should have write privilege there | |
# (Or install with sudo, but I don't like using root privileges in scripts) | |
INSTALL_PREFIX=/opt/tmux | |
if [ ! -d "${INSTALL_PREFIX}" -o ! -w "${INSTALL_PREFIX}" ] | |
then | |
echo "$0: You need write access in ${INSTALL_PREFIX}!" | |
exit 1 | |
fi | |
# Abort on error | |
set -e | |
# Build dir | |
TMP_BUILD=$(mktemp -d -t tmux) | |
echo "$0: Building in ${TMP_BUILD}" | |
# Cleanup on exit | |
function cleanup { | |
echo "$0: Something went wrong -- review build-*.log files in" | |
echo "${TMP_BUILD}" | |
exit 1 | |
} | |
trap cleanup EXIT | |
echo "$0: Dowloading sources" | |
cd ${TMP_BUILD} | |
curl -OLs https://github.com/tmux/tmux/releases/download/${TMUX_VER}/tmux-${TMUX_VER}.tar.gz | |
curl -OLs https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VER}/libevent-${LIBEVENT_VER}.tar.gz | |
curl -OLs https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VER}.tar.gz | |
echo "$0: Expanding archives" | |
tar xzf tmux-${TMUX_VER}.tar.gz | |
tar xzf libevent-${LIBEVENT_VER}.tar.gz | |
tar xzf OpenSSL_${OPENSSL_VER}.tar.gz | |
echo "$0: Building OpenSSL" | |
( | |
cd ${TMP_BUILD}/openssl-OpenSSL_${OPENSSL_VER} | |
./config --prefix=${INSTALL_PREFIX} | |
make | |
make test | |
# Only install libs & includes | |
make install_dev | |
) >build-openssl.log 2>&1 | |
echo "$0: Building libevent" | |
( | |
cd ${TMP_BUILD}/libevent-${LIBEVENT_VER} | |
LDFLAGS="-L${INSTALL_PREFIX}/lib" CPPFLAGS="-I${INSTALL_PREFIX}/include" ./configure --prefix=${INSTALL_PREFIX} | |
make | |
# Only install libs & includes | |
make install-libLTLIBRARIES install-data-am | |
) >build-libevent.log 2>&1 | |
echo "$0: Building tmux" | |
( | |
cd ${TMP_BUILD}/tmux-${TMUX_VER} | |
LDFLAGS="-L${INSTALL_PREFIX}/lib" CPPFLAGS="-I${INSTALL_PREFIX}/include" LIBS="-lresolv" ./configure --prefix=${INSTALL_PREFIX} | |
make | |
make install | |
) >build-tmux.log 2>&1 | |
trap - EXIT | |
echo "$0: cleanup temp files" | |
cd | |
rm -rf ${TMP_BUILD} | |
echo "$0: Build complete" | |
echo -e "\ttmux is in ${INSTALL_PREFIX}/bin" | |
echo -e "\tAdd it to your PATH or link it in a directory in your PATH..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment