GNU make manual 翻译(四十七)

继续翻译

3.4 The Variable `MAKEFILES'                            
============================                            
                            
If the environment variable `MAKEFILES' is defined, `make' considers 
its value as a list of names (separated by whitespace) of additional
makefiles to be read before the others.  This works much like the 
`include' directive: various directories are searched for those files  
(*note Including Other Makefiles: Include.).  In addition, the default 
goal is never taken from one of these makefiles (or any makefile 
included by them) and it is not an error if the files listed in  
`MAKEFILES' are not found.                            
                            
   The main use of `MAKEFILES' is in communication between recursive 
invocations of `make' (*note Recursive Use of `make': Recursion.).  It 
usually is not desirable to set the environment variable before a 
top-level invocation of `make', because it is usually better not to 
mess with a makefile from outside.  However, if you are running `make' 
without a specific makefile, a makefile in `MAKEFILES' can do useful  
things to help the built-in implicit rules work better, such as    
defining search paths (*note Directory Search::).                            
                            
   Some users are tempted to set `MAKEFILES' in the environment
automatically on login, and program makefiles to expect this to be done.
This is a very bad idea, because such makefiles will fail to work if 
run by anyone else.  It is much better to write explicit `include' 
directives in the makefiles.  *Note Including Other Makefiles: Include.  

3.4 变量 MAKEFILES

如果 环境变量 MAKEFILES 被定义了,那么 make 会在读取其他 makefile之前,先读取 MAKEFILES定义的列表中的名字(由空格分隔)。这有点像 include 指令:各目录会被搜索(*note Including Other Makefiles:Include.)。并且,缺省的终点也不会从这些makefile(或被其包含的makefile)中获得,如果找不到相应的 makefile, 也不会报错。

 

'MAKEFILES' 的主要用途是在 递归调用(*note Recursive Use of 'make') make 时进行通信。

通常在顶层调用 make 之前,是不推荐设置 此环境变量的,因为通常最好不要和外面的makefile混淆。

但是如果你运行 make 时,没有指定一个特定的 makefile, 那么 MAKEFILES 中定义的 makefile可以做一些有益的事情来帮助使隐式规则运行得更好,例如定义搜索路径(*note Directory Search)

 

有些用户试图在设置在 登录后自动设置 MAKEFILES 环境变量,并且编排 makefile使得此种设定生效。

这是一个坏主意,因为如此一来,它同时被其他人运行时,就会出错退出。更好的办法是在 makefile中写include 指令。 *Note Including Other Makefiles: Include.

后文待续

你可能感兴趣的:(Make)