Bash 使用shell脚本运行makefile
我的目录结构如下: . ├── one │ ├── one_one │ │ └── one_one_one │ │ ├── Makefile │ │ └── one_one_oneTest.cpp │ └── one_two │ ├── Makefile │ └── one_twoTest.cpp ├── three │ ├── Makefile │ └── threeTest.cpp └── two └── two_one ├── Makefile └── two_oneTest.cppBash 使用shell脚本运行makefile,bash,shell,makefile,find,Bash,Shell,Makefile,Find,我的目录结构如下: . ├── one │ ├── one_one │ │ └── one_one_one │ │ ├── Makefile │ │ └── one_one_oneTest.cpp │ └── one_two │ ├── Makefile │ └── one_twoTest.cpp ├── three │ ├── Makefile │ └── threeTest.cpp └── two └──
all: TestTwoOne
TestTwoOne: two_oneTest.cpp
g++ two_oneTest.cpp -o TestTwoOne
但它给出的错误是:make:**没有指定目标,也没有找到makefile。停止。
如果我只是运行find-键入f-name Makefile
,我得到
./two/two_one/Makefile
./three/Makefile
./one/one_two/Makefile
./one/one_one/one_one_one/Makefile
这是我期望的正确输出
如果我使用make命令运行Makefile,它将正常运行,因此我认为Makefile是正确的。
shell脚本可能有什么问题
仅供参考,我的一个makefile如下所示:
.
├── one
│ ├── one_one
│ │ └── one_one_one
│ │ ├── Makefile
│ │ └── one_one_oneTest.cpp
│ └── one_two
│ ├── Makefile
│ └── one_twoTest.cpp
├── three
│ ├── Makefile
│ └── threeTest.cpp
└── two
└── two_one
├── Makefile
└── two_oneTest.cpp
all: TestTwoOne
TestTwoOne: two_oneTest.cpp
g++ two_oneTest.cpp -o TestTwoOne
您的“当前目录”未更改为运行make的相应子目录。改为这样做:
find . -type f -name Makefile -execdir make \;
您的“当前目录”未更改为运行make的相应子目录。改为这样做:
find . -type f -name Makefile -execdir make \;