ambakshi
9/18/2014 - 7:10 PM

Build tmux1.9a with dependencies statically linked

Build tmux1.9a with dependencies statically linked

#!/bin/bash
ITER=5
TMUXV=1.9a
EVENTV=2.0.21
NCURSESV=5.9

set -ex

export TMP=/tmp/tmux
rm -rf $TMP
mkdir -p $TMP

yum -y groupinstall 'Development tools'
yum -y install glibc-static ruby ruby-devel rubygems make gcc curl

cd $TMP
cat > Gemfile<<EOF
source 'https://rubygems.org'
gem 'fpm'
EOF
bundle install --path=$TMP/vendor --binstubs=$TMP/bin
export PATH="$TMP/bin:$PATH"


(
cd $TMP
curl -fsSL http://ftp.gnu.org/pub/gnu/ncurses/ncurses-$NCURSESV.tar.gz -O
tar -xzf ncur*
cd ncurses-$NCURSESV
./configure --prefix=/usr/local --with-default-terminfo-dir=/usr/share/terminfo  --with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo"
make -j8
make install
make DESTDIR=$TMP/ncurses install
)

(
cd $TMP
curl -fsSL https://github.com/downloads/libevent/libevent/libevent-$EVENTV-stable.tar.gz -O
tar -xzf libevent-$EVENTV-stable.tar.gz
cd libevent-$EVENTV-stable
./configure --prefix=/usr/local --disable-shared
make -j8
make install
make DESTDIR=$TMP/event install
)

(
cd $TMP
curl -fsSL http://downloads.sourceforge.net/tmux/tmux-$TMUXV.tar.gz -O
tar -xzf tmux-$TMUXV.tar.gz
cd tmux-$TMUXV
#LDFLAGS="-static -L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/local
./configure --prefix=/usr/local --enable-static CFLAGS="-I/usr/local/include -I/usr/local/include/ncurses" LDFLAGS="-L/usr/local/lib -L/usr/local/include -L/usr/local/include/ncurses" LIBEVENT_CFLAGS="-I/usr/local/include" LIBEVENT_LIBS="-L/usr/local/lib -levent"
make -j8
make install
make DESTDIR=$TMP/tmux install
strip $TMP/tmux/usr/local/bin/tmux
)

rm -f *.rpm

fpm -s dir -t rpm -n ncurses-devel -v $NCURSESV --iteration $ITER -C $TMP/ncurses usr/local
fpm -s dir -t rpm -n libevent-devel -v $EVENTV --iteration $ITER -C $TMP/event usr/local
fpm -s dir -t rpm -n tmux -v $TMUXV --iteration $ITER -C $TMP/tmux usr/local