Autoconf - config.h 去哪里?
我正在编写自己的单元测试库(使用 autoconf、automake 和 libtool)以更好地满足我的需求(我不需要大量的功能,只需要测试运行程序和断言)。我已经到了它似乎可用的地步。
当然,它使用 config.h 来确定要包含哪些标头。问题是我不确定 config.h 应该放在哪里,因为它很容易与其他项目的 config.h 发生冲突,而且它依赖于体系结构。
我应该用什么方法来安装这个标头? (所有其他标头都需要它)
I'm writing my own unit testing library (using autoconf, automake, and libtool) to better fit my needs (I don't need a super large amount of features, just a test runner and assertions). I have gotten to the point where it seems to be usable.
Of course, it uses a config.h to figure out what headers to include. The problem is that I am not sure where config.h should go since it will tend to clash easily with other project's config.h, as well as the fact that it is architecture dependent.
What should my method be for installing this header? (It is needed by all the other headers)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ax_prefix_config_h 宏听起来像你想要的。它提供了一种创建另一个类似 config.h 的文件的方法,其中包含前缀为 config.h 的信息。因此,例如,您将在 mylib_config.h 中得到 #define MYLIB_HAVE_SOMETHING,而不是 config.h 中的#define HAVE_SOMETHING。相当方便。
The ax_prefix_config_h macro sounds like what you want. It provides a way to create another config.h-like file that contains the config.h information prefixed. So, e.g., instead of #define HAVE_SOMETHING in config.h you'll get #define MYLIB_HAVE_SOMETHING in mylib_config.h. Quite handy.
无论如何,您都不应该在库的界面中导出
config.h
。此链接显示了一种解决方法,如果您安装的标头确实需要的话依赖于平台。不过,这是一种使用过时的 autoconf 宏的脆弱方法。
You shouldn't be exporting
config.h
in your library's interface anyway.This link shows a method of getting around that if your installed headers really, truly need to be platform dependent. It is a fragile method using an outdated autoconf macro though.
您可以选择通过更改 AC_OUTPUT 宏来输出不同的配置文件,尽管我不确定您的项目将如何与其他项目集成。如果它是一个子项目,那么它无论如何都会位于子目录中。
You can choice to output a different config file by changing the AC_OUTPUT macro, although I'm not sure how you project is going to integrate with other projects. If it's a sub-project, then it'll be in a sub-directory anyway.