新手求教一个automake的问题

周靖峰 2013-05-06 10:48:04
automake在书写Makefile.am时,有一项是XXX_SOURCES,该项中会有很多的.c文件,例如:


bin_PROGRAMS = test
test_SOURCES = test.c test2.c test3.c


我想问的是,如果test_SOURCES后面有很多.c文件怎么办,比方说有几十个甚至几百个,难道也要一个个手写上去?

求高手解答
...全文
72 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
亲,如果你的C文件安排位置比较合理,可以使用自动变量或者通配符的
就是那个党伟 2013-05-06
  • 打赏
  • 举报
回复
qq120848369 2013-05-06
  • 打赏
  • 举报
回复
27.3 Why doesn't Automake support wildcards? ============================================ Developers are lazy. They would often like to use wildcards in `Makefile.am's, so that they would not need to remember to update `Makefile.am's every time they add, delete, or rename a file. There are several objections to this: * When using CVS (or similar) developers need to remember they have to run `cvs add' or `cvs rm' anyway. Updating `Makefile.am' accordingly quickly becomes a reflex. Conversely, if your application doesn't compile because you forgot to add a file in `Makefile.am', it will help you remember to `cvs add' it. * Using wildcards makes it easy to distribute files by mistake. For instance, some code a developer is experimenting with (a test case, say) that should not be part of the distribution. * Using wildcards it's easy to omit some files by mistake. For instance, one developer creates a new file, uses it in many places, but forgets to commit it. Another developer then checks out the incomplete project and is able to run `make dist' successfully, even though a file is missing. By listing files, `make dist' _will_ complain. * Finally, it's really hard to _forget_ to add a file to `Makefile.am': files that are not listed in `Makefile.am' are not compiled or installed, so you can't even test them. Still, these are philosophical objections, and as such you may disagree, or find enough value in wildcards to dismiss all of them. Before you start writing a patch against Automake to teach it about wildcards, let's see the main technical issue: portability. Although `$(wildcard ...)' works with GNU `make', it is not portable to other `make' implementations. The only way Automake could support `$(wildcard ...)' is by expending `$(wildcard ...)' when `automake' is run. The resulting `Makefile.in's would be portable since they would list all files and not use `$(wildcard ...)'. However that means developers would need to remember to run `automake' each time they add, delete, or rename files. Compared to editing `Makefile.am', this is a very small gain. Sure, it's easier and faster to type `automake; make' than to type `emacs Makefile.am; make'. But nobody bothered enough to write a patch to add support for this syntax. Some people use scripts to generate file lists in `Makefile.am' or in separate `Makefile' fragments. Even if you don't care about portability, and are tempted to use `$(wildcard ...)' anyway because you target only GNU Make, you should know there are many places where Automake needs to know exactly which files should be processed. As Automake doesn't know how to expand `$(wildcard ...)', you cannot use it in these places. `$(wildcard ...)' is a black box comparable to `AC_SUBST'ed variables as far Automake is concerned. You can get warnings about `$(wildcard ...') constructs using the `-Wportability' flag.

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧