简体   繁体   English

自动工具:在Makefile.am中生成源和标题

[英]Autotools: Generating Sources and Headers in Makefile.am

This link mentions wildcards as a way to automatically list the SOURCES and HEADERS in the Makefile.am file. 该链接提到通配符,作为在Makefile.am文件中自动列出源和头的一种方法。 It also mentions that some people write external scripts to generate those files. 它还提到有些人编写外部脚本来生成那些文件。

Do you know of the standard way of automatically including all the *.h *.cpp here, or should I just write my own Perl script to generate them. 您是否知道在此处自动包括所有* .h * .cpp的标准方式,还是我应该编写自己的Perl脚本来生成它们。 Do you have such a script already that you use? 您已经使用了这样的脚本吗?

PS: I organize the source files in my project according to the following purely-logical separation of directories: PS:我根据以下目录的纯粹逻辑分隔来组织项目中的源文件:

src/dog/woof.h
src/dog/woof.cpp
src/cow/moo.h
src/cow/moo.cpp

Automake won't add this feature. 自动制作不会添加此功能。 It makes assumptions that a particular .h or .cpp file is associated with a particular project. 它假定特定的.h或.cpp文件与特定的项目相关联。 That assumption holds for a number of common project layouts and fails for any layout that differs. 该假设适用于许多常见的项目布局,但不适用于任何不同的布局。

For example, I've had projects that were laid out as 例如,我有一些项目的布局

src/module/code
src/app/code
src/library/code
include/headers

built from one central makefile in the root. 从根目录中的一个中央makefile构建。 Other times, I've had the same layout built from four makefiles in the appropriate local directories. 其他时候,我在适当的本地目录中通过四个makefile构建了相同的布局。

There's a lot of variability in projects. 项目中有很多可变性。 Some keep public header files mixed with private headers files in the code directories, some keep them separate. 有些将公共头文件与专用头文件混合在代码目录中,有些则将它们分开。 Some build shared object libraries, some don't. 有些构建共享对象库,有些则不。 Some ship code that's not SUPPOSED to compile on incompatible platforms. 某些未在不兼容的平台上编译的船舶代码。

To put in a wild card inclusion would actually pose a great risk of limiting the functionality, and for those odd people who do things like 'file.template.c' and such it would be fatal. 放入通配符实际上会带来限制功能的巨大风险,对于那些像“ file.template.c”这样的怪人来说,这将是致命的。

If you consider it a flaw of automake, that's fine; 如果您认为这是自动制作的缺陷,那很好。 however, it's one of those flaws that automake embraces as it's preserved in the effort to make things more flexible. 但是,这是automake所包含的缺陷之一,因为它在努力使事情变得更加灵活的过程中得以保留。 Automake doesn't impose the "how" you do things, it provides a lot of enabling tools, but it goes out of it's way to ensure that you aren't forced into one "method" of laying out or building your code. Automake并没有强加“做事”的方式,它提供了许多启用工具,但它完全避免了确保您不被迫采用一种布局或构建代码的“方法”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM