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. 深挖 NGUI 基础 之UIRoot (一)

    当你开始使用NGUI的时候,简单的从项目视图 中一个”Control”预设体 拖拽到场景视图中,你将会发现 Hierarchy层次面板中会出现以下层次结构: 其中 UI Root作为根节点,是每个NG ...

  2. LeetCode 206——反转链表

    对单链表进行反转有迭代法和递归法两种. 1. 迭代法 迭代法从前往后遍历链表,定义三个指针分别指向相邻的三个结点,反转前两个结点,即让第二个结点指向第一个结点.然后依次往后移动指针,直到第二个结点为空 ...

  3. 计算机概念总结5-阿里云的了解-ecs

    1.ecs 1.1ecs 云服务器Elastic Compute Service(ECS)是阿里云提供的一种基础云计算服务.使用云服务器ECS就像使用水.电.煤气等资源一样便捷.高效.您无需提前采购硬 ...

  4. throw er; // Unhandled 'error' event&Error: ENOENT: no such file or directory,

    今天做一个文件上传的项目时, 用express-formidable往硬盘里面存文件时, 报  ENOENT:no such file or directory 原因就是程序不能像别的语言一样不存在就 ...

  5. Flask 学习笔记(二):RESTful API

    概括 URL:需要操作的对象,也就是资源 HTTP method:我要对该对象做什么(POST 增.DELETE 删.GET 查.PUT 和 PATCH 改) HTTP status code:操作的 ...

  6. vim使用注意事项

    vim使用注意事项 1. 中文编码的问题 中文编码有很多,如果文件与vim的终端界面使用的编码不同,那么在vim显示的文件内容将会是一堆乱码. 2. 语系编码转换 命令iconv可以将语系编码进行转换 ...

  7. 【转载】Linux升级NTPD服务器-编译安装ntp-4.2.8p12与配置

    [转载]Linux升级NTPD服务器-编译安装ntp-4.2.8p12与配置 1. 系统与软件版本 1.1 系统版本 rhel6.4(Red Hat Enterprise Linux Server r ...

  8. 5for Java

    ① 从字符串“耿丹计算机Java20170320”中提取日期 public class Xx1 { /** * @param args */ public static void main(Strin ...

  9. Python执行Linux系统命令的4种方法

    http://www.jb51.net/article/56490.htm (1) os.system 仅仅在一个子终端运行系统命令,而不能获取命令执行后的返回信息 复制代码代码如下: system( ...

  10. HTML精确定位之位置参数乱炖一锅

    一.前言 公司项目,需要在一个图片的右上角放置一个类似“X”的东西(其实是需要显示一个数字,就像微信一样,在右上角显示几个消息),然后需要用到html的定位,看了几个网上的例子,恍惚间看到了一个off ...