GNU make manual 翻译( 一百三十七)

简介:

继续翻译

复制代码
Choosing a Shell in DOS and Windows
...................................

Choosing a shell in MS-DOS and MS-Windows is much more complex than on
other systems.

   On MS-DOS, if `SHELL' is not set, the value of the variable
`COMSPEC' (which is always set) is used instead.

   The processing of lines that set the variable `SHELL' in Makefiles
is different on MS-DOS.  The stock shell, `command.com', is
ridiculously limited in its functionality and many users of `make' tend
to install a replacement shell.  Therefore, on MS-DOS, `make' examines
the value of `SHELL', and changes its behavior based on whether it
points to a Unix-style or DOS-style shell.  This allows reasonable
functionality even if `SHELL' points to `command.com'.

   If `SHELL' points to a Unix-style shell, `make' on MS-DOS
additionally checks whether that shell can indeed be found; if not, it
ignores the line that sets `SHELL'.  In MS-DOS, GNU `make' searches for
the shell in the following places:

  1. In the precise place pointed to by the value of `SHELL'.  For
     example, if the makefile specifies `SHELL = /bin/sh', `make' will
     look in the directory `/bin' on the current drive.

  2. In the current directory.

  3. In each of the directories in the `PATH' variable, in order.


   In every directory it examines, `make' will first look for the
specific file (`sh' in the example above).  If this is not found, it
will also look in that directory for that file with one of the known
extensions which identify executable files.  For example `.exe',
`.com', `.bat', `.btm', `.sh', and some others.

   If any of these attempts is successful, the value of `SHELL' will be
set to the full pathname of the shell as found.  However, if none of
these is found, the value of `SHELL' will not be changed, and thus the
line that sets it will be effectively ignored.  This is so `make' will
only support features specific to a Unix-style shell if such a shell is
actually installed on the system where `make' runs.

   Note that this extended search for the shell is limited to the cases
where `SHELL' is set from the Makefile; if it is set in the environment
or command line, you are expected to set it to the full pathname of the
shell, exactly as things are on Unix.

   The effect of the above DOS-specific processing is that a Makefile
that contains `SHELL = /bin/sh' (as many Unix makefiles do), will work
on MS-DOS unaltered if you have e.g. `sh.exe' installed in some
directory along your `PATH'.
复制代码

在DOS 或者 Windows中选择shell
...................................

Choosing a shell in MS-DOS and MS-Windows is much more complex than on
other systems.

在 MS-DOS 或者 MS-Windows 上选择一个shell, 比在其他系统上复杂多了。

在 MS-DOS , 如果 SHELL 没有设定,那么变量 COMSPEC 会被使用。

在 makefile里面的,对SHELL 的设定方式, 在 MS-DOS 上的表现,也有所不同。

陈旧的shell--command.com',被荒谬地限制在自己的功能里,很多make用户想要安装一个替代性的shell。

因此,在 MS-DOS, make 检查 SHELL 的值,根据它指向Unix 类型的shell 还是 DOS 类型的shell, 来决定自身的行为。
这可以保证合理的功能,甚至在 SHELL 指向了 command.com 时也是如此。

如果 SHELL 指向了一个 Unix 类型的shell, 那么在 MS-DOS 系统上的 make 要检查是否此shell 真的存在;如果没有,它就忽略那些使用SHELL 的行。在MS-DOS中, GNU make 搜索如下的地方:

1. 在SHELL 的值所精确指定的位置,例如,如果makefile 指定了 SHELL=/bin/sh,make 会搜索 当前驱动器的/bin目录。

2. 在当前目录。

3. 按照顺序搜索PATH 变量中指定的路径。

在每一个它所检查的目录,make 会先看看特定的文件(上述例子中的sh), 如果没有找到,它也会看看那些可知兴文锦,如.exe, .com,.bat,.btm,.sh 之类。

如果以上任何一个努力得到了成功,SHELL 的值回被设定为所找到的SHELL的全路径名。但是,如果没有找到,SHELL的值不会改变,设置它的行就会被无视。这也是 如果确实存在一个shell在此系统中存在,make 会仅仅支持 UNIX 类型的特定功能的原因。

请注意这个对shell的扩展搜索仅限于SHELL 被Makefile设置的场合;如果它被在环境变量或者命令行设置,你需要设置其完整路径名,就像那些在Unix中的一样。

上述DOS特定的处理效果是,一个包含 SHELL=/bin/sh 的makefile,如果你有诸如sh.exe 文件在你的PATH中,将要在MS-DOS 上正常无损地工作。

后文待续





本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/09/29/2707602.html,如需转载请自行联系原作者

目录
相关文章
|
Linux C语言
make: gcc:命令未找到
make: gcc:命令未找到
make: gcc:命令未找到
|
7月前
|
编译器 Linux 开发工具