zoukankan      html  css  js  c++  java
  • 基于cygwin构建u-boot(三)make错误忽视

    接上文,修改gcc 的-std标准后,.depend文件处理仍然出现了错误:

    五、错误:make中命令报错(sed找不到需要的文件)

     错误告警如下

    1 make -C examples/api all
    2 make[1]: 进入目录“/u-boot-2010.09/u-boot-2010.09/examples/api”
    3 sed -i 's/d:///cygdrive/d//g' .depend
    4 sed:无法读取 .depend:No such file or directory
    5 make[1]: *** 没有规则可以创建“all”需要的目标“.depend”。 停止。
    6 make[1]: 离开目录“/u-boot-2010.09/u-boot-2010.09/examples/api”
    7 Makefile:378: recipe for target `examples/api' failed
    8 make: *** [examples/api] Error 2

    1、分析
    错误提示比较明显,是 examples/api中,没有.depend规则的产生。

    而之前 sed命令,是需要.depend文件存在的。

    2、解决思路1:首先会想到if...else来实现

    又有两种思路,一种是make自身带的,一种是shell工具。该部分单独讨论,不再本文描述。(大家可以自己尝试)

    3、解决思路2:先建立一个空.depend文件

    原始代码如下:

     1 $(obj).depend:    $(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
     2         @rm -f $@
     3         @for f in $(SRCS); do 
     4             g=`basename $$f | sed -e 's/(.*).w/1.o/'`; 
     5             $(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; 
     6         done
     7         @for f in $(HOSTSRCS); do 
     8             g=`basename $$f | sed -e 's/(.*).w/1.o/'`; 
     9             $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; 
    10         done
    11         sed -i 's/d:///cygdrive/d//g' $@

    只需要在第2行后,增加 touch $@ 即可

    4、解决思路3:利用make的忽视错误规则

    make 对其规则中调用的外部程序返回的错误可选的应对。

    To ignore errors in a recipe line, write a ‘-’ at the beginning of the line’s text

    (after theinitial tab). The ‘-’ is discarded before the line is passed to the shell for execution. 

    可知,如果将“-”放置到调用命令之前,就可以忽视外部命令的错误。

    可以利用: - sed -i 's/d:///cygdrive/d//g' $@

    来忽视相关错误。

    扩展:对于include这个内部命令也可以这样用,但还有一种别名:sinclude (相当于 -include)。

    前文 autoconf.mk.dep 格式错误时,涉及到sinclude。其主要是解决引用找不到文件等错误,如果文件内部错误,sinclude也无法避免。

    详细信息参见:https://www.gnu.org/software/make/manual/make.html#Errors

    5、后记

    make错误信息含义:

    https://www.gnu.org/software/make/manual/make.html#Error-Messages

     之前,make的错误为:multiple target patterns. Stop.

     1 ‘missing target pattern. Stop.’
     2 ‘multiple target patterns. Stop.’
     3 ‘target pattern contains no ‘%’. Stop.’
     4 ‘mixed implicit and static pattern rules. Stop.’
     5     These are generated for malformed static pattern rules. 
     6     The first means there’s no pattern in the target section of the rule; 
     7     the second means there are multiple patterns in the target section; 
     8     the third means the target doesn’t contain a pattern character (%); 
     9     and the fourth means that all three parts of the static pattern rule 
    10       contain pattern characters (%)–only the first two parts should. 
    11     If you see these errors and you aren’t trying to create a static pattern rule, 
    12       check the value of any variables in your target and prerequisite lists 
    13       to be sure they do not contain colons. 

    ===【未完待续】=== 

  • 相关阅读:
    android 各国语言对应的缩写
    Android 程式开发:(十三)特殊碎片 —— 13.2 DialogFragment
    Android Bitmap和Canvas学习笔记 [转]
    Android 高手进阶之自定义View,自定义属性(带进度的圆形进度条)
    XAMPP 在windows下无法启动Apache解决方案
    深入浅出Java并发包—锁机制(一)
    深入浅出Java并发包—锁(Lock)VS同步(synchronized)
    深入浅出Java并发包—CAS机制
    深入浅出Java并发包—指令重排序
    深入浅出Java并发包—原子类操作
  • 原文地址:https://www.cnblogs.com/yvivid/p/3574234.html
Copyright © 2011-2022 走看看