Autotools:包括预构建的第三方库
我目前正在努力将一组 C++ 二进制文件升级为基于 Autotools 的更现代的文件,每个文件都使用自己的 Makefile 集。但是我不知道如何将第三方库(例如 Oracle Instant Client)包含到构建/打包过程中。
这真的是我错过的简单事情吗?
编辑以添加更多详细信息
我当前的构建环境如下所示:
/src
/lib
/libfoo
... source and header files
Makefile
/oci #Oracle Instant Client
... header and shared libraries
Makefile
/bin
/bar
... source and header files
Makefile
Makefile
/build
/bin
/lib
build.sh
今天,顶层 build.sh 执行以下步骤:
- 运行每个库的 Makefile 并将输出复制到 /build/lib
- 运行每个二进制文件的 Makefile并将输出复制到 /build/bin
每个 Makefile 都有一组指向各个同级目录的硬编码路径。不用说,这已经成为维护的噩梦。我已经开始测试自动工具,但我遇到的问题是找出相当于将 /src/lib/oci/*.so 复制到 /build/lib 的方法,以进行编译时链接并捆绑到发行版中。
I'm currently working to upgrade a set of c++ binaries that each use their own set of Makefiles to something more modern based off of Autotools. However I can't figure out how to include a third party library (eg. the Oracle Instant Client) into the build/packaging process.
Is this something really simple that I've missed?
Edit to add more detail
My current build environment looks like the following:
/src
/lib
/libfoo
... source and header files
Makefile
/oci #Oracle Instant Client
... header and shared libraries
Makefile
/bin
/bar
... source and header files
Makefile
Makefile
/build
/bin
/lib
build.sh
Today the top level build.sh does the following steps:
- Runs each lib's Makefile and copies the output to /build/lib
- Runs each binary's Makefile and copied the output to /build/bin
Each Makefile has a set of hardcoded paths to the various sibling directories. Needless to say this has become a nightmare to maintain. I have started testing out autotools but where I am stuck is figuring out the equivalent to copying /src/lib/oci/*.so to /build/lib for compile time linking and bundling into a distribution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想出了如何实现这一点。
首先,我切换到非递归 make。
接下来,我按照此页面对configure.am进行了以下更改 http://www.openismus .com/documents/linux/using_libraries/using_libraries
然后在 Makefile.am 中使用以下行(假设名为 foo 的二进制文件)
I figured out how to make this happen.
First I switched to a non recursive make.
Next I made the following changes to configure.am as per this page http://www.openismus.com/documents/linux/using_libraries/using_libraries
In the Makefile.am you then use the following lines (assuming a binary named foo)
自动工具不是包管理系统,尝试将这种类型的功能放入其中是一个坏主意。您不应将第三方库合并到您的发行版中,而应该简单地让配置脚本检查其是否存在,并在所需的库不可用时中止。用户有责任满足依赖性。然后,您可以发布一个二进制包,该包将允许用户使用包管理系统来简化依赖关系解析。
The autotools are not a package management system, and attempting to put that type of functionality in is a bad idea. Rather than incorporating the third party library into your distribution, you should simply have the configure script check for its existence and abort if the required library is not available. The onus is on the user to satisfy the dependency. You can then release a binary package that will allow the user to use the package management system to simplify dependency resolution.