回答
从手册:
The arguments of 'AC_INIT' must be static, i.e., there should not be any shell computation, quotes, or newlines, but they can be computed by M4. This is because the package information strings are expanded at M4 time into several contexts, and must give the same text at shell time whether used in single-quoted strings, double-quoted strings, quoted here-documents, or unquoted here-documents. It is permissible to use 'm4_esyscmd' or 'm4_esyscmd_s' for computing a version string that changes with every commit to a version control system (in fact, Autoconf does just that, for all builds of the development tree made between releases).
这是autoconf的(目前)使用:
AC_INIT([GNU Autoconf],
m4_esyscmd([build-aux/git-version-gen .tarball-version]),
[[email protected]])
如果你不需要从外部来源读取的版本,这里是GLIB使用的:
m4_define([glib_major_version], [2])
m4_define([glib_minor_version], [41])
m4_define([glib_micro_version], [0])
...
m4_define([glib_version],
[glib_major_version.glib_minor_version.glib_micro_version])
...
AC_INIT(glib, [glib_version], ...)
当然,你将不得不使用M4构建,而不是外壳,像m4_if()
,m4_eval()
等
对于任何获得“错误:应该使用包和版本参数调用AC_INIT”的人,我能够使其工作通过将m4_esyscmd放在方括号中。 另外,如果您碰巧在最后使用“回显”脚本获取版本号,请务必使用“-ne”。我的配置脚本对版本字符串中的换行符不满意! – jonthalpy
- 1. 创建AC_INIT
- 2. Autoconf - 在AC_INIT参数列表中使用来自m4/revision.m4的宏
- 3. 在变量中使用变量PyQT
- 4. 如何在变量中使用变量?
- 5. 在新变量中使用变量
- 6. 在变量中使用变量?
- 7. 在ansible_python_interpreter变量中使用env变量
- 8. 在变量中使用find变量
- 9. 在mixin上使用变量或在Less.js中使用变量
- 10. 在sed中使用变量
- 11. 在ServletContextListener中使用变量
- 12. 在CSV中使用变量
- 13. 在REPLACE中使用变量
- 14. 在VLOOKUP中使用变量
- 15. 在$ _POST中使用变量[]
- 16. 在Javascript中使用变量
- 17. 在Unix中使用变量
- 18. 在SQL中使用变量
- 19. 在sed中使用变量
- 20. 在Tasker中使用变量
- 21. 在GET中使用变量
- 22. 在PHP中使用变量
- 23. 在Animationlistener中使用变量
- 24. 在config.xml中使用变量
- 25. 在Makefile中使用变量
- 26. 在.map()中使用变量
- 27. 在find中使用变量
- 28. 在find_by_sql中使用变量
- 29. 在@ Url.Action中使用变量()
- 30. 在reStructuredText中使用变量
可能重复(http://stackoverflow.com/questions/8559456/read-a-version-number-from-a-file-in-configure-ac) – ldav1s