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的更多相关文章

  1. ORA-00604: error occurred at recursive SQL level 1

    在测试环境中使用某个账号ESCMOWNER对数据库进行ALTER操作时,老是报如下错误: ORA-00604: error occurred at recursive SQL level 1 ORA- ...

  2. scala tail recursive优化,复用函数栈

    在scala中如果一个函数在最后一步调用自己(必须完全调用自己,不能加其他额外运算子),那么在scala中会复用函数栈,这样递归调用就转化成了线性的调用,效率大大的提高.If a function c ...

  3. 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 ...

  4. 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 ...

  5. some simple recursive lisp programs

    1. Write a procedure count-list to count the number of elements in a list (defun count-list (numbers ...

  6. LEETCODE —— Binary Tree的3 题 —— 3种非Recursive遍历

    Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' valu ...

  7. WITH RECURSIVE and MySQL

    WITH RECURSIVE and MySQL If you have been using certain DBMSs, or reading recent versions of the SQL ...

  8. Using Recursive Common table expressions to represent Tree structures

    http://www.postgresonline.com/journal/archives/131-Using-Recursive-Common-table-expressions-to-repre ...

  9. hdu 5950 Recursive sequence 矩阵快速幂

    Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

  10. HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)

    Recursive sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Other ...

随机推荐

  1. windows下网络命令----Tracert命令详解

    现在网络四通八达,网线光纤基站卫星,只要运营商能收费的地方,就有网络,覆盖了全世界所有的区域.彻底改变了以前通讯基本靠吼的情况.那么宽广的网络世界,超过100米就得需要中继放大信号的网线,即使现在的光 ...

  2. sed-awk命令详解

      第2章 ***********sed***********. 1目  录 2.1 -------sed命令小结及小结图---- 1 2.2 -------第几行---------- 2 2.3 - ...

  3. 并查集——hdu1213(入门)

    传送门:How Many Tables 模板代入 判断几个连通分支 DFS亦可完成 [并查集] #include <iostream> #include <cstdio> #i ...

  4. Alpha阶段展示

    程序员杀产品经理祭天(SacrificePM)团队 1.团队成员简介和个人博客地址 故事 我们队伍的建立过程稍具戏剧性,大家看我们也颇为奇怪,这么一支8人队伍是怎么诞生的呢?其实我们原本分属三组,而第 ...

  5. 最短路径——Dijkstra算法以及二叉堆优化(含证明)

    一般最短路径算法习惯性的分为两种:单源最短路径算法和全顶点之间最短路径.前者是计算出从一个点出发,到达所有其余可到达顶点的距离.后者是计算出图中所有点之间的路径距离. 单源最短路径 Dijkstra算 ...

  6. 【转】GOOGLE-PROTOBUF与FLATBUFFERS数据的序列化和反序列化

    转载自[黑米GameDev街区] 原文链接: http://www.himigame.com/unity3d-game/1607.html  关于Protobuf 通过本文的转载和分享的相关链接,足够 ...

  7. Python数据分析(二)pandas缺失值处理

    import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(5, 3), index=['a', 'c', 'e' ...

  8. P1531 I Hate It

    题目背景 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少.这让很多学生很反感. 题目描述 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的 ...

  9. Netscaler重置密码的方法

    Netscaler重置密码的方法 http://blog.51cto.com/caojin/1898401 有时候我们会碰到忘记Netscaler的密码,或接手别人的设备而不知道密码的情况.在这种情况 ...

  10. 【算法】CDQ分治 -- 三维偏序 & 动态逆序对

    初次接触CDQ分治,感觉真的挺厉害的.整体思路即分而治之,再用之前处理出来的答案统计之后的答案. 大概流程是(对于区间 l ~ r): 1.处理 l ~mid, mid + 1 ~ r 的答案: 2. ...