Autoconf 和多个不同版本的二进制文件

发布于 2024-12-21 11:06:08 字数 363 浏览 4 评论 0原文

我在自己的源代码树中有两个类似的应用程序,我正在使用自动工具来构建它们。在每个应用程序的configure.ac中,我有:AC_INIT(appname, appversion)
由于代码库相似并且共享一些代码,我想将它们合并到 1 个源代码树,但我需要每个应用程序的应用程序名称和应用程序版本不同,这可以使用自动工具来实现吗?
我在应用程序中使用PACKAGE_NAME, PACKAGE_VERSION
我当前的源结构如下所示:

./configure.ac
./src/Makefile.am
./src/*.cpp
./src/include/*.h

谢谢。

I have two similar applications in their own source trees and I am using autotools to build them. In each application's configure.ac I have:AC_INIT(appname, appversion)
Since the code base is similar and is sharing some code, I'd like to merge them to 1 source tree but I need to have the appname and appversion distinct for each application, can this be achieved using autotools?
I am using PACKAGE_NAME, PACKAGE_VERSION in the application.
My current source structure looks like this:

./configure.ac
./src/Makefile.am
./src/*.cpp
./src/include/*.h

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七颜 2024-12-28 11:06:08

在configure.ac中,您可以这样做:

AC_SUBST([APP1VERSION],[1.2.3])
AC_SUBST([APP2VERSION],[0.0.1])
AC_DEFINE_UNQUOTED([APP1VERSION],["$APP1VERSION"],[Version of app 1])
AC_DEFINE_UNQUOTED([APP2VERSION],["$APP2VERSION"],[Version of app 2])

这些版本独立于PACKAGE_VERSION,但在您的.c文件中
你可以简单地将它们连接起来:

printf( "%s", PACKAGE_VERSION APP1VERSION );

In configure.ac, you could do:

AC_SUBST([APP1VERSION],[1.2.3])
AC_SUBST([APP2VERSION],[0.0.1])
AC_DEFINE_UNQUOTED([APP1VERSION],["$APP1VERSION"],[Version of app 1])
AC_DEFINE_UNQUOTED([APP2VERSION],["$APP2VERSION"],[Version of app 2])

These versions are independent of PACKAGE_VERSION, but in your .c files
you can simply concatenate them:

printf( "%s", PACKAGE_VERSION APP1VERSION );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文