makefile 基础

命令前加破折号:make忽略命令行返回的状态

clean:
        -rm *.o *~ core paper

命令前加@:不打印命令本身,只返回结果

install:
        @echo You must be root to install

条件指令

ifeq ($(CC),gcc)
        $(CC) -o foo $(objects) $(libs_for_gcc)
else
        $(CC) -o foo $(objects) $(normal_libs)
endif

 include指令

include指令告诉make暂停读取当前makefile文件,转而读取一个或多个其它的makefile,然后再继续当前makefile
include ${TOP_DIR}/config/common/makefile.mk

 指定头文件路径

先定义一个变量存头文件路径,比如变量 INCLUDES

INCLUDES += 
  -I${TOP_DIR}/ 
  -I${TOP_DIR}/common/include/quectel/open 
  -I${TOP_DIR}/interface/network/sockets/inc 
  -I${TOP_DIR}/interface/dev/inc 

 makefile 里调用 shell 输出

PWD:=$(shell pwd)
 
原文地址:https://www.cnblogs.com/god-of-death/p/14846310.html