问题描述
出于某些原因,我在纯文本文件中而不是configure.ac中定义我的项目版本号.我想创建一条语句,该语句将读取版本号并将其存储在编译期间.
I define my project version number in a plain text file instead of configure.ac for some reasons. I would like to create a statement that would read the version number and store it during compilation time.
现在我的configure.ac看起来像这样:
Right now my configure.ac looks like this:
AC_INIT([my program],[999.9.9])
我想要类似的东西:
AC_INIT([my program],[ $(cat VERSION) ])
这当然行不通.这有什么窍门? (我知道我失去了一些可移植性-目前我不在乎).谢谢!
This wont work of course. What is the trick here? (I know I am loosing some portability - I don't care at the moment). Thanks!
推荐答案
尝试:
AC_INIT([my program], m4_esyscmd([tr -d '\n' < VERSION]))
使用注释中建议的修复程序进行编辑.
Edited with fixes suggested in the comments.
我还能够使用以下方式删除不可移植的tr
调用:
I was also able to remove the non-portable tr
invocation using:
AC_INIT([my program], [m4_translit(m4_esyscmd([cat VERSION]),m4_newline)])
似乎也一样有效,Enrico在下面的评论中建议的解决方案也是如此:
which seems to work just as well, as does the solution suggested by Enrico in the comments below:
AC_INIT([my program], [m4_esyscmd_s([cat VERSION])])
这篇关于从configure.ac中的文件中读取版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!