gmake和make有什么区别?

Nic*_*dad 121 makefile build gnu-make

我想了解'gmake'和'make'之间的区别?

在我的linux盒子上,它们完全相同:

% gmake --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

% make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Run Code Online (Sandbox Code Playgroud)

我猜这在所有平台上都不一样?是否有充分的理由使用其中一个?
为什么有这两个名字有一些历史意义吗?

bdo*_*lan 157

'gmake'专指GNU make.'make'是指系统的默认make实现; 在大多数Linux发行版中,这是GNU make,但在其他unix上,它可以引用make的其他一些实现,例如BSD make,或各种商业unix的make实现.

GNU make接受的语言是传统make实用程序支持的语言的超集.

通过特别使用'gmake',您可以使用GNU make扩展,而不必担心它们会被其他一些make实现误解.

  • 好答案.请注意,gcc和cc遵循相同的约定 (24认同)
  • 它也适用于其他gtools:例如,gawk和gtar是在Solaris上绊倒的人. (4认同)
  • GNU Make在其语言扩展中不提供兼容的功能超集.例如,$ ^在gmake(1)中不存在,但在其BSD的pmake(1)中存在.当尝试编写可供GNU Make和pmake使用的Makefile时,这会导致灾难性的结果(设计无害的例子,想象:`gcc -o $ @ $ <`= gmake没有输入源,因为$ <评估为空字符串.存在可能导致gcc clobbering文件的更糟糕的组合. (2认同)
  • @Sean关于`$ ^`是什么?[具有该名称的变量](https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html)当然存在于GNU Make中,据我所知与旧版Make兼容。BSD中的语义是否有所不同? (2认同)

dim*_*mba 10

在我的系统上没有区别(gmake是软链接):

-> ls -l $(which gmake make)
lrwxrwxrwx 1 root root      4 Jun  5  2007 /usr/bin/gmake -> make
-rwxr-xr-x 1 root root 168976 Jul 13  2006 /usr/bin/make
Run Code Online (Sandbox Code Playgroud)

gmake代表GNU make.make的实现有所不同.在Linux机器上最有可能由GNU制造并使用户的生命更加柔和地链接到gmake.