scripts/Makefile.*

Documentations/kbuild/makefiles.txt に以下な記述がある。

scripts/Makefile.* contains all the definitions/rules etc. that
are used to build the kernel based on the kbuild makefiles.

scripts ディレクトリには以下が存在。

一つづつ見るか、とか思ったりしたのですが fwinst とか意味不明。

headers_install

なんか grep してみたら Documentations/make/headers_install.txt とかいうドキュメントがあるな。てーか、よく分からなくなってきた。。

  make headers_install ARCH=i386 INSTALL_HDR_PATH=/usr/include

な呼び出し例がナニされてるんですが、top の Makefile に以下な記述がありまして

headers_install: __headers
	$(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
	$(error Headers not exportable for the $(SRCARCH) architecture))
	$(Q)$(MAKE) $(hdr-inst)=include
	$(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst)

ちなみに Makefile.headersinst に以下な記述があります。

# Recursion
hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj

えー、って思ってたら top な Makefile にも記述がありました。hdr-dir とか hdr-dst とかも謎だなぁ、と思ってたら記述あり。

#Default location for installed headers
export INSTALL_HDR_PATH = $(objtree)/usr

hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
# Find out where the Kbuild file is located to support
# arch/$(ARCH)/include/asm
hdr-dir = $(strip                                                         \
          $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \
               arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch)))

# If we do an all arch process set dst to asm-$(hdr-arch)
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)

fwinst

ふむふむ、ということで再度 fwinst を grep してみたら Makefile に記述がある模様。

# Firmware install
INSTALL_FW_PATH=$(INSTALL_MOD_PATH)/lib/firmware
export INSTALL_FW_PATH

PHONY += firmware_install
firmware_install: FORCE
	@mkdir -p $(objtree)/firmware
	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install

とか

#	Build modules
#
#	A module can be listed more than once in obj-m resulting in
#	duplicate lines in modules.order files.  Those are removed
#	using awk while concatenating to the final file.

PHONY += modules
modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
	$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
	@$(kecho) '  Building modules, stage 2.';
	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild

とか

# This depmod is only for convenience to give the initial
# boot a modules.dep even before / is mounted read-write.  However the
# boot script depmod is the master version.
PHONY += _modinst_post
_modinst_post: _modinst_
	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modinst
	$(call cmd,depmod)

とか。ええと、こいつらを使ってるソレを探してみれば良いのか。まず firmware_install で以下。

次は modules ってこれは略かな。てか、make modules ってどう進むのか。あるいは _modinst_post ターゲットは modules_install ターゲットが依存しているソレらしい。
とりあえず fwinst がナニなケイスというのは firmware/Makefile に記述されてる以下なソレって見ておけば良いのか。

# There are three cases to care about:
# 1. Building kernel with CONFIG_FIRMWARE_IN_KERNEL=y -- $(fw-shipped-y) should
#    include the firmware files to include, according to .config
# 2. 'make modules_install', which will install firmware for modules, and 
#    _also_ for the in-kernel drivers when CONFIG_FIRMWARE_IN_KERNEL=n
# 3. 'make firmware_install', which installs all firmware, unconditionally.

Makefile.build

scripts/Kbuild.include にて以下な定義。

###
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
# Usage:
# $(Q)$(MAKE) $(build)=dir
build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj

$(obj) とゆーナニはここで設定されてるのか。あと、Makefile.build からは以下が include されている模様。

     31:-include include/config/auto.conf
     33:include scripts/Kbuild.include
     41:include $(kbuild-file)
     49:include scripts/Makefile.lib
     58:# Do not include host rules unless needed
     60:include scripts/Makefile.host
     73:$(warning kbuild: Makefile.build is included improperly)
    377:  include $(cmd_files)

とほほ

途中で何してるかわけわかめな件について。
scripts/Makefile.* は様々な定義やルールなどがあるので云々ってあったので確認していたのでした。
しかし何故に makefiles.txt なのかと。ちょっと昼間の仕事対応で諸々ばたばたしておりまして、こっち方面微妙だな。もう少しざっくり読んで arch/arm 方面に去ろう。