Make recursive
folder structure:
Makefile
t1/Makefile
t1/t1.c
t2/Makefile
t2/t2.c
Makefile
SUBDIRS = t1 t2
all:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir; \
done
t1/Makefile
all: t1
clean:
rm t1
t1/t1.c
#include <stdio.h>
int main(void)
{
printf("t1 \n");
return 0;
}
t2/Makefile
all: t2
clean:
rm t2
t2/t2.c
#include <stdio.h>
int main(void)
{
printf("t2 \n");
return 0;
}
===========================================
case 1:
如果我們將 t1/t1.c 故意寫錯
t1/t1.c
#include <stdio.h>
int main(void)
{
printf("t1 \n");
xxxxxxxxxxxxxxxxxxxxxxxx
return 0;
}
接下 make
$ make
for dir in t1 t2; do \
make -C $dir; \
done
make[1]: Entering directory '/home/break-through/working_space/wasai/make_test/t1'
cc t1.c -o t1
t1.c: In function ‘main’:
t1.c:5:9: error: ‘asdfasd’ undeclared (first use in this function)
asdfasd
^
t1.c:5:9: note: each undeclared identifier is reported only once for each function it appears in
t1.c:6:9: error: expected ‘;’ before ‘return’
return 0;
^
<builtin>: recipe for target 't1' failed
make[1]: *** [t1] Error 1
make[1]: Leaving directory '/home/break-through/working_space/wasai/make_test/t1'
make[1]: Entering directory '/home/break-through/working_space/wasai/make_test/t2'
cc t2.c -o t2
make[1]: Leaving directory '/home/break-through/working_space/wasai/make_test/t2'
發生什麼事呢?
當 build 到 t1 時,會有error,
但是並沒有立即 停下來,而是繼續執行 build t2,
這個會造成無法判斷是否 build success,
且也不曉得 error 在那裡,
怎麼說呢?
假如要 build 的 code 很多,
第一隻 code build error,
沒有立即停下,
繼續 build code,
而 營幕 會被一直刷新而無法判斷是否 build successful,
也不曉得 error 在哪裡?
結論:
不要使用 for loop build code
=======================================
case2:
若我們將 Makefile 改成如下,
SUBDIRS = t1 t2
BUILDSUBDIRS = $(SUBDIRS:%=build-%)
all: $(BUILDSUBDIRS)
$(BUILDSUBDIRS):
make -C $(@:build-%=%)
t1/t1.c 故意寫錯
#include <stdio.h>
int main(void)
{
printf("t1 \n");
xxxxxxxxxxxxxxxxxxxxxxxx
return 0;
}
執行 make
$ make
make -C t1
make[1]: Entering directory '/home/break-through/working_space/wasai/make_test/t1'
cc t1.c -o t1
t1.c: In function ‘main’:
t1.c:5:9: error: ‘asdfasd’ undeclared (first use in this function)
asdfasd
^
t1.c:5:9: note: each undeclared identifier is reported only once for each function it appears in
t1.c:6:9: error: expected ‘;’ before ‘return’
return 0;
^
<builtin>: recipe for target 't1' failed
make[1]: *** [t1] Error 1
make[1]: Leaving directory '/home/break-through/working_space/wasai/make_test/t1'
Makefile:7: recipe for target 'build-t1' failed
make: *** [build-t1] Error 2
看到了嗎?
一旦有 error,立即停止,
不會 build t2
Make recursive的更多相关文章
- ORA-00604: error occurred at recursive SQL level 1
在测试环境中使用某个账号ESCMOWNER对数据库进行ALTER操作时,老是报如下错误: ORA-00604: error occurred at recursive SQL level 1 ORA- ...
- scala tail recursive优化,复用函数栈
在scala中如果一个函数在最后一步调用自己(必须完全调用自己,不能加其他额外运算子),那么在scala中会复用函数栈,这样递归调用就转化成了线性的调用,效率大大的提高.If a function c ...
- one recursive approach for 3, hdu 1016 (with an improved version) , permutations, N-Queens puzzle 分类: hdoj 2015-07-19 16:49 86人阅读 评论(0) 收藏
one recursive approach to solve hdu 1016, list all permutations, solve N-Queens puzzle. reference: t ...
- hdu 1159, LCS, dynamic programming, recursive backtrack vs iterative backtrack vs incremental, C++ 分类: hdoj 2015-07-10 04:14 112人阅读 评论(0) 收藏
thanks prof. Abhiram Ranade for his vedio on Longest Common Subsequence 's back track search view in ...
- some simple recursive lisp programs
1. Write a procedure count-list to count the number of elements in a list (defun count-list (numbers ...
- LEETCODE —— Binary Tree的3 题 —— 3种非Recursive遍历
Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' valu ...
- WITH RECURSIVE and MySQL
WITH RECURSIVE and MySQL If you have been using certain DBMSs, or reading recent versions of the SQL ...
- Using Recursive Common table expressions to represent Tree structures
http://www.postgresonline.com/journal/archives/131-Using-Recursive-Common-table-expressions-to-repre ...
- hdu 5950 Recursive sequence 矩阵快速幂
Recursive sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)
Recursive sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
随机推荐
- laxcus的新功能:支持表跨数据库操作
关系数据库的层次结构,是账号.数据库.表,一个账号下可以有多个数据库,每个数据库有多个表,但是不同数据库下的表是不能够互相操作的.例如:"select a.*, b.* from Title ...
- [模板]BZOJ4756线段树合并
题面 Solution: 板子不解释 #include <iostream> #include <algorithm> #include <cstdio> #inc ...
- FFT的物理意义(转载)
文章转载自: http://blog.sina.com.cn/s/blog_640029b301010xkv.html FFT是离散傅立叶变换的快速算法,可以将一个信号变换到频域.有些信号在时域上是很 ...
- 以太坊solidity编程常见错误(不定期更新)
1.报错: Expected token Semicolon got 'eth_compileSolidity' funtion setFunder(uint _u,uint _amount){ 解决 ...
- 点击查看大图Activity
1.使用方式 Intent intent = new Intent(FriendCircleActivity.this, ImageGralleryPagerActivity.class);//0,索 ...
- chromium源码阅读
linux下chromium的入口函数在文件:src/chrome/app/chrome_exe_main_aura.cc 中 int main(int argc, const char** argv ...
- c++单例模式代码分析
单例模式就是一个C++语法精华浓缩的一个体现,有句老话:麻雀虽小五脏俱全!来形容单例非常贴切! 下面的代码分析了如果自己malloc并且memcpy一个单例指针会带来很大危害并如何防止这种情况发生. ...
- Android问题:could not install *smartsocket* listener;Address already in use
今天启动genymotion后,发现没有ip地址,运行项目时报错: 可见,没有连接到模拟器,无法运行,而先前说过没有ip,自然而然连接不上, 解决放法:将资源管理器打开,将adb全部退出 ...
- el-input怎么绑定回车事件
在 Vue 2.0 中,为自定义组件绑定原生事件必须使用 .native 修饰符:<el-input v-model="queryForm.skuName" placehol ...
- 习题:就是干(DP)
洛谷2301 题目描述 眼看着老师大军浩浩荡荡的向机房前进.LOI 的同学们决定动用自己的力量来保卫他们的好朋友loidc.现在每个人都要挑选自己的武器——两根木棍.一根用做远距离投掷,另一根用做近距 ...