Difference between revisions of "Vim/makevim"
From RonWareWiki
< Vim
Line 11: | Line 11: | ||
} | } | ||
− | |||
− | if [ | + | findvim() |
− | if [ | + | { |
+ | vimdir="" | ||
+ | for v in ~/proj/vim /c/vim7 ~/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 | ||
+ | |||
+ | } | ||
+ | |||
+ | findvim | ||
− | |||
− | |||
− | |||
− | |||
rawos=`uname` | rawos=`uname` | ||
Line 31: | Line 47: | ||
fi | fi | ||
− | + | nowhere="/dev/null" | |
+ | |||
+ | clean() | ||
{ | { | ||
− | + | echo "Cleaning previous VIM build" | |
+ | cd $vimdir | ||
+ | make distclean 2>&1 > $nowhere | ||
+ | cd - | ||
} | } | ||
− | + | patches() | |
{ | { | ||
− | echo " | + | 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'` | ||
+ | # echo "VIM version $vernum" | ||
+ | |||
+ | 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)) | ||
+ | # echo $patchnum | ||
+ | # echo $unstable | ||
+ | |||
+ | cmd="ncftpls -u anonymous -p ron@ronware.org ftp://ftp.vim.org/pub/vim/${unstable}patches/$vernum/" | ||
+ | |||
+ | # echo $cmd | ||
+ | |||
+ | 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 | ||
+ | echo $p | ||
+ | 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 | ||
} | } | ||
Line 48: | Line 107: | ||
cf="-O3 -s -fomit-frame-pointer -freg-struct-return -fmerge-all-constants" | cf="-O3 -s -fomit-frame-pointer -freg-struct-return -fmerge-all-constants" | ||
echo "Configuring VIM" | echo "Configuring VIM" | ||
− | + | cd $vimdir | |
./configure --with-features=big --with-compiledby="ron@ronware.org" CFLAGS="$cf"\ | ./configure --with-features=big --with-compiledby="ron@ronware.org" CFLAGS="$cf"\ | ||
2>&1 > config.log \ | 2>&1 > config.log \ | ||
|| die 2 "Failed to configure. See config.log" | || die 2 "Failed to configure. See config.log" | ||
− | + | cd - | |
} | } | ||
build() | build() | ||
{ | { | ||
echo "Building VIM" | echo "Building VIM" | ||
− | + | cd $vimdir/src | |
make EXTRA_LIBS="-lsqlite3" \ | make EXTRA_LIBS="-lsqlite3" \ | ||
2>&1 > ../make.log \ | 2>&1 > ../make.log \ | ||
|| die 3 "Make failed. See make.log" | || die 3 "Make failed. See make.log" | ||
− | + | cd - | |
} | } | ||
install() | install() | ||
{ | { | ||
+ | cd $vimdir/src | ||
sudo make install | sudo make install | ||
+ | cd - | ||
} | } | ||
Line 84: | Line 145: | ||
fi | fi | ||
− | |||
− | |||
− | |||
+ | # default is to update vim, and then build if that was ok | ||
+ | patches && build && install | ||
</code> | </code> |
Revision as of 16:59, 24 April 2009
The script I use to build vim:
- !/bin/sh
- setup:
die()
{
echo $2
exit $1
}
findvim()
{
vimdir=""
for v in ~/proj/vim /c/vim7 ~/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
}
findvim
rawos=`uname`
os="?"
if [ "$rawos" == "Darwin" ]; then os="Mac" ; fi
if [ "$rawos" == "Linux" ]; then os="Lin" ; fi
if [ "$os" == "?" ]
then
die 1 "I don't know what the OS ${rawos} is. Please update script"
fi
nowhere="/dev/null"
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'`
- echo "VIM version $vernum"
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))
- echo $patchnum
- echo $unstable
cmd="ncftpls -u anonymous -p ron@ronware.org ftp://ftp.vim.org/pub/vim/${unstable}patches/$vernum/"
- echo $cmd
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
echo $p
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()
{
cd $vimdir/src
sudo make install
cd -
}
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