【问题标题】:How to make from src directory in build directory?如何从构建目录中的 src 目录制作?
【发布时间】:2016-08-03 05:44:34
【问题描述】:

我的问题很简短。我有我的源目录 mySrcDir,我的 Makefile 也位于其中,我想将它编译到我的构建目录 myBuildDir 中。

我如何make我的/some/path/mySrcDir的内容变成/another/path/myBuildDir

PS:操作系统 Ubuntu 14.04

【问题讨论】:

  • 完全取决于你的makefile。默认的内置 make 规则不支持直接这样做。
  • 您的问题非常广泛。你能告诉我们这个问题中你已经知道怎么做的部分吗(例如在mySrcDir中构建目标)?
  • 1) 我创建 myBuildDir 2) 我调用 ../mySrcDir/configure 3) 我调用 make 4) 我调用 sudo make install。到目前为止,一切都很好。现在我想用修改后的 Makefile 重新编译 mySrcDir (mySrcDir/mySubSrcDir) 下的子目录。我可以在 mySubSrcDir 中调用 make & sudo make install,但这不是我认为的优雅方式。这就是为什么我想在 myBuildDir 中编译它然后安装..

标签: linux build makefile


【解决方案1】:

1) 在你的构建目录中调用这个:

make -f /some/path/mySrcDir/your-makefile

-f 选项用于指定您尝试“制作”的文件。

2) 如果 Makefile 是由 GNU autotools 生成的,你可以试试这个:

./configure --prefix=/another/path/myBuildDir

然后make

【讨论】:

  • 我配置并将整个源目录放入我的构建目录。现在我想用自定义选项重新编译一个子目录。我想,我可以在某处创建一个“子构建”目录,并在其中调用make 作为源文件夹中的子目录。
  • 试试这个:make -C /another/path/myBuildDir
  • 当我在 Makefile 所在的 src 目录中调用 make 命令时,它显示: make: Entering directory /another/path/myBuildDir make: *** No targets specified and no makefile found.停止。 make: 离开目录/another/path/myBuildDir
  • 从你的构建目录调用它:make -C /some/path/mySrcDir。让我知道这是否有效
  • 我犯了一个我想说的错误:make -f /some/path/mySrcDir/your-makefile. (从您的构建目录中调用它) f 选项是指定您要创建的文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-10-14
  • 1970-01-01
  • 1970-01-01
  • 2012-11-05
  • 2020-03-02
  • 2016-10-16
相关资源
最近更新 更多