History

kbuild: introduce hostprogs-always-y and userprogs-always-y

To build host programs, you need to add the program names to 'hostprogs' to use the necessary build rule, but it is not enough to build them because there is no dependency. There are two types of host programs: built as the prerequisite of another (e.g. gen_crc32table in lib/Makefile), or always built when Kbuild visits the Makefile (e.g. genksyms in scripts/genksyms/Makefile). The latter is typical in Makefiles under scripts/, which contains host programs globally used during the kernel build. To build them, you need to add them to both 'hostprogs' and 'always-y'. This commit adds hostprogs-always-y as a shorthand. The same applies to user programs. net/bpfilter/Makefile builds bpfilter_umh on demand, hence always-y is unneeded. In contrast, programs under samples/ are added to both 'userprogs' and 'always-y' so they are always built when Kbuild visits the Makefiles. userprogs-always-y works as a shorthand.

Masahiro Yamada committed 6 years ago

Commit faabed21 parent 85569d122 files · +78 −55Browse files

Showing the changes to scripts (9 of 22 files). Show all

Unified · Split

9 files
  1. scripts/Makefile +8 −10
  2. scripts/Makefile.clean +9 −3
  3. scripts/Makefile.lib +11 −0
  4. scripts/basic/Makefile +1 −2
  5. scripts/dtc/Makefile +2 −3
  6. scripts/genksyms/Makefile +1 −2
  7. scripts/mod/Makefile +2 −2
  8. scripts/selinux/genheaders/Makefile +1 −3
  9. scripts/selinux/mdp/Makefile +1 −2
scripts/Makefile+8−10
@@ -3,14 +3,14 @@ · 2 unmodified lines
33 # scripts contains sources for various helper programs used throughout
44 # the kernel for the build process.
55
6−always-$(CONFIG_BUILD_BIN2C) += bin2c
7−always-$(CONFIG_KALLSYMS) += kallsyms
8−always-$(BUILD_C_RECORDMCOUNT) += recordmcount
9−always-$(CONFIG_BUILDTIME_TABLE_SORT) += sorttable
10−always-$(CONFIG_ASN1) += asn1_compiler
11−always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
12−always-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
13−always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
6+hostprogs-always-$(CONFIG_BUILD_BIN2C) += bin2c
7+hostprogs-always-$(CONFIG_KALLSYMS) += kallsyms
8+hostprogs-always-$(BUILD_C_RECORDMCOUNT) += recordmcount
9+hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT) += sorttable
10+hostprogs-always-$(CONFIG_ASN1) += asn1_compiler
11+hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
12+hostprogs-always-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
13+hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
1414
1515 HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
1616 HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
@@ -26,8 +26,6 @@ HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED · 9 unmodified lines
2626 HOSTLDLIBS_sorttable = -lpthread
2727 endif
2828
29−hostprogs := $(always-y) $(always-m)
30−
3129 # The following programs are only built on demand
3230 hostprogs += unifdef
3331
scripts/Makefile.clean+9−3
@@ -27,9 +27,15 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) · 26 unmodified lines
2727 # build a list of files to remove, usually relative to the current
2828 # directory
2929
30−__clean-files := $(extra-y) $(extra-m) $(extra-) \
31− $(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \
32− $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) $(userprogs)
30+__clean-files := \
31+ $(clean-files) $(targets) $(hostprogs) $(userprogs) \
32+ $(extra-y) $(extra-m) $(extra-) \
33+ $(always-y) $(always-m) $(always-) \
34+ $(hostprogs-always-y) $(hostprogs-always-m) $(hostprogs-always-) \
35+ $(userprogs-always-y) $(userprogs-always-m) $(userprogs-always-)
36+
37+# deprecated
38+__clean-files += $(always) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
3339
3440 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
3541
scripts/Makefile.lib+11−0
@@ -68,6 +68,17 @@ real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) · 67 unmodified lines
6868
6969 always-y += $(always-m)
7070
71+# hostprogs-always-y += foo
72+# ... is a shorthand for
73+# hostprogs += foo
74+# always-y += foo
75+hostprogs += $(hostprogs-always-y) $(hostprogs-always-m)
76+always-y += $(hostprogs-always-y) $(hostprogs-always-m)
77+
78+# userprogs-always-y is likewise.
79+userprogs += $(userprogs-always-y) $(userprogs-always-m)
80+always-y += $(userprogs-always-y) $(userprogs-always-m)
81+
7182 # DTB
7283 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
7384 extra-y += $(dtb-y)
scripts/basic/Makefile+1−2
@@ -2,5 +2,4 @@ · 1 unmodified line
22 #
33 # fixdep: used to generate dependency information during build process
44
5−hostprogs := fixdep
6−always-y := $(hostprogs)
5+hostprogs-always-y += fixdep
scripts/dtc/Makefile+2−3
@@ -1,9 +1,8 @@
11 # SPDX-License-Identifier: GPL-2.0
22 # scripts/dtc makefile
33
4−hostprogs := dtc
5−always-$(CONFIG_DTC) += $(hostprogs)
6−always-$(CHECK_DT_BINDING) += $(hostprogs)
4+hostprogs-always-$(CONFIG_DTC) += dtc
5+hostprogs-always-$(CHECK_DT_BINDING) += dtc
76
87 dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
98 srcpos.o checks.o util.o
scripts/genksyms/Makefile+1−2
@@ -1,7 +1,6 @@
11 # SPDX-License-Identifier: GPL-2.0
22
3−hostprogs := genksyms
4−always-y := $(hostprogs)
3+hostprogs-always-y += genksyms
54
65 genksyms-objs := genksyms.o parse.tab.o lex.lex.o
76
scripts/mod/Makefile+2−2
@@ -1,8 +1,8 @@
11 # SPDX-License-Identifier: GPL-2.0
22 OBJECT_FILES_NON_STANDARD := y
33
4−hostprogs := modpost mk_elfconfig
5−always-y := $(hostprogs) empty.o
4+hostprogs-always-y += modpost mk_elfconfig
5+always-y += empty.o
66
77 modpost-objs := modpost.o file2alias.o sumversion.o
88
scripts/selinux/genheaders/Makefile+1−3
@@ -1,7 +1,5 @@
11 # SPDX-License-Identifier: GPL-2.0
2−hostprogs := genheaders
2+hostprogs-always-y += genheaders
33 HOST_EXTRACFLAGS += \
44 -I$(srctree)/include/uapi -I$(srctree)/include \
55 -I$(srctree)/security/selinux/include
6−
7−always-y := $(hostprogs)
scripts/selinux/mdp/Makefile+1−2
@@ -1,8 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
2−hostprogs := mdp
2+hostprogs-always-y += mdp
33 HOST_EXTRACFLAGS += \
44 -I$(srctree)/include/uapi -I$(srctree)/include \
55 -I$(srctree)/security/selinux/include -I$(objtree)/include
66
7−always-y := $(hostprogs)
87 clean-files := policy.* file_contexts