[cheat sheet] Make

1.

#comments

 

2.

#variable assignments

var1=val1

 

3.

#variable reference

$(var1)

 

#dereference a variable

$$(var1)

 

4.

#rules

target : dependency1 denpendency2 ... dependencyN

 

5.

<tab> command

 

Normally, when make encounters a command that returns a nonzero status code to the shell, it will stop execution and display an error message—but if you use a leading dash, it will just
ignore the error and continue.

 

<tab> -command

 

A command prefixed with an at sign tells make not to perform its normal behavior of printing the command to the stdout device as it executes it.

<tab> @command

 

6. 

make executes each command in a separate shell, so we need run many commands in the same shell via a trailing backslash, be sure that there are no spaces or other invisible characters after it.

foo: bar.c

    sources=bar.c; \
    gcc -o foo $${sources}

 

7.  

Variables referenced in commands are bound to their value when make start a shell for execution.

 

...
mytarget=foo
$(mytarget): $(mytarget).c
    gcc -o $(mytarget) $(mytarget).c
    
mytarget=bar
...

 

equals

 

...
foo: foo.c
    gcc -o bar bar.c
...

  

8.

automatic variables

$@ - the full target name of the current target

 

9.

implicit rule

 

10.

phony target is a target which is  not file. E.g., all, clean.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值