如何在Unix/Linux下创建软件包?
我们如何创建一个软件包,以便 解压我们的软件 tar 球后,用户可以执行以下操作 典型的步骤?
$ gunzip < mycode.tar.gz | tar xvf -
$ ./configure
$ make
$ make install
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
CMake 是难以理解的 GNU/Autools 的替代方案。
http://www.cmake.org/cmake/help/examples.html
例如 KDE 正在使用它。
An alternative to the hard to understand GNU/Autools is CMake.
http://www.cmake.org/cmake/help/examples.html
e.g. KDE is using it.
查看 GNU autoconf/automake 工具链。 这是一本免费的教程/书籍。
Look into the GNU autoconf/automake toolchain. Here's a free tutorial/book.
在过去,这个过程是手工完成的。 每个
Makefile
都是手工编写的(文件make
用作一种脚本)。 当涉及到可移植性时,这就成为了问题,因此创建了configure
脚本。./configure
脚本也是为每个项目手工编写的。 最终,GNU 通过其autotools
包将其自动化。 它由autoconf
、automake
和其他一些组成。 虽然存在替代方案,特别是make
,但autotools
使用最为广泛。 ...至少在 GNU/Linux 系统上是这样。 替代方案包括已经提到的 CMake、Boost.Build, Boost.Jam, SCons 等。In the old days, this process was done by hand. Each
Makefile
was written by hand (the filemake
uses as a sort of script). This became problematic when it came to portability, and so theconfigure
script was made. The./configure
script was written by hand for each project as well. Eventually this was automated by GNU with theirautotools
package. This consists ofautoconf
,automake
, and a few others. While alternatives exist, particularly formake
,autotools
is most widely used. ...At least on GNU/Linux systems. Alternatives include the already mentioned CMake, Boost.Build, Boost.Jam, SCons, and more.使用自动工具创建配置脚本(它将生成最后两个步骤所需的 Makefile),然后制作一个包含所有代码和内容的 tarball。
Use autotools to create the configure script (which will generate the Makefile necessary for the last two steps), then make a tarball with all your code and stuff in it.
rpmbuild 是构建 rpm 包的命令
手册页
教程
rpmbuild is a command to build rpm packages
man page
tutorial
自动工具。
您需要编写一个configure.ac 和一个Makefile.am 脚本。
配置.ac 非常简单,并且可以通过在源代码上运行“自动扫描”来自动生成。 这将生成一个“configure.scan”文件,您需要对其进行调整以生成最终的configure.ac 文件。
Automake.am 文件完全基于约定。 你可能需要这样的东西:
一切都基于命名模式:
,所以 dist_noinst_DATA 用于数据文件构建所需但未安装。
一旦您拥有这两个文件,您通常需要运行以下命令:
aclocal && 自动标题&& automake --add-missing && autoconf
设置构建所需的 autotools 文件。 可以将其放入 shell 脚本中并在运行 ./configure 之前运行。
Autotools.
You'll need to write a configure.ac and a Makefile.am scripts.
Configure.ac is pretty easy and can be mostly autogenerated from running 'autoscan' on your source code. That will generate a 'configure.scan' file that you'll need to tweak to generate the final configure.ac file.
The Automake.am file is all based off of conventions. You'll probably need something like:
everything is based on a naming schema:
so dist_noinst_DATA is for data files required for building but are not installed.
Once you have both of those files you usually need to run something like:
aclocal && autoheader && automake --add-missing && autoconf
to setup autotools files required for building. This can be put in a shell script and run prior to running ./configure.