makefile := 用法

发布时间:2014-10-23 23:27:48
来源:分享查询网

使用":="操作符 前面的變量不能使用後面的變量,只能使用前面已定義好的變量 如果是使用"="就可以使用後面的變量   轉載自http://toucware.blogspot.tw/2012/09/what-is-colon-equals-sign-in-makefiles.html In Linux makefiles, you will often see a notation which looks like this: This is called "expansion assignment". So what is the difference between expansion assignment and ordinary variable assignment ( = )?  Let's get straight into a coding example: So nothing unexpected or unusual here!  But lets try the same thing using expansion assignment ( := ): Oh no! It appears that we have a frog instead of the porcupine we wanted.  So what happened? When using the equals sign the variable is only expanded when used.  In other words, when we run test. In the second example we used ":=".  This means that the variable is expanded at the time of assignment.  If we want to see PORCUPINE again in the second example, we need to make a slight modification to it:

返回顶部
查看电脑版