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/Makefile.lib (1 of 22 files). Show all

Unified · Split

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)