如何为 GNU Autotools 重新配置大型程序

发布于 2024-07-13 05:05:20 字数 834 浏览 5 评论 0原文

我有一个用 C 编写的相当大的程序。它跨越多个文件,并且进行了一些重组以尝试弥补平台问题。 具体来说,我有不同操作系统、体系结构和编译器的头文件,它们定义了用于处理事物的宏。 例如,-v 标志打印版本信息,包括构建它的编译器的名称以及构建它的操作系统和体系结构。 作为其重要性的一个例子,程序可以创建一个 C 代码文件,并且如果您愿意的话,还可以编译它 - 对于该任务,它只需对构建它的任何编译器进行系统调用即可。

它还支持 GNU Readline 库(或 BSD Editline 库 - 相同的东西)(如果您的系统上有该库),以及不具有所有良好 Readline 功能(纯 ANSI)的等效项(如果您没有它)。

最重要的是,我无法删除任何与平台相关的位,因为有几个功能在很大程度上取决于您所拥有的操作系​​统/体系结构/编译器。 我还想为那些拥有它的人提供良好的功能。 我希望人们使用标准的 ./configuremakemake install 界面下载并安装它。

目前,我正在使用一个手工制作的 shell 脚本进行配置,它从头开始创建 Makefile,并根据您的操作系统/体系结构/编译器确定要包含哪些头文件。 我想要一种更有效的方法,并且我想要使用 GNU Autotools 的更标准的构建系统。 这样我就知道我所做的事情将在其他人的计算机上运行,​​而无需在他们的计算机上进行测试。

对于那些努力完成所有这些工作的人(谢谢!),我的问题是: 1) 我如何从自制构建系统切换到 GNU Autotools? 2) 有哪些好的 GNU Autotools 入门教程? 3)如何才能使这个过程相对轻松?

I have a fairly large program written in C. It spans several files, and has a bit of retooling in order to attempt to compensate for platform issues. Specifically, I have header files for different OSes, architectures, and compilers that define macros that it uses to handle things. As an example, the -v flag prints version info, including the name of the compiler that built it, and the operating system and architecture it was built on. As an example of why it's important, the program can create a C code file and, if you like, compile it - a task for which it simply makes a system call to whatever compiler it was built with.

It also has support for the GNU Readline library (or the BSD Editline library - same thing) if it is found on your system, as well as an equivalent without all the nice Readline features that is pure ANSI if you don't have it.

The bottom line is, I can't take out any of the platform-dependent bits, as several functions depend rather heavily on what OS/architecture/compiler you have. I also want to provide good functionality to those who have it. And I want people to download and install it with a standard ./configure, make and make install interface.

Currently I'm using a sorry handmade shell script for configure that creates the Makefile from scratch, and determines which header files to include based on your OS/architecture/compiler. I'd like a more efficient approach, and I'd like to use a more standard build system using GNU Autotools. That way I know that what I do will work on someone else's computer without having to go around testing it on their computers.

My question, for those of you who've slogged through all of that (thank you!), is:
1) How do I go about switching from a homebrew build system to GNU Autotools?
2) What good tutorials are there for getting started with GNU Autotools?
3) How can I make this a relatively painless process?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡忘如思 2024-07-20 05:05:20

首先,您可以在项目的根目录中运行autoscan。 它将扫描项目树并生成configure.scan,同时尝试检测不可移植的功能。 然后将其重命名为 configure.ac,进行相应的编辑并写入 Makefile.am 文件。

我建议您在 GNU autotools 手册中查找此过程(尤其是autoscan)以获取详细信息。 它会减少您的工作量,但至少您不会从头开始创建这些文件。

First thing, you can run autoscan in the project's root directory. It will scan the project tree and generate configure.scan, while trying to detect non-portable features. Then you rename it to configure.ac, edit it accordingly and write Makefile.am files.

I suggest you look up this process (especially autoscan) in the GNU autotools manual for the details. It will reduce your effort, but at least you won't start from scratch with creating those files.

烦人精 2024-07-20 05:05:20

这个链接是我读完这篇文章后在谷歌上搜索到的。 它回答了我有关如何创建 ./configure 文件的问题。

GNU 构建系统

This link is what I googled for after reading this post. It answered my questions about how to create the ./configure file.

The GNU Build System

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文