博客
关于我
Makefile系列--语法相关
阅读量:510 次
发布时间:2019-03-07

本文共 2387 字,大约阅读时间需要 7 分钟。

Makefile ??

Makefile ?????

Makefile ?????????????????????? := ?????????? = ??????????????????????????????????

???

A := $(C)B = $(C)C = abc

??? all ?????A ? B ???? abc ???

Makefile ??????

$^?????

$^ ?????????????????????Makefile ?????????????

$@?????

$@ ?????????????????.o????????????

$<????????

$< ?????????????????

$????????

$? ?????????????????

%????

% ?Makefile ??????????????????%.o ????.o???

??

test : a.o b.o    gcc -o test $^%.o : %.c    gcc -c -o $@ $<

???????$^ ????? a.o ? b.o?????????????

Makefile ???????

Makefile ???????????????????????????

?????

  • $(subst form,to,text)?? text ????? form ? to????

    $(subst ee,EE,feet on the street)

    ????fEET on the strEET

  • $(patsubst pattern,replacement,text)??? text ??? pattern ?????????

    $(patsubst %.c,%.o,a.c.c bar.c)

    ????a.c.o bar.o

?????

  • $(dir names...)???????????????

    $(dir src/foo.c hacks)

    ????src/ ./

  • $(notdir names...)????????????????

    $(notdir src/foo.c hacks)

    ????foo.c hacks

  • $(suffix names...)???????????????

    $(suffix src/foo.c src-1.0/bar.c hacks)

    ????.c .c

  • $(basename names...)?????????????

    $(basename src/foo.c src-1.0/bar.c hacks)

    ????src/foo src-1.0/bar hacks

  • $(addsuffix suffix,names...)???????????

    $(addsuffix .c,foo bar)

    ????foo.c bar.c

  • $(addprefix prefix,names...)???????????

    $(addprefix src/,foo bar)

    ????src/foo src/bar

  • $(join list1,list2)??????????????

    $(join aaa bbb, 111 222 333)

    ????aaa111 bbb222 333

Makefile ?????

  • $(foreach var,list,text)??????????????? text????

    dirs := a b c dfiles := $(foreach dir,$(dirs),$(wildcard $(dir)/*))

    ???? files ??????????

  • ?????? $(if ...), $(value ...), $(eval ...), $(call ...), $(origin ...), $(shell ...), ??

Makefile ? .PHONY ??

???? make ????????????????????????? .PHONY ???

???

.PHONY: cleanclean:    rm -f *.o test

?? clean ?????make clean ????????? .PHONY ?????????

Makefile ???? @ ??

? Makefile ?????? @ ??????????

???

@echo ???? XXX ??......

??????

???? XXX ??......

???? make -n ? --just-print?Makefile ????????????

Makefile ??????

????

  • A := $(C)
  • ??????????????

????

  • B = $(C)
  • ???????????????????????????????

???

  • ?=???????????????????
  • +?????????????????????

??

A := $(C)B = $(C)C = abc

?? all?

all:    @echo A = $(A)    @echo B = $(B)    @echo C = $(C)

?????

A = abcB = abcC = abc

??????

C ?= 123

?????

A = abcB = abcC = 123

Makefile ?????

Makefile ????????????????????????

  • VPATH?????????
  • SHELL??? shell ??????
  • MAKEFLAGS??? make ??????
  • MAKELEVEL??? make ?????
  • CURDIR???????

转载地址:http://zgvjz.baihongyu.com/

你可能感兴趣的文章
python filter过滤器的使用_python基础知识分享:zip()、filter函数和reduce如何使用?...
查看>>
python flask 请求code 400, message Bad request version
查看>>
Python Flink Stateful函数入口上的Kafka键访问
查看>>
Python float - str - 浮动怪异
查看>>
Python Flower库:分布式任务管理与监控
查看>>
Python for 循环和迭代器行为
查看>>
Python For循环多次返回
查看>>
Python ftplib - 指定端口
查看>>
Python furl库:一键搞定复杂URL操作
查看>>
Python GC 也会关闭文件吗?
查看>>
python gen_key.py 报错 提示找不到OpenSSL lib
查看>>
python getattrribute_Python学习——面向对象高级之反射
查看>>
Python进阶语法:字典推导式
查看>>
python gil_Python中GIL的使用详解
查看>>
python glob.glob使用
查看>>
python glob的安装和使用
查看>>
Python google drive API 下载,文件在哪里?
查看>>
Python GPS 模块:读取最新的 GPS 数据
查看>>
python grpc入门
查看>>
python gRPC测试helloworld
查看>>