1

我有一个基于 autotools 的包调用 Foo。由于历史原因(还有其他原因吗?),这包含一个子包 subBar。

Foo -|
     |- configure.ac
     |- Makefile.am
     |- subBar -|
                |- configure.ac
                |- Makefile.am

subBar 的 configure.ac 足够复杂,如果可以避免的话,我不想弄乱它。另一方面,subBar 与 Foo 紧密集成,因此为其保留单独的版本号是没有意义的。

有没有办法将 Foo 的版本(从 AC_INIT)传播到 subBar?显而易见的:

subBar/configure.ac:
  AC_INIT([subBar], [$(VERSION)], ...)

由于循环引用而不起作用。

有任何想法吗?

4

2 回答 2

2

The manual provides a possible solution:

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... 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).

Since autoconf itself uses this in its own configure.ac:

AC_INIT([GNU Autoconf],
        m4_esyscmd([build-aux/git-version-gen .tarball-version]),
        [bug-autoconf@gnu.org])

you need to replace this with a system command or shell script of your own to get a version string. e.g., a top-level file called .foo-version with "MAJOR.MINOR", and borrowing from git-version-gen, something like: m4_esyscmd([tr -d '\n' < ../.foo-version])

I suppose you could use the same command in the top-level package, replacing ../ with ./ of course. Since m4 is invoking a system command, you're free to get the version string any way you prefer.

于 2013-06-10T18:27:42.193 回答
0

https://github.com/ClusterLabs/libqb/blob/master/build-aux/git-version-gen

这是一个您可以采用的 shell 脚本文件……对于那些不熟悉的人……然后将名称定制为两个单独的变量文件集,例如.subBar-tarball-versionand.tarball-version.subBar-versionand.version

于 2015-11-17T20:52:31.430 回答