从 configure.ac 中的文件中读取版本号 [英] Read a version number from a file in configure.ac

查看:33
本文介绍了从 configure.ac 中的文件中读取版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某些原因,我在纯文本文件而不是 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 '
' < 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 中的文件中读取版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆