Blame view

scripts/Makefile.headersinst 2.97 KB
8d730cfb5   David Woodhouse   Basic implementat...
1
2
3
  # ==========================================================================
  # Installing headers
  #
7712401ae   Sam Ravnborg   kbuild: optimize ...
4
5
6
7
  # header-y  - list files to be installed. They are preprocessed
  #             to remove __KERNEL__ section of the file
  # unifdef-y - Same as header-y. Obsolete
  # objhdr-y  - Same as header-y but for generated files
8d730cfb5   David Woodhouse   Basic implementat...
8
9
  #
  # ==========================================================================
7712401ae   Sam Ravnborg   kbuild: optimize ...
10
  # called may set destination dir (when installing to asm/)
8d730cfb5   David Woodhouse   Basic implementat...
11
  _dst := $(if $(dst),$(dst),$(obj))
283039fb7   Sam Ravnborg   kbuild: drop supp...
12
13
  kbuild-file := $(srctree)/$(obj)/Kbuild
  include $(kbuild-file)
8d730cfb5   David Woodhouse   Basic implementat...
14

283039fb7   Sam Ravnborg   kbuild: drop supp...
15
  include scripts/Kbuild.include
de7891258   David Woodhouse   Use dependencies ...
16

7712401ae   Sam Ravnborg   kbuild: optimize ...
17
  install       := $(INSTALL_HDR_PATH)/$(_dst)
8d730cfb5   David Woodhouse   Basic implementat...
18

7712401ae   Sam Ravnborg   kbuild: optimize ...
19
20
21
  header-y      := $(sort $(header-y) $(unifdef-y))
  subdirs       := $(patsubst %/,%,$(filter %/, $(header-y)))
  header-y      := $(filter-out %/, $(header-y))
de7891258   David Woodhouse   Use dependencies ...
22

7712401ae   Sam Ravnborg   kbuild: optimize ...
23
24
25
  # files used to track state of install/check
  install-file  := $(install)/.install
  check-file    := $(install)/.check
de7891258   David Woodhouse   Use dependencies ...
26

7712401ae   Sam Ravnborg   kbuild: optimize ...
27
28
29
30
31
  # all headers files for this dir
  all-files     := $(header-y) $(objhdr-y)
  input-files   := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
                   $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
  output-files  := $(addprefix $(install)/, $(all-files))
de7891258   David Woodhouse   Use dependencies ...
32

7712401ae   Sam Ravnborg   kbuild: optimize ...
33
34
35
  # Work out what needs to be removed
  oldheaders    := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
  unwanted      := $(filter-out $(all-files),$(oldheaders))
8d730cfb5   David Woodhouse   Basic implementat...
36

7712401ae   Sam Ravnborg   kbuild: optimize ...
37
38
  # Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
  unwanted-file := $(addprefix $(install)/, $(unwanted))
de7891258   David Woodhouse   Use dependencies ...
39

7712401ae   Sam Ravnborg   kbuild: optimize ...
40
  printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
684753599   David Woodhouse   Basic implementat...
41

7712401ae   Sam Ravnborg   kbuild: optimize ...
42
43
  quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
                              file$(if $(word 2, $(all-files)),s))
db1bec4f5   Sam Ravnborg   kbuild: install a...
44
45
46
47
        cmd_install = \
          $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
          $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
          touch $@
8d730cfb5   David Woodhouse   Basic implementat...
48

7712401ae   Sam Ravnborg   kbuild: optimize ...
49
50
  quiet_cmd_remove = REMOVE  $(unwanted)
        cmd_remove = rm -f $(unwanted-file)
8d730cfb5   David Woodhouse   Basic implementat...
51

7712401ae   Sam Ravnborg   kbuild: optimize ...
52
53
54
55
  quiet_cmd_check = CHECK   $(printdir) ($(words $(all-files)) files)
        cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
                    $(addprefix $(install)/, $(all-files));           \
  	          touch $@
de7891258   David Woodhouse   Use dependencies ...
56

7712401ae   Sam Ravnborg   kbuild: optimize ...
57
  PHONY += __headersinst __headerscheck
de7891258   David Woodhouse   Use dependencies ...
58

7712401ae   Sam Ravnborg   kbuild: optimize ...
59
60
61
62
  ifndef HDRCHECK
  # Rules for installing headers
  __headersinst: $(subdirs) $(install-file)
  	@:
de7891258   David Woodhouse   Use dependencies ...
63

7712401ae   Sam Ravnborg   kbuild: optimize ...
64
65
66
67
68
  targets += $(install-file)
  $(install-file): scripts/headers_install.pl $(input-files) FORCE
  	$(if $(unwanted),$(call cmd,remove),)
  	$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
  	$(call if_changed,install)
de7891258   David Woodhouse   Use dependencies ...
69

684753599   David Woodhouse   Basic implementat...
70
  else
7712401ae   Sam Ravnborg   kbuild: optimize ...
71
72
  __headerscheck: $(subdirs) $(check-file)
  	@:
8d730cfb5   David Woodhouse   Basic implementat...
73

7712401ae   Sam Ravnborg   kbuild: optimize ...
74
75
76
  targets += $(check-file)
  $(check-file): scripts/headers_check.pl $(output-files) FORCE
  	$(call if_changed,check)
8d730cfb5   David Woodhouse   Basic implementat...
77

7712401ae   Sam Ravnborg   kbuild: optimize ...
78
  endif
de7891258   David Woodhouse   Use dependencies ...
79

7712401ae   Sam Ravnborg   kbuild: optimize ...
80
81
82
83
84
  # Recursion
  hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
  .PHONY: $(subdirs)
  $(subdirs):
  	$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
8d730cfb5   David Woodhouse   Basic implementat...
85

7712401ae   Sam Ravnborg   kbuild: optimize ...
86
87
88
  targets := $(wildcard $(sort $(targets)))
  cmd_files := $(wildcard \
               $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
4e420aa94   Sam Ravnborg   kbuild: always un...
89

7712401ae   Sam Ravnborg   kbuild: optimize ...
90
91
  ifneq ($(cmd_files),)
  	include $(cmd_files)
8d730cfb5   David Woodhouse   Basic implementat...
92
  endif
7712401ae   Sam Ravnborg   kbuild: optimize ...
93
94
95
  .PHONY: $(PHONY)
  PHONY += FORCE
  FORCE: ;