Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Vinllen Chen


To be a better coder

Automake中的BUILT_SOURCES

  BUILT_SOURCES变量作用是自动化编译依赖文件。
  举个例子,比如我需要编译A.c代码,而A.c代码依赖A.h和B.h、B.c,A.h是实际存在的,而B.h和B.c是需要通过调用gen二进制程序生成的,我不想每次都先执行gen生成B.h和B.c,再执行Makefile.am,而是想要集成化操作,一步到位,那么就需要用到BUILT_SOURCES了。相当于在Makefile.am里面加上下面这三行就行,其中$(EXEEXT)标识gen为可执行程序,当然,不加也可以。

BUILT_SOURCES = B.h B.c  
$(BUILT_SOURCES): Makefile
    gen$(EXEEXT)

  需要注意的是,BUILT_SOURCES只支持make allmake checkmake install,如果单个执行make A是不行的。
  关于具体BUILT_SOURCES使用方式可以参考gnu的文档

参考

http://stackoverflow.com/questions/33296627/makefile-am-to-run-script-if-source-file-changed https://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/Sources.html https://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/Built-Sources-Example.html#Built-Sources-Example


About the author

vinllen chen

Beijing, China

格物致知


Discussions

comments powered by Disqus