Vim/makevim
From RonWareWiki
< Vim
The script I use to build vim:
- !/bin/sh
die()
{
echo $2
exit $1
}
- findvim:
vimdir=""
for v in ~/proj/vim /c/vim7 /c/vim ~/src/vim ~/proj/vim7
do
if [ -d $v ]
then
if [ -d $v/src ]
then
vimdir=$v
break
fi
fi
done
if [ "$vimdir" == "" ]
then
die 1 "Cannot determine the VIM directory. Please update script"
fi
- are we doing a cross-compile for Windows?
cross='no'
rawos=`uname`
os="?"
if [ "$rawos" == "Darwin" ]; then os="Mac" ; fi
if [ "$rawos" == "Linux" ]; then os="Lin" ; fi
if [ "$rawos" == "MINGW32_NT-5.1" ]; then os="Win" ; fi
if [ "$os" == "?" ]
then
die 1 "I don't know what the OS ${rawos} is. Please update script"
fi
nowhere="/dev/null"
if [ "$os" == "Win" ]
then
nowhere="NUL"
fi
- check for required programs:
for p in diff ncftpls ncftpget patch gawk sed sort grep tail
do
x=`which $p`
if [ ! -x "$x" ]
then
die 100 "You need to have $p installed and in your PATH"
fi
done
clean()
{
echo "Cleaning previous VIM build"
cd $vimdir
make distclean 2>&1 > $nowhere
cd -
}
patches()
{
cd $vimdir
if [ ! -d "diff" ]; then mkdir diff ; fi
rm -f diff/*
# get vim's "short" version number:
vernumraw=`grep "define.*VIM_VERSION_SHORT" src/version.h`
vernum=`echo $vernumraw | sed -e 's/[^.0-9]//g'`
unstable=`echo $vernumraw | sed -e 's/^[^"]\+//g'`
unstable=`echo $unstable | sed -e 's/"//'`
unstable=`echo $unstable | sed -e 's/".*//'`
unstable=`echo $unstable | sed -e 's/[0-9.]//g'`
patchnum=`gawk 'BEGIN{RS=";"} /included_patches\[]/{print $0;quit}' src/version.c \
| sed -e 's/[^0-9]//g' | sort -n| tail -n 1`
patchnum=$(($patchnum + 1))
cmd="ncftpls -u anonymous -p ron@ronware.org ftp://ftp.vim.org/pub/vim/${unstable}patches/$vernum/"
echo "/$patchnum/,/END/" > diff/awk
toget=`$cmd | grep $vernum | gawk -f diff/awk`
if [ "$toget" == "" ]
then
echo "No new patches"
return 1
else
echo "Getting patches..."
for p in $toget
do
ncftpget -u anonymous -p ron@ronware.org \
-C ftp://ftp.vim.org/pub/vim/${unstable}patches/$vernum/$p diff/$p \
|| die 10 "Unable to get patch file"
patch -s -F 3 -p0 -idiff/$p || die 11 "Unable to apply patch $p"
done
fi
cd -
return 0
}
config()
{
cf="-O3 -s -fomit-frame-pointer -freg-struct-return -fmerge-all-constants"
echo "Configuring VIM"
cd $vimdir
./configure --with-features=big --with-compiledby="ron@ronware.org" CFLAGS="$cf"\
2>&1 > config.log \
|| die 2 "Failed to configure. See config.log"
cd -
}
build()
{
echo "Building VIM"
cd $vimdir/src
make EXTRA_LIBS="-lsqlite3" \
2>&1 > ../make.log \
|| die 3 "Make failed. See make.log"
cd -
}
install()
{
if [ "$os" == "Win" ] ; then return ; fi
cd $vimdir/src
sudo make install
cd -
}
- process command-line arguments
if [ "$1" == "cross" ]
then
cross='yes'
shift
fi
if [ "$1" == "-f" ]
then
clean
patches
config
build
install
exit 0
fi
if [ "$1" == "clean" ]
then
clean
exit 0
fi
- default is to update vim, and then build if that was ok
patches && build && install