【问题标题】:Makefile creation for subdirectories Makefile为子目录创建 Makefile Makefile
【发布时间】:2021-05-19 04:24:20
【问题描述】:

我是 Makefile 的新手,我必须为我的项目创建一个 Makefile

project
├── Makefile
|
├── application
│   |── code1
│   |   ├── header-->header1.h(Inside the header1 folder)
│   |   |── source-->main1.c(Inside the source1 folder)
|   |   ├── doc-->Makefile
|   |
|   |── code2
|   |   ├── header-->header2.h(Inside the header2 folder)
|   |   |── source-->main2.c(Inside the source2 folder)
|   |   ├── doc-->Makefile

对于这个项目,我怎样才能在code1和code2里面写Makefile和整体Makefile 如何创建整体Makefile运行子目录Makefile

【问题讨论】:

  • 你必须使用makefile吗?如果可能的话,我建议改用cmake
  • 为什么你认为每个目录都需要一个Makefile...?
  • 我必须在linux中使用Makefile
  • @user253751: 那么如何运行项目文件夹中的C程序
  • 如果在每个目录中使用相同的子目录名称会简单很多。在doc 中有一个Makefile 是完全陌生的。

标签: c linux shell makefile project


【解决方案1】:

这样的?

.PHONY: all
all: application/code1/exe1 application/code2/exe2

application/code1/exe1: application/code1/source/main1.c application/code1/header/header1.c

application/code2/exe2: application/code2/source/main2.c application/code2/header/header2.c

application/ 级别增加了这里的痛苦;也许你应该删除它。或者,可以将Makefile 放入application 并删除上面的顶级目录。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-23
    • 2020-10-10
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    相关资源
    最近更新 更多