Makefile 详解
Hello大家好,以上就是小编想说的所有内容啦。(手动狗头)
1、Makefile 打印变量的值
makefile中打印信息基本用到三个:info、warning、error
$(info, "here add the debug info") #此方法不能打印出.mk的行号 $(warning "here add the debug info") #正常打印 $(error "error: this will stop the compile") #到此位置会停止编译,并打印错误信息
打印信息如此,那么打印变量呢?
$(warning $(TARGET_DEVICE) ) #这样就打印了TARGET_DEVICE
另外使用echo也是可以的,但echo只能在target:后面的语句中使用,且前面加个TAB
@echo "xxxxxxxx" #普通打印 @echo $(xxx) #打印变量xxx
2、Makefile 使用加减乘除四则运算
除法:
A = $(shell date '+%s') #给A赋值 B = $(shell expr $(A) / 5) #将A除以5的结果赋值给B
tips:makefile中使用shell函数,必须在函数前加上shell。另外 / 两边都有空格,且空格是必须的。