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. LeetCode 707 ——设计链表

    1. 题目 2. 解答 用一个单链表来实现,只有一个头指针.因为不能建立哨兵结点,因此要特别注意是否在头结点处操作. class MyLinkedList { public: struct ListN ...

  2. 爬虫:Scrapy17 - Common Practices

    在脚本中运行 Scrapy 除了常用的 scrapy crawl 来启动 Scrapy,也可以使用 API 在脚本中启动 Scrapy. 需要注意的是,Scrapy 是在 Twisted 异步网络库上 ...

  3. 【iOS开发】UIView之userInteractionEnabled属性介绍

    http://my.oschina.net/hmj/blog/108002 属性作用 该属性值为布尔类型,如属性本身的名称所释,该属性决定UIView是否接受并响应用户的交互. 当值设置为NO后,UI ...

  4. Mininet简单性能测试

    建一个简单的模型,使用一个单交换机,然后链接n个主机形成拓扑,然后对每个链路设置带宽,延迟时间,和丢包率. 这里就选择建一个单交换机和六个主机的作为例子. 创建py脚本生成拓扑:写一个类生成一个单交换 ...

  5. 微信小程序小程序使用scroll-view不能使用下拉刷新的解决办法

    <scroll-view class="movie-grid-container" scroll-y="true" scroll-x="fals ...

  6. PHP与webserver【简书看到的】

    很久以前,人们造出来一个机器人,它的英文名字叫web server,中文名叫网页服务器.(为了简写,下文称web server为server) server的工作很简单,就是做内容的分发. 初期的se ...

  7. DataTable定义

    DataTable是一个临时保存数据的网格虚拟表(表示内存中数据的一个表.).DataTable是ADO dot net 库中的核心对象.它可以被应用在 VB 和 ASP 上.它无须代码就可以简单的绑 ...

  8. [洛谷P3382]【模板】三分法

    题目大意:给出一个$N$次函数,保证在范围$[l,r]$内存在一点x,使得$[l,x]$上单调增,$[x,r]$上单调减.试求出$x$的值. 题解:求导,就变成了求零点,二分答案即可 卡点:无 C++ ...

  9. 【BZOJ 1146】[CTSC2008]网络管理Network

    树剖+树状数组套线段树O(nlogn^3)(我打的),有一种更加优秀的算法是O(nlogn^2)的就是直接树状数组套线段树欧拉序(并不快),或者是用主席树维护原始的树的信息,同时用树状数组套线段树维护 ...

  10. JavaScript使用数组拼接字符串性能如何?

    传统上,字符串连接一直是js中性能最低的操作之一. view source   print? 1 var text="Hello"; 2 text+=" World!&q ...