qla2xxx: fix printk typo in qla_bsg.c
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / scripts / Makefile.headersinst
CommitLineData
8d730cfb
DW
1# ==========================================================================
2# Installing headers
3#
7712401a
SR
4# header-y - list files to be installed. They are preprocessed
5# to remove __KERNEL__ section of the file
7712401a 6# objhdr-y - Same as header-y but for generated files
cb97914b 7# genhdr-y - Same as objhdr-y but in a generated/ directory
8d730cfb
DW
8#
9# ==========================================================================
10
7712401a 11# called may set destination dir (when installing to asm/)
8d730cfb
DW
12_dst := $(if $(dst),$(dst),$(obj))
13
cb97914b
PA
14# generated header directory
15gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj)))
16
283039fb
SR
17kbuild-file := $(srctree)/$(obj)/Kbuild
18include $(kbuild-file)
8d730cfb 19
c7bb349e
SR
20_dst := $(if $(destination-y),$(destination-y),$(_dst))
21
283039fb 22include scripts/Kbuild.include
de789125 23
7712401a 24install := $(INSTALL_HDR_PATH)/$(_dst)
8d730cfb 25
7cfddeef 26header-y := $(sort $(header-y))
7712401a
SR
27subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
28header-y := $(filter-out %/, $(header-y))
de789125 29
7712401a
SR
30# files used to track state of install/check
31install-file := $(install)/.install
32check-file := $(install)/.check
de789125 33
d8ecc5cd
SR
34# generic-y list all files an architecture uses from asm-generic
35# Use this to build a list of headers which require a wrapper
36wrapper-files := $(filter $(header-y), $(generic-y))
37
7712401a 38# all headers files for this dir
d8ecc5cd 39header-y := $(filter-out $(generic-y), $(header-y))
cb97914b 40all-files := $(header-y) $(objhdr-y) $(genhdr-y) $(wrapper-files)
7712401a 41input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
cb97914b
PA
42 $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) \
43 $(addprefix $(objtree)/$(gen)/,$(genhdr-y))
7712401a 44output-files := $(addprefix $(install)/, $(all-files))
de789125 45
7712401a
SR
46# Work out what needs to be removed
47oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
48unwanted := $(filter-out $(all-files),$(oldheaders))
8d730cfb 49
7712401a
SR
50# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
51unwanted-file := $(addprefix $(install)/, $(unwanted))
de789125 52
7712401a 53printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
68475359 54
7712401a
SR
55quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
56 file$(if $(word 2, $(all-files)),s))
db1bec4f
SR
57 cmd_install = \
58 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
59 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
cb97914b 60 $(PERL) $< $(objtree)/$(gen) $(install) $(SRCARCH) $(genhdr-y); \
d8ecc5cd
SR
61 for F in $(wrapper-files); do \
62 echo "\#include <asm-generic/$$F>" > $(install)/$$F; \
63 done; \
db1bec4f 64 touch $@
8d730cfb 65
7712401a
SR
66quiet_cmd_remove = REMOVE $(unwanted)
67 cmd_remove = rm -f $(unwanted-file)
8d730cfb 68
7712401a 69quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
7211b8b9
SP
70# Headers list can be pretty long, xargs helps to avoid
71# the "Argument list too long" error.
72 cmd_check = for f in $(all-files); do \
73 echo "$(install)/$${f}"; done \
74 | xargs \
75 $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \
7712401a 76 touch $@
de789125 77
7712401a 78PHONY += __headersinst __headerscheck
de789125 79
7712401a
SR
80ifndef HDRCHECK
81# Rules for installing headers
82__headersinst: $(subdirs) $(install-file)
83 @:
de789125 84
7712401a
SR
85targets += $(install-file)
86$(install-file): scripts/headers_install.pl $(input-files) FORCE
87 $(if $(unwanted),$(call cmd,remove),)
88 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
89 $(call if_changed,install)
de789125 90
68475359 91else
7712401a
SR
92__headerscheck: $(subdirs) $(check-file)
93 @:
8d730cfb 94
7712401a
SR
95targets += $(check-file)
96$(check-file): scripts/headers_check.pl $(output-files) FORCE
97 $(call if_changed,check)
8d730cfb 98
7712401a 99endif
de789125 100
7712401a
SR
101# Recursion
102hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
103.PHONY: $(subdirs)
104$(subdirs):
105 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
8d730cfb 106
7712401a
SR
107targets := $(wildcard $(sort $(targets)))
108cmd_files := $(wildcard \
109 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
4e420aa9 110
7712401a
SR
111ifneq ($(cmd_files),)
112 include $(cmd_files)
8d730cfb
DW
113endif
114
7712401a
SR
115.PHONY: $(PHONY)
116PHONY += FORCE
117FORCE: ;