博客
关于我
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:矩形参数无效
查看>>
Python:语法进阶
查看>>
Python:调用复制函数时调用 Python 对象时超出了最大递归深度
查看>>
Python:这两个 import 语句有什么区别?
查看>>
Python:通过串口从 Velleman k8090 读取数据
查看>>
python:遍历具有列表值的字典
查看>>
Python:降低精度 pandas 时间戳数据帧
查看>>
python:非阻塞子进程,检查标准输出
查看>>
PythonABC多重继承
查看>>
Pythonargparse中的多个参数
查看>>
Python关于 *args 和 **kwargs 参数的详解(全)
查看>>
Pythonfrozenset散列算法/实现
查看>>
PythonGTK+3:通过单击列对树视图进行排序
查看>>
pythonnumpy生成二进制流_python/numpy生成的二进制文件,由C读取
查看>>
pythonsign函数_对python函数签名的方法详解 用python怎么写一个自签名证书
查看>>
PythonStudy
查看>>
Pythons__IMPORT__未按预期工作
查看>>
Pythont通过request以及BeautifulSoup爬取几千条情话
查看>>
pythonweb django的学习
查看>>
pythonweb网站开发基础django安装
查看>>