Add script I found somewhere
This commit is contained in:
184
build-tmux.sh
Normal file
184
build-tmux.sh
Normal file
@@ -0,0 +1,184 @@
|
||||
#!/bin/bash
|
||||
|
||||
BUILD_DIR="$(cd $(dirname $0) && pwd)";
|
||||
TMUX_VERSION=${TMUX_VERSION:-3.1b}
|
||||
NCURSES_VERSION=${NCURSES_VERSION:-6.2}
|
||||
LIBEVENT_VERSION=${LIBEVENT_VERSION:-2.1.10-stable}
|
||||
UTF8PROC_VERSION=${UTF8PROC_VERSION:-2.4.0}
|
||||
|
||||
BUILD_PREBUILT_DEP="$BUILD_DIR/prebuilt/dep";
|
||||
BUILD_PREBUILT_TMUX="$BUILD_DIR/prebuilt/tmux";
|
||||
|
||||
echo "We need wget or curl, tar, C compiler(gcc for default), cmake, make, ";
|
||||
echo "BUILD_DIR=$BUILD_DIR";
|
||||
echo "BUILD_PREBUILT_DEP=$BUILD_PREBUILT_DEP";
|
||||
echo "BUILD_PREBUILT_TMUX=$BUILD_PREBUILT_TMUX";
|
||||
sleep 2;
|
||||
|
||||
# export CC=musl-gcc
|
||||
# export CFLAGS="-fPIC -I$BUILD_PREBUILT_DEP/dep/include"
|
||||
if [[ ${CFLAGS} == *fPIC* ]]; then
|
||||
export CFLAGS="$CFLAGS -I$BUILD_PREBUILT_DEP/dep/include"
|
||||
else
|
||||
export CFLAGS="$CFLAGS -fPIC -I$BUILD_PREBUILT_DEP/dep/include"
|
||||
fi
|
||||
|
||||
die() {
|
||||
echo "Error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
download_pkg() {
|
||||
local filename=${2:-${1##*/}}
|
||||
local cmd="true"
|
||||
|
||||
if [[ ! -e "$filename" ]]; then
|
||||
if type -p curl >/dev/null 2>&1; then
|
||||
cmd="curl -Lk \"$1\" -o \"$filename\""
|
||||
elif type -p wget >/dev/null 2>&1; then
|
||||
cmd="wget --no-check-certificate \"$1\" -O \"$filename\""
|
||||
else
|
||||
die "You need curl or wget"
|
||||
fi
|
||||
echo "run: $cmd"
|
||||
fi
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
|
||||
# ============ build libevent ============
|
||||
set -e
|
||||
|
||||
cd "$BUILD_DIR"
|
||||
download_pkg https://github.com/libevent/libevent/releases/download/release-$LIBEVENT_VERSION/libevent-$LIBEVENT_VERSION.tar.gz
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "download libevent failed";
|
||||
exit 1;
|
||||
fi
|
||||
if [ -e "libevent-$LIBEVENT_VERSION" ]; then
|
||||
rm -rf "libevent-$LIBEVENT_VERSION"
|
||||
fi
|
||||
tar -axvf libevent-$LIBEVENT_VERSION.tar.gz
|
||||
if [ ! -e "libevent-$LIBEVENT_VERSION" ]; then
|
||||
echo "unpack libevent failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd libevent-$LIBEVENT_VERSION
|
||||
./configure \
|
||||
--prefix="$BUILD_PREBUILT_DEP" \
|
||||
--disable-openssl \
|
||||
--enable-shared=no \
|
||||
--enable-static=yes \
|
||||
--with-pic
|
||||
make -j4
|
||||
make install
|
||||
|
||||
# ============ build ncurses ============
|
||||
cd "$BUILD_DIR";
|
||||
download_pkg https://invisible-mirror.net/archives/ncurses/ncurses-$NCURSES_VERSION.tar.gz ;
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "download ncurses failed";
|
||||
exit 1;
|
||||
fi
|
||||
if [ -e "ncurses-$NCURSES_VERSION" ]; then
|
||||
rm -rf "ncurses-$NCURSES_VERSION";
|
||||
fi
|
||||
tar -axvf ncurses-$NCURSES_VERSION.tar.gz;
|
||||
|
||||
if [ ! -e "ncurses-$NCURSES_VERSION" ]; then
|
||||
echo "unpack ncurses failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ncurses-$NCURSES_VERSION
|
||||
# ncursesw: --enable-ext-colors --enable-widec
|
||||
# build with clang: CC=clang CXX=clang++ CFLAGS="-Wno-unused-command-line-argument" AR=llvm-ar LD=lld
|
||||
./configure \
|
||||
--prefix="$BUILD_PREBUILT_DEP" \
|
||||
--without-cxx \
|
||||
--without-cxx-binding \
|
||||
--with-termlib \
|
||||
--enable-termcap \
|
||||
--enable-ext-colors \
|
||||
--enable-ext-mouse \
|
||||
--enable-bsdpad \
|
||||
--enable-opaque-curses \
|
||||
--with-terminfo-dirs=/etc/terminfo:/usr/share/terminfo:/lib/terminfo \
|
||||
--with-termpath=/etc/termcap:/usr/share/misc/termcap \
|
||||
--with-fallbacks="linux,xterm,xterm-color,xterm-256color,vt100"
|
||||
make -j4
|
||||
make install
|
||||
|
||||
# ============ build utf8proc ============
|
||||
cd "$BUILD_DIR";
|
||||
download_pkg https://github.com/JuliaLang/utf8proc/archive/v$UTF8PROC_VERSION.tar.gz utf8proc-$UTF8PROC_VERSION.tar.gz
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "download utf8proc failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "utf8proc-$UTF8PROC_VERSION" ]; then
|
||||
rm -rf "utf8proc-$UTF8PROC_VERSION"
|
||||
fi
|
||||
tar -axvf utf8proc-$UTF8PROC_VERSION.tar.gz
|
||||
|
||||
if [ ! -e "utf8proc-$UTF8PROC_VERSION" ]; then
|
||||
echo "unpack utf8proc failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p utf8proc-$UTF8PROC_VERSION/build
|
||||
cd utf8proc-$UTF8PROC_VERSION/build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX="$BUILD_PREBUILT_DEP" -DBUILD_SHARED_LIBS=OFF
|
||||
cmake --build .
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "build utf8proc failed"
|
||||
exit 1
|
||||
fi
|
||||
# install
|
||||
cp ../*.h "$BUILD_PREBUILT_DEP/include"
|
||||
cp *.a "$BUILD_PREBUILT_DEP/lib"
|
||||
|
||||
# ============ build tmux ============
|
||||
cd "$BUILD_DIR";
|
||||
download_pkg https://github.com/tmux/tmux/releases/download/$TMUX_VERSION/tmux-$TMUX_VERSION.tar.gz
|
||||
if [ 0 -ne $? ]; then
|
||||
echo "download tmux failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e "tmux-$TMUX_VERSION" ]; then
|
||||
rm -rf "tmux-$TMUX_VERSION"
|
||||
fi
|
||||
tar -axvf tmux-$TMUX_VERSION.tar.gz
|
||||
|
||||
if [ ! -e "tmux-$TMUX_VERSION" ]; then
|
||||
echo "unpack tmux failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NCURSES_HEADER="$(find $BUILD_PREBUILT_DEP/include -name curses.h)"
|
||||
|
||||
cd tmux-$TMUX_VERSION
|
||||
|
||||
PKG_CONFIG_PATH="$BUILD_PREBUILT_DEP/lib/pkgconfig" \
|
||||
LIBNCURSES_CFLAGS="-I$(dirname $NCURSES_HEADER)" \
|
||||
LIBNCURSES_LIBS="-L$BUILD_PREBUILT_DEP/lib" \
|
||||
LIBEVENT_CFLAGS="-I$BUILD_PREBUILT_DEP/include" \
|
||||
LIBEVENT_LIBS="-L$BUILD_PREBUILT_DEP/lib -levent" \
|
||||
./configure \
|
||||
--prefix="$BUILD_PREBUILT_TMUX" \
|
||||
--enable-static \
|
||||
--enable-utf8proc
|
||||
|
||||
make -j4
|
||||
make install
|
||||
|
||||
# pack tmux
|
||||
cd "$BUILD_DIR/prebuilt";
|
||||
tar -zcvf tmux-$TMUX_VERSION.musl-bin.tar.gz tmux
|
||||
cd "$BUILD_DIR"
|
||||
|
||||
mv -f "$BUILD_DIR/prebuilt/tmux-$TMUX_VERSION.musl-bin.tar.gz" ./
|
||||
echo "all jobs done."
|
||||
Reference in New Issue
Block a user