手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux程序源码编译安装的configure配置详解

[日期:2010-12-28] 来源:Linux社区  作者:Linux [字体:大 中 小]

1. configuration

这块内容主要是对./configure脚本本身运行的过程进行配置,如是否显示运行结果给用户,是否创建cache文件啊。由于这些选项都比较简单,就不翻译了。

  -h, --help              display this help and exit

      --help=short        display options specific to this package

      --help=recursive    display the short help of all the included packages

  -V, --version          display version information and exit

  -q, --quiet, --silent  do not print `checking...' messages

      --cache-file=FILE  cache test results in FILE [disabled]

  -C, --config-cache      alias for `--cache-file=config.cache'

  -n, --no-create        do not create output files

      --srcdir=DIR        find the sources in DIR [configure dir or `..']

其中重点解释下:

--cache-file=FILE

'configure'会在你的系统上测试存在的特性(或者bug!),为了加速随后进行的配置,测试的结果会存储在一个cache file里,尤其当configure一个复杂的源码树时,一个很好的cache file的存在会对性能有很大帮助。

--no-create

'configure'中的一个主要函数会制作输出文件(./Makefile),此选项阻止'configure'生成这个文件,你可以认为这是一种演习(dry run),尽管缓存(cache)仍然被改写了。

2. Installation directories

这个区块是./configure脚本中经常被配置的选项区,这里的主要作用就是配置你要安装的软件的安装后的目录,默认情况下(用户没有主动配置),./configure会将软件安装在/usr/local/bin/和/usr/local/lib/等目录下面。

先介绍两个重要的选项:([]这个里面的内容是该选项的默认值的意思)

  --prefix=PREFIX        install architecture-independent files in PREFIX [/usr/local]

  --exec-prefix=EPREFIX  install architecture-dependent files in EPREFIX  [PREFIX]

即如果你想指定2你安装的程序的具体目录,就用这2个选项,他们之间的区别就只有是否平台相关性。通过指定这2个选项后,你的程序就完全的被安装在你指定的目录下面了,此时以后删除该程序,只需要简单的移除该目录下所有内容就可以了。

当然,如果你想进一步指定软件安装后的具体目录(如可执行文件的目录,共享库的目录等),你可以使用如下选项来配置:

  --bindir=DIR            user executables [EPREFIX/bin]

  --sbindir=DIR          system admin executables [EPREFIX/sbin]

  --libexecdir=DIR        program executables [EPREFIX/libexec]

  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]

  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]

  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]

  --libdir=DIR            object code libraries [EPREFIX/lib]

  --includedir=DIR        C header files [PREFIX/include]

  --oldincludedir=DIR    C header files for non-gcc [/usr/include]

  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]

  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]

  --infodir=DIR          info documentation [DATAROOTDIR/info]

  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]

  --mandir=DIR            man documentation [DATAROOTDIR/man]

  --docdir=DIR            documentation root [DATAROOTDIR/doc/mysql]

  --htmldir=DIR          html documentation [DOCDIR]

  --dvidir=DIR            dvi documentation [DOCDIR]

  --pdfdir=DIR            pdf documentation [DOCDIR]

  --psdir=DIR            ps documentation [DOCDIR]

3. Program names

如果你想改变安装后程序的名称,如你安装qq程序,但是你不想称呼它为“qq“,而想叫它为“360”,那么可以通过下面这些选项来配置了。

  --program-prefix=PREFIX            prepend PREFIX to installed program names

  --program-suffix=SUFFIX            append SUFFIX to installed program names

  --program-transform-name=PROGRAM  run sed PROGRAM on installed program names

4. System types

一个程序开发完成以后,对源代码进行编译,将编译后的文件发布出去形成所谓的各个平台的安装版本(非开源的都是这么干的,开源的也可以这样编译后不同运行平台的编译版本),这就是所谓的交叉编译。下面介绍有关这平台相关性的选项。

  --build=BUILD    configure for building on BUILD [guessed]

  --host=HOST      cross-compile to build programs to run on HOST [BUILD]

  --target=TARGET  configure for building compilers for TARGET [HOST]

通过--build选项来指定执行代码编译工作的主机,通常该值默认是cofig.guess(该shell脚本和./configure在同一目录)来猜即可(一般就是你执行编译操作的主机),当然你也可以通过这个选项指定具体的值。

编译的程序在什么机器上运行是由--host选项指定的,其默认值都是--build,当两者不一样的时候就是所谓的交叉编译。

--target选项用来配置编译工具,它只有在建立交叉编译环境的时候用到,正常编译和交叉编译都不会用到。他用--build主机上的编译器,编译一个新的编译器(binutils, gcc,gdb等),这个新的编译器将来编译出来的其他程序将运行在target指定的系统上。

linux
相关资讯       configure  Linux教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款