2007年3月20日 星期二

Understand the Linux Makefile system

Makefile 的組成 (compoments)
1. explicit rules
2. implicit rules
3. variable definitions
4. directives
5. comments


1. 利用 origin function 可以知道某一個變數是從何處來的

Example:
ifdef V
ifeq ("$(origin V)", "command line")



The result of this function is a string telling you how the variable variable was defined:

`undefined'
if variable was never defined.
`default'
if variable has a default definition, as is usual with CC and so on. See Variables Used by Implicit Rules. Note that if you have redefined a default variable, the origin function will return the origin of the later definition.
`environment'
if variable was defined as an environment variable and the `-e' option is not turned on (see Summary of Options).
`environment override'
if variable was defined as an environment variable and the `-e' option is turned on (see Summary of Options).
`file'
if variable was defined in a makefile.
`command line'
if variable was defined on the command line.
`override'
if variable was defined with an override directive in a makefile (see The override Directive).
`automatic'
if variable is an automatic variable defined for the execution of the commands for each rule (see Automatic Variables).

沒有留言: