Makefile2

Makefile上面会有个变量区:

VRE_D : make VRE_D=1 or true (必须得有等号,因为它不是target,另外ifdef,只要有值就是true)

OPT: make OPT=add(得等于固定的值)

其实更多使用方法是直接赋值;在变量区调用echo会出错,why???

# 注释顶格写,不然会被输出

不加@ ,会把这条指令也输出出来

#firstly,serval method of assignment, ?= assignmen when no value
#:= reassigned
VAR ?= "defined already"

ifdef VRE_D
        VRE = "hello world"
endif
ifeq ($(OPT),define)
        VRE ?= "hello world, first\n"
endif

ifeq ($(OPT), add)
        VRE += "Kelly"
endif

ifeq ($(OPT),recover)
        VRE := "hello world , again !!!"
endif


all:
        @echo $(VRE)
        @echo $(VAR)
#@ls /dev

猜你喜欢

转载自blog.csdn.net/qq_24328911/article/details/83414478