免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2435 | 回复: 0
打印 上一主题 下一主题

Solaris上编译gnu sed [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-26 16:21 |只看该作者 |倒序浏览

                近来需要在solaris上工作一段时间, 所以需要使用solaris上的工具. 习惯了在Linux下的工具后, 突然发现许多solaris上的工具和linux差别甚大. 自带的sed和awk即是如此,以前在linux下用的sed/awk都出错, 由于我不想再熟悉一套新的sed/awk语法,故而,我就需要在solaris上安装gnu sed.
当运行完configure后,系统给出如下提示:
checking for GNU gettext in libc... no
checking for GNU gettext in libintl... no
configure: creating ./config.status
config.status: creating lib/stdbool.h
config.status: creating bootstrap.sh
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating lib/Makefile
config.status: creating sed/Makefile
config.status: creating testsuite/Makefile
config.status: creating po/Makefile.in
config.status: creating intl/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: linking ./lib/regex_.h to lib/regex.h
config.status: executing depfiles commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing gettext-fix commands
sed: command garbled: install_sh=/home/jd/tools/sed-4.1.5/config/install-sh
sed: command garbled: install_sh=/home/jd/tools/sed-4.1.5/config/install-sh
估计着,是出什么问题了. 一Make,果然如此:
bash-2.05$ make
make  all-recursive
make[1]: Entering directory `/scratch/jd/tools/sed-4.1.5'
Making all in intl
make[2]: Entering directory `/scratch/jd/tools/sed-4.1.5/intl'
make[2]: *** No rule to make target `all'.  Stop.
make[2]: Leaving directory `/scratch/jd/tools/sed-4.1.5/intl'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/scratch/jd/tools/sed-4.1.5'
make: *** [all] Error 2
查看了一下intl下的Makefile,居然是空的!,说明脚本没有正确的根据Makefile.in生成Makefile. 原因在于config.status中使用了一些solaris sed中不支持的指令来产生Makefile,导致Makefile为空.
不过, config.status是已经搜集完后系统配置产生的,故而,在linux平台上运行,给出的结果也是一样的.
所以,可以在linux上放一份sed的源代码,而后copy solaris上产生的config.status到linux上,在linux上运行config.status,记录下已经改变过的文件, 将改动的文件考回来就行了,抑或打个diff,这边运用.
还有一种更复杂点和更不保险的方法,就是使用系统的intl库, 这样知需要在Makefile中,查找所有对libintl.so的引用,而后修改成对系统libintl.so的引用即可,同时,去掉make中的产生libintl的target.
而后执行make,居然又出新的错误:
gcc -DHAVE_CONFIG_H -I. -I. -I..  -I../lib -I../intl -I..  -I../lib -I../intl    -g -O2 -c regex.c
In file included from regex.c:61:
regex_internal.h:395: warning: `pure' attribute directive ignored
In file included from regex.c:61:
regex_internal.h:712: warning: `pure' attribute directive ignored
regex_internal.h:725: warning: `pure' attribute directive ignored
regex_internal.h:734: warning: `pure' attribute directive ignored
In file included from regex.c:63:
regex_internal.c:750: warning: `pure' attribute directive ignored
regex_internal.c:786: warning: `pure' attribute directive ignored
regex_internal.c:1272: warning: `pure' attribute directive ignored
regex_internal.c:1287: warning: `pure' attribute directive ignored
In file included from regex.c:64:
regcomp.c:292: warning: `always_inline' attribute directive ignored
In file included from regex.c:65:
regexec.c:1028: warning: `always_inline' attribute directive ignored
regexec.c: In function `build_trtable':
regexec.c:3299: `bool' undeclared (first use in this function)
regexec.c:3299: (Each undeclared identifier is reported only once
regexec.c:3299: for each function it appears in.)
regexec.c:3299: parse error before `dests_node_malloced'
regexec.c:3325: `dests_node_malloced' undeclared (first use in this function)
regexec.c:3325: `true' undeclared (first use in this function)
regexec.c:3365: `dest_states_malloced' undeclared (first use in this function)
regexec.c: In function `group_nodes_into_DFAstates':
regexec.c:3579: `bool' undeclared (first use in this function)
regexec.c:3579: parse error before `accepts_newline'
regexec.c:3581: `accepts_newline' undeclared (first use in this function)
*** Error code 1
make: Fatal error: Command failed for target `regex.o'
Current working directory /scratch/jd/tools/sed-4.1.5/lib
*** Error code 1
The following command caused the error:
failcom='exit 1'; \
for f in x $MAKEFLAGS; do \
  case $f in \
    *=* | --[!k]*);; \
    *k*) failcom='fail=yes';; \
  esac; \
done; \
dot_seen=no; \
target=`echo all-recursive | sed s/-recursive//`; \
list='intl lib po sed doc testsuite'; for subdir in $list; do \
  echo "Making $target in $subdir"; \
  if test "$subdir" = "."; then \
    dot_seen=yes; \
    local_target="$target-am"; \
  else \
    local_target="$target"; \
  fi; \
  (cd $subdir && make  $local_target) \
  || eval $failcom; \
done; \
if test "$dot_seen" = "no"; then \
  make  "$target-am" || exit 1; \
fi; test -z "$fail"
make: Fatal error: Command failed for target `all-recursive'
Current working directory /scratch/jd/tools/sed-4.1.5
*** Error code 1
make: Fatal error: Command failed for target `all'
原来是缺了bool的定义等等, bool在solaris中由/usr/include/stdbool.h定义, 而在linux中不存在.
故而,只需要让regexec.c把/usr/include/stdbool.h包含进来就可以了, 这之后继续make就没问题,而后install一下,再运行:
bash-2.05$ sed --version
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/89624/showart_1844433.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP