9How to Run make

Arguments to Specify the Goals

The goals are the targets that make should strive ultimately to update.

By default, the goal is the first target in the makefile (not counting targets that start with a period).

You can also specify a different goal or goals with command line arguments to make.
Use the name of the goal as an argument.
If you specify several goals, make processes each of them in turn, in the order you name them.

Any target in the makefile may be specified as a goal.
Even targets not in the makefile may be specified, if make can find implicit rules that say how to make them.
和其他target一样,也需要在Makefile中写规则,只不过名字约定俗成
#Copy the executable file into a directory that users typically search for commands;
#Copy any auxiliary files that the executable uses into the directories where it will look for them.
install
#Delete all files that are normally created by running make.
clean
#Make all the top-level targets the makefile knows about.
all

Instead of Executing Recipes

#Causes make to print the recipes that are needed to make the targets up to date, but not actually execute them.
-n

Overriding Variables

For example, if you say ‘make CFLAGS='-g -O'’, each C compilation will be done with ‘cc -c -g -O’.
If you specify a value in this way,all ordinary assignments of the same variable in the makefile are ignored.
we say they have been overridden by the command line argument.

When you override a variable with a command line argument, you can define either a recursively-expanded variable
or a simply-expanded variable.
The examples shown above make a recursively-expanded variable;to make a simply-expanded variable, write ‘:=’ or
‘::=’ instead of ‘=’.

But, unless you want to include a variable reference or function call in the value that you specify,it makes no
difference which kind of variable you create.
#Make will set the special variable MAKECMDGOALS to the list of goals you specified on the command line.
#将hello,how,are,you视为target\goal, 将VAR=value视为变量定义
#将-d,--debug=n视为option
make hello VAR=value how are -d you --debug=n

https://www.gnu.org/software/make/manual/html_node/Running.html
https://www.gnu.org/software/make/manual/html_node/Standard-Targets.html
https://www.gnu.org/software/make/manual/html_node/Complex-Makefile.html
https://www.gnu.org/software/coreutils/manual/html_node/install-invocation.html
https://man7.org/linux/man-pages/man1/install.1.html
https://man7.org/linux/man-pages/man1/make.1.html
https://askubuntu.com/questions/1410401/arguments-for-make
https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html
https://makefiletutorial.com/
https://www.sas.upenn.edu/~jesusfv/Chapter_HPC_6_Make.pdf
https://faculty.cs.byu.edu/~rodham/cs240/make-tutorial.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值