【编译工具】几种常用make的介绍和分析(gmake,nmake,cmake,dmake,bmake)

DATE:2018.12.21


1、参考

http://www.it610.com/article/2154508.htm
https://blog.csdn.net/tsaiyong_ahnselina/article/details/17554337
https://en.wikipedia.org/wiki/Make_(software)

2、几种常用make的介绍

1). gmake: GNU make,也是Linux/Unix系统下通用的make

2). bmake:BSD make,freebsd系统自带的make是BSD make。

3). dmake:是同GNU Make类似的一个工具。其命令格式自成一体,但是可以适用于Linux, Solaris, and Win32 and other platforms。Dmake有一个变种,被OpenOffice.org使用。dmake 是一个命令行工具,与 make(1) 兼容。dmake 能够以网格、分布、并行或串行模式生成目标。如果使用的是标准 make(1) 实用程序,在对 makefile 进行任何更改时可以毫不费力地过渡到使用 dmake。dmake 是 make 实用程序的超集。

4). nmake: Windows系统下自带的make,一般在$(VCInstallDir)/bin目录下面。

5).cmake: CMake是一个跨平台的安装(编译)工具,可以用简单的语句来描述所有平台的安装(编译过程)。他能够输出各种各样的makefile或者project文件,能测试编译器所支持的C++特性,类似UNIX下的automake。只是 CMake 的组态档取名为 CMakeLists.txt。Cmake 并不直接建构出最终的软件,而是产生标准的建构档(如 Unix 的 Makefile 或 Windows Visual C++ 的 projects/workspaces),然后再依一般的建构方式使用。这使得熟悉某个集成开发环境(IDE)的开发者可以用标准的方式建构他的软件,这种可以使用各平台的原生建构系统的能力是 CMake 和 SCons 等其他类似系统的区别之处。

详细参考:https://en.wikipedia.org/wiki/Make_(software)

3、GNU make与Windows Nmake的异同点

参考自:https://blog.csdn.net/tsaiyong_ahnselina/article/details/17554337

3.1、自动变量的区别
GNU make的自动变量 Windows Nmake自动变量
$@:The file name of the target of the rule.
$%: The target member name, when the target is an archive member. $(@): Current target’s full name (path, base name, extension), as currently specified.
$$@ $$@: Current target’s full name (path, base name, extension), as currently specified. Valid only as a dependent in a dependency.
$*: 这个变量表示目标模式中"%"及其之前的部分 (少用) $*: Current target’s path and base name except file extension.
$?: The names of all the prerequisites that are newer than the target, with spaces between them.
$^: The names of all the prerequisites, with spaces between them.
$|: The names of all the order-only prerequisites, with spaces between them. $?: All dependent files in the dependency with a later timestamp than the target
$**: All dependents of the current target.
$<: The name of the first prerequisite. If the target got its recipe from an implicit rule, this will be the first prerequisite added by the implicit rule $<: Dependent file with a later timestamp than the current target. Valid only in commands in inference rules.
3.2、内置宏的一些区别
     NMAKE                               GNU MAKE
    ==========                           ==============
      !MESSAGE hello world                $(info hello world)

      !ERROR message                      $(error message)

      !INCLUDE filename                   include filename

      $(MAKEDIR)                          $(CURDIR)

      $(@D)                               $(@D:=)

      $(@F)                               $(@F)

      $(@B)                               $(basename $(@F))

      $(@R)                               $(basename $@)

      $(var:find=replace)                 $(subst find,replace,$(var))

      !IF "a" == "b"     (also !=)        ifeq (a, b) (also ifneq)
      ...                                 ...
      !ELSE                               else
      ...                                 ...
      !ENDIF                              endif

      !IFDE var   (also !IFNDEF)         ifdef var (also ifndef)
      ...                                 ...
      !ELSE                               else
      ...                                 ...
      !ENDIF                              endif
      
      !IF EXIST("filename")               ifeq ($(wildcard filename), filename)  (NOTE: Case-sensitive!)
      ...                                 ...
      !ELSE                               else
      ...                                 ...
      !ENDIF                              endif

      doit:                               define runit_cmd
         @echo <<runit.cmd >nul           ...$(1), $(2), $(3),...
         ...%1,%2,%3,...                  endef
         <<                               doit:
         @call runit.cmd x y z               $(call runit_cmd, x, y, z)

THE END!

原文地址:https://www.cnblogs.com/SoaringLee/p/10532194.html