Makefile.def 对比 Makefile.am

Makefile.def vs Makefile.am

我正在开发 linux binutils-2.29。 父目录下没有Makefile.am,所有子目录下都有Makefile.am.

在父目录中存在这些 Makefile:

Makefile  Makefile.def  Makefile.in  Makefile.tpl

Makefile.tpl 旁边有一条评论说 Makefile 是由 autogen Makefile.def

Makefile.tpl 生成的

但是子目录里面没有Makefile.def,当我运行autoreconf && automake它从Makefile.am

生成Makefile

Makefile.defMakefile.am 到底有什么区别?

What exactly is the difference between Makefile.def and Makefile.am?

让我们看看 GCC,大型项目也在使用 binutils。引用 Regenerating GCC Configuration:

The Makefile.in file is sometimes big, and can be generated by automake from a Makefile.am file. Some Makefile.in files (used to generate Makefile in the build tree) are generated by autogen from Makefile.tpl and Makefile.def files. Autogen is a (GUILE scriptable) tool designed to simplify the creation and maintenance of programs that contain large amounts of repetitious text.

所以区别实际上在于您希望如何以及在何处存储 autogen 将处理的输入文件部分。对于 GCC,它 Makefile.tpl 存储一个 模板 (用于生成输出 Makefile,而 Makefile.def 存储 定义 , autogen 将使用它。

例如,在 Makefile.tpl 中,您会发现这个用于填充 HOST_LIB_PATH 变量的模板(注意它使用 host_modules 变量):

# This is the list of directories that may be needed in RPATH_ENVVAR
# so that programs built for the host machine work.
HOST_LIB_PATH = [+ FOR host_modules +][+
  IF lib_path +]$(HOST_LIB_PATH_[+module+])[+ ENDIF lib_path +][+
  ENDFOR host_modules +]

Makefile.def 里面有 host_modules 的定义:

host_modules= { module= bfd; bootstrap=true; };
host_modules= { module= opcodes; bootstrap=true; };
// ...