linux/scripts/Makefile.headersinst
<<
>>
Prefs
   1# ==========================================================================
   2# Installing headers
   3#
   4# header-y  - list files to be installed. They are preprocessed
   5#             to remove __KERNEL__ section of the file
   6# unifdef-y - Same as header-y. Obsolete
   7# objhdr-y  - Same as header-y but for generated files
   8#
   9# ==========================================================================
  10
  11# called may set destination dir (when installing to asm/)
  12_dst := $(if $(dst),$(dst),$(obj))
  13
  14kbuild-file := $(srctree)/$(obj)/Kbuild
  15include $(kbuild-file)
  16
  17_dst := $(if $(destination-y),$(destination-y),$(_dst))
  18
  19include scripts/Kbuild.include
  20
  21install       := $(INSTALL_HDR_PATH)/$(_dst)
  22
  23header-y      := $(sort $(header-y) $(unifdef-y))
  24subdirs       := $(patsubst %/,%,$(filter %/, $(header-y)))
  25header-y      := $(filter-out %/, $(header-y))
  26
  27# files used to track state of install/check
  28install-file  := $(install)/.install
  29check-file    := $(install)/.check
  30
  31# all headers files for this dir
  32all-files     := $(header-y) $(objhdr-y)
  33input-files   := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
  34                 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
  35output-files  := $(addprefix $(install)/, $(all-files))
  36
  37# Work out what needs to be removed
  38oldheaders    := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
  39unwanted      := $(filter-out $(all-files),$(oldheaders))
  40
  41# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
  42unwanted-file := $(addprefix $(install)/, $(unwanted))
  43
  44printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
  45
  46quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
  47                            file$(if $(word 2, $(all-files)),s))
  48      cmd_install = \
  49        $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
  50        $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
  51        touch $@
  52
  53quiet_cmd_remove = REMOVE  $(unwanted)
  54      cmd_remove = rm -f $(unwanted-file)
  55
  56quiet_cmd_check = CHECK   $(printdir) ($(words $(all-files)) files)
  57      cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
  58                  $(addprefix $(install)/, $(all-files));           \
  59                  touch $@
  60
  61PHONY += __headersinst __headerscheck
  62
  63ifndef HDRCHECK
  64# Rules for installing headers
  65__headersinst: $(subdirs) $(install-file)
  66        @:
  67
  68targets += $(install-file)
  69$(install-file): scripts/headers_install.pl $(input-files) FORCE
  70        $(if $(unwanted),$(call cmd,remove),)
  71        $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
  72        $(call if_changed,install)
  73
  74else
  75__headerscheck: $(subdirs) $(check-file)
  76        @:
  77
  78targets += $(check-file)
  79$(check-file): scripts/headers_check.pl $(output-files) FORCE
  80        $(call if_changed,check)
  81
  82endif
  83
  84# Recursion
  85hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
  86.PHONY: $(subdirs)
  87$(subdirs):
  88        $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
  89
  90targets := $(wildcard $(sort $(targets)))
  91cmd_files := $(wildcard \
  92             $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  93
  94ifneq ($(cmd_files),)
  95        include $(cmd_files)
  96endif
  97
  98.PHONY: $(PHONY)
  99PHONY += FORCE
 100FORCE: ;
 101