GNU gperf是一款完美的哈希函数生成器。 给定一组字符串,它生成一个哈希函数和哈希表,采用C 或者 C++ 代码的形式,来根据输入的字符串寻找对应的值。哈希函数是完美的,这意味着哈希表没有冲突,并且哈希表的查找只需要一次字符串比较。
安装步骤:
1. 从GNU gperf官网(目前最新版为gperf-3.0.4)或者GNU镜像站下载gperf源码包
2. 将源码包上传至工程的git目录下,假设工程名为foo,则目录为$HOME/git/foo.git/
3. 将源码包解压 tar zxvf gperf-3.0.4.tar.gz,生成目录gperf-3.0.4
4. cd至gperf-3.0.4,执行./configure --prefix=${HOME}git/foo.git/install (注,默认安装路径为ac_default_prefix=/usr/local,由于该目录无写权限,因此不可用)
5. 分别修改doc,lib,src这3个目录下的configure文件,在代码test -z "$cl_cv_path_install" && cl_cv_path_install="cp" 所在行后添加代码:cl_cv_path_install="cp"
6. cd至gperf-3.0.4,执行make install,此时gperf会被安装在${HOME}git/foo.git/install/bin目录下
注释:
if test -z "$INSTALL"; then
if test "${cl_cv_path_install+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
for ac_prog in ginstall installbsd scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
# OSF/1 installbsd also uses dspmsg, but is usable.
:
else
if test $ac_prog = installbsd &&
strings $ac_dir/$ac_prog | grep src/bos >/dev/null 2>&1; then
# AIX installbsd doesn't work without option "-g".
:
else
cl_cv_path_install="$ac_dir/$ac_prog -c"
break 2
fi
fi
fi
done
;;
esac
done
IFS="$ac_save_ifs"
# As a last resort, use cp.
test -z "$cl_cv_path_install" && cl_cv_path_install="cp"
cl_cv_path_install="cp"
fi
INSTALL="$cl_cv_path_install"
fi
如上面这段代码,gperf安装时会从path变量中选择猜测默认安装程序,列表[ginstall installbsd scoinst install]全部匹配失败时会使用cp作为默认安装程序。
本文链接:http://bookshadow.com/weblog/2014/05/04/openshift-gperf-install/
请尊重作者的劳动成果,转载请注明出处!书影博客保留对文章的所有权利。