]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - scripts/Makefile.headersinst
block: Declare local symbols static
[karo-tx-linux.git] / scripts / Makefile.headersinst
1 # ==========================================================================
2 # Installing headers
3 #
4 # All headers under include/uapi, include/generated/uapi,
5 # arch/<arch>/include/uapi and arch/<arch>/include/generated/uapi are
6 # exported.
7 # They are preprocessed to remove __KERNEL__ section of the file.
8 #
9 # ==========================================================================
10
11 PHONY := __headers
12 __headers:
13
14 include scripts/Kbuild.include
15
16 srcdir        := $(srctree)/$(obj)
17 subdirs       := $(patsubst $(srcdir)/%/.,%,$(wildcard $(srcdir)/*/.))
18 # caller may set destination dir (when installing to asm/)
19 _dst          := $(if $(dst),$(dst),$(obj))
20
21 # Recursion
22 __headers: $(subdirs)
23
24 .PHONY: $(subdirs)
25 $(subdirs):
26         $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
27
28 # Skip header install/check for include/uapi and arch/$(hdr-arch)/include/uapi.
29 # We have only sub-directories there.
30 skip-inst := $(if $(filter %/uapi,$(obj)),1)
31
32 ifeq ($(skip-inst),)
33
34 # generated header directory
35 gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj)))
36
37 # Kbuild file is optional
38 kbuild-file := $(srctree)/$(obj)/Kbuild
39 -include $(kbuild-file)
40
41 old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild
42 ifneq ($(wildcard $(old-kbuild-file)),)
43 include $(old-kbuild-file)
44 endif
45
46 installdir    := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst))
47
48 gendir        := $(objtree)/$(gen)
49 header-files  := $(notdir $(wildcard $(srcdir)/*.h))
50 header-files  += $(notdir $(wildcard $(srcdir)/*.agh))
51 header-files  := $(filter-out $(no-export-headers), $(header-files))
52 genhdr-files  := $(notdir $(wildcard $(gendir)/*.h))
53 genhdr-files  := $(filter-out $(header-files), $(genhdr-files))
54
55 # files used to track state of install/check
56 install-file  := $(installdir)/.install
57 check-file    := $(installdir)/.check
58
59 # generic-y list all files an architecture uses from asm-generic
60 # Use this to build a list of headers which require a wrapper
61 generic-files := $(notdir $(wildcard $(srctree)/include/uapi/asm-generic/*.h))
62 wrapper-files := $(filter $(generic-files), $(generic-y))
63 wrapper-files := $(filter-out $(header-files), $(wrapper-files))
64
65 # all headers files for this dir
66 all-files     := $(header-files) $(genhdr-files) $(wrapper-files)
67 output-files  := $(addprefix $(installdir)/, $(all-files))
68
69 ifneq ($(mandatory-y),)
70 missing       := $(filter-out $(all-files),$(mandatory-y))
71 ifneq ($(missing),)
72 $(error Some mandatory headers ($(missing)) are missing in $(obj))
73 endif
74 endif
75
76 # Work out what needs to be removed
77 oldheaders    := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
78 unwanted      := $(filter-out $(all-files),$(oldheaders))
79
80 # Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
81 unwanted-file := $(addprefix $(installdir)/, $(unwanted))
82
83 printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
84
85 quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
86                             file$(if $(word 2, $(all-files)),s))
87       cmd_install = \
88         $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \
89         $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \
90         for F in $(wrapper-files); do                                   \
91                 echo "\#include <asm-generic/$$F>" > $(installdir)/$$F;    \
92         done;                                                           \
93         touch $@
94
95 quiet_cmd_remove = REMOVE  $(unwanted)
96       cmd_remove = rm -f $(unwanted-file)
97
98 quiet_cmd_check = CHECK   $(printdir) ($(words $(all-files)) files)
99 # Headers list can be pretty long, xargs helps to avoid
100 # the "Argument list too long" error.
101       cmd_check = for f in $(all-files); do                          \
102                   echo "$(installdir)/$${f}"; done                      \
103                   | xargs                                            \
104                   $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \
105                   touch $@
106
107 ifndef HDRCHECK
108 # Rules for installing headers
109 __headers: $(install-file)
110         @:
111
112 targets += $(install-file)
113 $(install-file): scripts/headers_install.sh \
114                  $(addprefix $(srcdir)/,$(header-files)) \
115                  $(addprefix $(gendir)/,$(genhdr-files)) FORCE
116         $(if $(unwanted),$(call cmd,remove),)
117         $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
118         $(call if_changed,install)
119
120 else
121 __headers: $(check-file)
122         @:
123
124 targets += $(check-file)
125 $(check-file): scripts/headers_check.pl $(output-files) FORCE
126         $(call if_changed,check)
127
128 endif
129
130 targets := $(wildcard $(sort $(targets)))
131 cmd_files := $(wildcard \
132              $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
133
134 ifneq ($(cmd_files),)
135         include $(cmd_files)
136 endif
137
138 endif # skip-inst
139
140 .PHONY: $(PHONY)
141 PHONY += FORCE
142 FORCE: ;