~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/Makefile.headersinst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/Makefile.headersinst (Version linux-6.12-rc7) and /scripts/Makefile.headersinst (Version linux-4.12.14)


  1 # SPDX-License-Identifier: GPL-2.0             << 
  2 # ============================================      1 # ==========================================================================
  3 # Installing headers                                2 # Installing headers
  4 #                                                   3 #
  5 # All headers under include/uapi, include/gene      4 # All headers under include/uapi, include/generated/uapi,
  6 # arch/<arch>/include/uapi and arch/<arch>/inc      5 # arch/<arch>/include/uapi and arch/<arch>/include/generated/uapi are
  7 # exported.                                         6 # exported.
  8 # They are preprocessed to remove __KERNEL__ s      7 # They are preprocessed to remove __KERNEL__ section of the file.
  9 #                                                   8 #
 10 # ============================================      9 # ==========================================================================
 11                                                    10 
 12 PHONY := __headers                                 11 PHONY := __headers
 13 __headers:                                         12 __headers:
 14                                                    13 
 15 include $(srctree)/scripts/Kbuild.include      !!  14 include scripts/Kbuild.include
 16                                                    15 
 17 src := $(srctree)/$(obj)                       !!  16 srcdir        := $(srctree)/$(obj)
 18 gen := $(objtree)/$(subst include/,include/gen !!  17 
 19 dst := usr/include                             !!  18 # When make is run under a fakechroot environment, the function
 20                                                !!  19 # $(wildcard $(srcdir)/*/.) doesn't only return directories, but also regular
 21 -include $(src)/Kbuild                         !!  20 # files. So, we are using a combination of sort/dir/wildcard which works
 22                                                !!  21 # with fakechroot.
 23 # $(filter %/, ...) is a workaround for GNU Ma !!  22 subdirs       := $(patsubst $(srcdir)/%/,%,\
 24 # $(wildcard $(src)/*/) contains not only dire !!  23                  $(filter-out $(srcdir)/,\
 25 src-subdirs := $(patsubst $(src)/%/,%,$(filter !!  24                  $(sort $(dir $(wildcard $(srcdir)/*/)))))
 26 gen-subdirs := $(patsubst $(gen)/%/,%,$(filter !!  25 
 27 all-subdirs := $(sort $(src-subdirs) $(gen-sub !!  26 # caller may set destination dir (when installing to asm/)
 28                                                !!  27 _dst          := $(if $(dst),$(dst),$(obj))
 29 src-headers := $(if $(src-subdirs), $(shell cd !!  28 
 30 src-headers := $(filter-out $(no-export-header !!  29 # Recursion
 31 gen-headers := $(if $(gen-subdirs), $(shell cd !!  30 __headers: $(subdirs)
 32 gen-headers := $(filter-out $(no-export-header !!  31 
 33                                                !!  32 .PHONY: $(subdirs)
 34 # If the same header is exported from source a !!  33 $(subdirs):
 35 # the former takes precedence, but this should !!  34         $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
 36 duplicated := $(filter $(gen-headers), $(src-h !!  35 
 37 $(if $(duplicated), $(warning duplicated heade !!  36 # Skip header install/check for include/uapi and arch/$(hdr-arch)/include/uapi.
 38                                                !!  37 # We have only sub-directories there.
 39 gen-headers := $(filter-out $(duplicated), $(g !!  38 skip-inst := $(if $(filter %/uapi,$(obj)),1)
 40                                                !!  39 
 41 # Add dst path prefix                          !!  40 ifeq ($(skip-inst),)
 42 all-subdirs := $(addprefix $(dst)/, $(all-subd !!  41 
 43 src-headers := $(addprefix $(dst)/, $(src-head !!  42 # generated header directory
 44 gen-headers := $(addprefix $(dst)/, $(gen-head !!  43 gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj)))
 45 all-headers := $(src-headers) $(gen-headers)   !!  44 
                                                   >>  45 # Kbuild file is optional
                                                   >>  46 kbuild-file := $(srctree)/$(obj)/Kbuild
                                                   >>  47 -include $(kbuild-file)
                                                   >>  48 
                                                   >>  49 old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild
                                                   >>  50 ifneq ($(wildcard $(old-kbuild-file)),)
                                                   >>  51 include $(old-kbuild-file)
                                                   >>  52 endif
                                                   >>  53 
                                                   >>  54 installdir    := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst))
                                                   >>  55 
                                                   >>  56 gendir        := $(objtree)/$(gen)
                                                   >>  57 header-files  := $(notdir $(wildcard $(srcdir)/*.h))
                                                   >>  58 header-files  += $(notdir $(wildcard $(srcdir)/*.agh))
                                                   >>  59 header-files  := $(filter-out $(no-export-headers), $(header-files))
                                                   >>  60 genhdr-files  := $(notdir $(wildcard $(gendir)/*.h))
                                                   >>  61 genhdr-files  := $(filter-out $(header-files), $(genhdr-files))
                                                   >>  62 
                                                   >>  63 # files used to track state of install/check
                                                   >>  64 install-file  := $(installdir)/.install
                                                   >>  65 check-file    := $(installdir)/.check
                                                   >>  66 
                                                   >>  67 # generic-y list all files an architecture uses from asm-generic
                                                   >>  68 # Use this to build a list of headers which require a wrapper
                                                   >>  69 generic-files := $(notdir $(wildcard $(srctree)/include/uapi/asm-generic/*.h))
                                                   >>  70 wrapper-files := $(filter $(generic-files), $(generic-y))
                                                   >>  71 wrapper-files := $(filter-out $(header-files), $(wrapper-files))
                                                   >>  72 
                                                   >>  73 # all headers files for this dir
                                                   >>  74 all-files     := $(header-files) $(genhdr-files) $(wrapper-files)
                                                   >>  75 output-files  := $(addprefix $(installdir)/, $(all-files))
                                                   >>  76 
                                                   >>  77 ifneq ($(mandatory-y),)
                                                   >>  78 missing       := $(filter-out $(all-files),$(mandatory-y))
                                                   >>  79 ifneq ($(missing),)
                                                   >>  80 $(error Some mandatory headers ($(missing)) are missing in $(obj))
                                                   >>  81 endif
                                                   >>  82 endif
 46                                                    83 
 47 # Work out what needs to be removed                84 # Work out what needs to be removed
 48 old-subdirs := $(wildcard $(all-subdirs))      !!  85 oldheaders    := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
 49 old-headers := $(if $(old-subdirs),$(shell fin !!  86 unwanted      := $(filter-out $(all-files),$(oldheaders))
 50 unwanted    := $(filter-out $(all-headers), $( << 
 51                                                << 
 52 # Create directories                           << 
 53 existing-dirs := $(sort $(dir $(old-headers))) << 
 54 wanted-dirs   := $(sort $(dir $(all-headers))) << 
 55 new-dirs      := $(filter-out $(existing-dirs) << 
 56 $(if $(new-dirs), $(shell mkdir -p $(new-dirs) << 
 57                                                << 
 58 # Rules                                        << 
 59 quiet_cmd_install = HDRINST $@                 << 
 60       cmd_install = $(CONFIG_SHELL) $(srctree) << 
 61                                                    87 
 62 $(src-headers): $(dst)/%.h: $(src)/%.h $(srctr !!  88 # Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
 63         $(call if_changed,install)             !!  89 unwanted-file := $(addprefix $(installdir)/, $(unwanted))
 64                                                    90 
 65 $(gen-headers): $(dst)/%.h: $(gen)/%.h $(srctr !!  91 printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
 66         $(call if_changed,install)             !!  92 
                                                   >>  93 quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
                                                   >>  94                             file$(if $(word 2, $(all-files)),s))
                                                   >>  95       cmd_install = \
                                                   >>  96         $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \
                                                   >>  97         $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \
                                                   >>  98         for F in $(wrapper-files); do                                   \
                                                   >>  99                 echo "\#include <asm-generic/$$F>" > $(installdir)/$$F;    \
                                                   >> 100         done;                                                           \
                                                   >> 101         touch $@
 67                                                   102 
 68 quiet_cmd_remove = REMOVE  $(unwanted)            103 quiet_cmd_remove = REMOVE  $(unwanted)
 69       cmd_remove = rm -f $(unwanted)           !! 104       cmd_remove = rm -f $(unwanted-file)
 70                                                   105 
 71 __headers: $(all-headers)                      !! 106 quiet_cmd_check = CHECK   $(printdir) ($(words $(all-files)) files)
 72 ifneq ($(unwanted),)                           !! 107 # Headers list can be pretty long, xargs helps to avoid
 73         $(call cmd,remove)                     !! 108 # the "Argument list too long" error.
 74 endif                                          !! 109       cmd_check = for f in $(all-files); do                          \
                                                   >> 110                   echo "$(installdir)/$${f}"; done                      \
                                                   >> 111                   | xargs                                            \
                                                   >> 112                   $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \
                                                   >> 113                   touch $@
                                                   >> 114 
                                                   >> 115 ifndef HDRCHECK
                                                   >> 116 # Rules for installing headers
                                                   >> 117 __headers: $(install-file)
 75         @:                                        118         @:
 76                                                   119 
 77 existing-headers := $(filter $(old-headers), $ !! 120 targets += $(install-file)
                                                   >> 121 $(install-file): scripts/headers_install.sh \
                                                   >> 122                  $(addprefix $(srcdir)/,$(header-files)) \
                                                   >> 123                  $(addprefix $(gendir)/,$(genhdr-files)) FORCE
                                                   >> 124         $(if $(unwanted),$(call cmd,remove),)
                                                   >> 125         $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
                                                   >> 126         $(call if_changed,install)
 78                                                   127 
 79 -include $(foreach f,$(existing-headers),$(dir !! 128 else
                                                   >> 129 __headers: $(check-file)
                                                   >> 130         @:
 80                                                   131 
 81 PHONY += FORCE                                 !! 132 targets += $(check-file)
 82 FORCE:                                         !! 133 $(check-file): scripts/headers_check.pl $(output-files) FORCE
                                                   >> 134         $(call if_changed,check)
                                                   >> 135 
                                                   >> 136 endif
                                                   >> 137 
                                                   >> 138 targets := $(wildcard $(sort $(targets)))
                                                   >> 139 cmd_files := $(wildcard \
                                                   >> 140              $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
                                                   >> 141 
                                                   >> 142 ifneq ($(cmd_files),)
                                                   >> 143         include $(cmd_files)
                                                   >> 144 endif
                                                   >> 145 
                                                   >> 146 endif # skip-inst
 83                                                   147 
 84 .PHONY: $(PHONY)                                  148 .PHONY: $(PHONY)
                                                   >> 149 PHONY += FORCE
                                                   >> 150 FORCE: ;
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php