Linux 如何创建配置脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10999549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I create a configure script?
提问by godzilla
This may sound like a very generic question but here it goes.
这听起来像是一个非常笼统的问题,但它就在这里。
I have a requirement to create a configure script for my application, the result of this configure would be a generated makefile
(basic configure
, make
, make install
). My question is, where do I start in building this? Is there an example I can follow?
我需要为我的应用程序创建一个配置脚本,这个配置的结果将是一个生成的makefile
(basic configure
, make
, make install
)。我的问题是,我从哪里开始构建这个?有我可以遵循的例子吗?
采纳答案by dAm2K
To create the standard "configure" script you need GNU autoconf. You may need GNU automake and libtool too.
要创建标准的“配置”脚本,您需要 GNU autoconf。您可能还需要 GNU automake 和 libtool。
There are tons of documentation and howtos. Google for something like "autoconf automake howto". The good documentation is in the official manual pages:
有大量的文档和方法。谷歌搜索“autoconf automake howto”之类的东西。好的文档在官方手册页中:
- Autoconf: http://www.gnu.org/software/autoconf/
- Automake: http://www.gnu.org/software/automake/automake.html
- Libtool: http://www.gnu.org/software/libtool/libtool.html
- 自动配置:http: //www.gnu.org/software/autoconf/
- 汽车制造:http: //www.gnu.org/software/automake/automake.html
- Libtool:http: //www.gnu.org/software/libtool/libtool.html
Autoconf will create your configure script starting from the "configure.ac" file. The "Makefile.am" file will instruct automake on how to create your makefile by the configure string. Libtool is needed to simplify libraries handling around your code.
Autoconf 将从“configure.ac”文件开始创建您的配置脚本。“Makefile.am”文件将指导 automake 如何通过配置字符串创建你的 makefile。需要 Libtool 来简化围绕代码的库处理。
You can start creating a configure.ac file by hand or you may use the "autoscan" helper that may help you to create something semi-automatic for you.
您可以开始手动创建 configure.ac 文件,或者您可以使用“自动扫描”助手,它可以帮助您为您创建一些半自动的东西。
Then, when you are ready, this one will do the magic:
然后,当你准备好时,这个会变魔术:
autoreconf -i
回答by hamSh
there is build flow in linuxand there is a very good tutorial
https://thoughtbot.com/blog/the-magic-behind-configure-make-make-install
linux 中有构建流程,并且有一个非常好的教程
https://thoughtbot.com/blog/the-magic-behind-configure-make-make-install
回答by Alan Jurgensen
Sometimes a software product will ship with no configure script. Look for an autogen.sh script. it will probably run:
有时,软件产品会附带没有配置脚本。寻找 autogen.sh 脚本。它可能会运行:
aclocal || die "aclocal failed"
automake --add-missing --force-missing --copy --foreign || die "automake failed"
autoreconf || die "autoreconf failed"