kbuild: move headers_check rule to usr/include/Makefile
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 7 Nov 2019 07:14:41 +0000 (16:14 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 14 Nov 2019 15:23:10 +0000 (00:23 +0900)
Currently, some sanity checks for uapi headers are done by
scripts/headers_check.pl, which is wired up to the 'headers_check'
target in the top Makefile.

It is true compiling headers has better test coverage, but there
are still several headers excluded from the compile test. I like
to keep headers_check.pl for a while, but we can delete a lot of
code by moving the build rule to usr/include/Makefile.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Makefile
lib/Kconfig.debug
scripts/Makefile.headersinst
usr/include/Makefile

index a45291d8470a62889702a8f1f4f5420bfde883e6..ad6340ac90ba71c831f97bbd2a4c0d6895f23451 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1193,19 +1193,15 @@ headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
        $(Q)$(MAKE) $(hdr-inst)=include/uapi
        $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
 
+# Deprecated. It is no-op now.
 PHONY += headers_check
-headers_check: headers
-       $(Q)$(MAKE) $(hdr-inst)=include/uapi HDRCHECK=1
-       $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi HDRCHECK=1
+headers_check:
+       @:
 
 ifdef CONFIG_HEADERS_INSTALL
 prepare: headers
 endif
 
-ifdef CONFIG_HEADERS_CHECK
-all: headers_check
-endif
-
 PHONY += scripts_unifdef
 scripts_unifdef: scripts_basic
        $(Q)$(MAKE) $(build)=scripts scripts/unifdef
@@ -1473,7 +1469,6 @@ help:
        @echo  '  versioncheck    - Sanity check on version.h usage'
        @echo  '  includecheck    - Check for duplicate included header files'
        @echo  '  export_report   - List the usages of all exported symbols'
-       @echo  '  headers_check   - Sanity check on exported headers'
        @echo  '  headerdep       - Detect inclusion cycles in headers'
        @echo  '  coccicheck      - Check with Coccinelle'
        @echo  ''
index 93d97f9b015714493715297fd49a5be1b457df69..f61d834e02fee6906a9e8acaa02eef2fef7dc597 100644 (file)
@@ -299,17 +299,6 @@ config HEADERS_INSTALL
          user-space program samples. It is also needed by some features such
          as uapi header sanity checks.
 
-config HEADERS_CHECK
-       bool "Run sanity checks on uapi headers when building 'all'"
-       depends on HEADERS_INSTALL
-       help
-         This option will run basic sanity checks on uapi headers when
-         building the 'all' target, for example, ensure that they do not
-         attempt to include files which were not exported, etc.
-
-         If you're making modifications to header files which are
-         relevant for userspace, say 'Y'.
-
 config OPTIMIZE_INLINING
        def_bool y
        help
index 1b405a7ed14fcfe3df8c6198041facd6b06a7f99..708fbd08a2c51d9321ac251605589c1e7a877005 100644 (file)
@@ -56,9 +56,6 @@ new-dirs      := $(filter-out $(existing-dirs), $(wanted-dirs))
 $(if $(new-dirs), $(shell mkdir -p $(new-dirs)))
 
 # Rules
-
-ifndef HDRCHECK
-
 quiet_cmd_install = HDRINST $@
       cmd_install = $(CONFIG_SHELL) $(srctree)/scripts/headers_install.sh $< $@
 
@@ -81,21 +78,6 @@ existing-headers := $(filter $(old-headers), $(all-headers))
 
 -include $(foreach f,$(existing-headers),$(dir $(f)).$(notdir $(f)).cmd)
 
-else
-
-quiet_cmd_check = HDRCHK  $<
-      cmd_check = $(PERL) $(srctree)/scripts/headers_check.pl $(dst) $(SRCARCH) $<; touch $@
-
-check-files := $(addsuffix .chk, $(all-headers))
-
-$(check-files): $(dst)/%.chk : $(dst)/% $(srctree)/scripts/headers_check.pl
-       $(call cmd,check)
-
-__headers: $(check-files)
-       @:
-
-endif
-
 PHONY += FORCE
 FORCE:
 
index 325f4d0f2e73d871235fde353b71b584ccdc216f..24543a30b9f018e4f2b478ed0eaee94b37b297ef 100644 (file)
@@ -95,11 +95,14 @@ endif
 # asm-generic/*.h is used by asm/*.h, and should not be included directly
 header-test- += asm-generic/%
 
-extra-y := $(patsubst %.h,%.hdrtest, $(filter-out $(header-test-), \
-               $(patsubst $(obj)/%,%, $(shell find $(obj) -name '*.h'))))
+extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h'))
 
 quiet_cmd_hdrtest = HDRTEST $<
-      cmd_hdrtest = $(CC) $(c_flags) -S -o /dev/null -x c /dev/null -include $<; touch $@
+      cmd_hdrtest = \
+               $(CC) $(c_flags) -S -o /dev/null -x c /dev/null \
+                       $(if $(filter-out $(header-test-), $*.h), -include $<); \
+               $(PERL) $(srctree)/scripts/headers_check.pl $(obj) $(SRCARCH) $<; \
+               touch $@
 
 $(obj)/%.hdrtest: $(obj)/%.h FORCE
        $(call if_changed_dep,hdrtest)