这个 makefile 架构有什么意义?

发布于 2024-08-04 15:48:21 字数 416 浏览 0 评论 0原文

我有一个正在尝试编译的程序,我们称之为 P。P 需要一个第三方库,L1。 L1 需要另一个库,L2。到目前为止,没有什么是奇怪的。

P 的 Makefile 基本上只是设置一些变量,然后包含 L1 的 makefile。

L1 的 makefile 执行一大堆变量设置和内容(例如,包括要编译的文件列表),然后包含 L2 的 makefile。

L2s makefile 做了很多工作,实际上完成了所有 3 个工作。

我的问题是 L2 不想编译。

但是,我的系统已经有两个库的二进制版本,但我无法使用它们,因为 L2 makefile 完成了所有工作。

此外,如果您使用动态库进行编译,它将在运行时在您的编译目录中查找要加载的库,这不是它们在生产系统上的位置。

我的问题是:他们到底为什么要这样设计?

I have a program I'm trying to compile, lets call it P. P needs a 3rd party library, L1. L1 needs another library, L2. So far, nothing is that weird.

The Makefile for P basically just sets some variables, and then includes the makefile for L1.

The makefile for L1 does a whole bunch of variable setting and stuff, (including a list of files to compile, for example) and then includes L2's makefile.

L2s makefile does a whole LOT of work and actually makes all 3.

My problem is that L2 doesn't want to compile.

However, I already HAVE a binary version of both libraries for my system, but I can't use them because the L2 makefile does all of the work.

Also, if you compile with dynamic libraries, it's going to look for the libraries to load in your compile directory, at runtime, which isn't where they belong on the production system.

My question is: Why the heck did they design it this way?

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

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

发布评论

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

评论(3

套路撩心 2024-08-11 15:48:21

可能是因为他们维护库和程序 - 对于他们来说,编译工作并且通过这样做,他们可以保证两个库都是最新的(因此程序具有最新的代码可以使用)。

Probably because they maintain both libraries and the program - and for them, the compilations work and by doing it this way, they are guaranteed that both libraries are fully up to date (and hence that the program has the latest code to use).

谜兔 2024-08-11 15:48:21

在我看来,这就像有机增长的东西:

  1. 有人编写了 L2 的 Makefile,并使其变得非常复杂和强大。这个 Makefile 使用变量,例如对象列表,并从它们开始的任何内容(例如,什么都没有)构建它们。
  2. 有人(其他人?)必须编写 L1 的 Makefile,并决定通过构建 L1 的列表然后将所有内容交给 L2 的 Makefile,而不是尝试重新发明所有这些机制。
  3. 你店里的某个人必须编写 P 的 Makefile 并搭载 L1 的 Makefile。

这种设计的问题(除了它很难理清之外)是它只能与链中最差的 Makefile 一样好(可能是其他人制作的)。如果 L2 没有编译,那么要么某些 Makefile 包含了一个脆弱的 Makefile 并破坏了它,要么环境中的某些内容发生了早期作者之一所期望的更改。如果 L2 Makefile 正确处理依赖关系,那么您应该能够说服它使用库而不重建它们(并且您可以尝试单独创建 L2 来诊断问题)。如果没有,那么你就只能去洞穴探险了。

This looks to me like something that grew organically:

  1. Someone wrote L2's Makefile and made it very complex and powerful. This Makefile uses variables, such as lists of objects, and builds them up from whatever they start with (like, say, nothing).
  2. Someone (else?) had to write L1's Makefile and decided to piggyback by constructing L1's lists and then handing everything over to L2's Makefile, rather than try to reinvent all that machinery.
  3. Someone at your shop had to write P's Makefile and piggybacked on L1's Makefile.

The trouble with this design (apart from its being hard to untangle) is that it's only as good as the worst Makefile in the chain (probably made by someone else). If L2 isn't compiling, then either some Makefile has included a delicate Makefile and broken it, or else something in the environment has changed that one of the earlier writers counted on. If the L2 Makefile handles dependencies correctly, then you should be able to persuade it to use the libraries without rebuilding them (and you can try making L2 alone to diagnose the problem). If it doesn't, then you'll just have to go spelunking.

时光与爱终年不遇 2024-08-11 15:48:21

我想说对我来说闻起来像是一个引导过程......

I would say for me smells like a bootstrapping process...

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