1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# ==========================================================================
# Installing headers
#
# header-y files will be installed verbatim
# unifdef-y are the files where unifdef will be run before installing files
# objhdr-y are generated files that will be installed verbatim
#
# ==========================================================================
UNIFDEF := unifdef -U__KERNEL__
# Eliminate the contents of (and inclusions of) compiler.h
HDRSED := sed -e "s/ inline / __inline__ /g" \
-e "s/[[:space:]]__user[[:space:]]\+/ /g" \
-e "s/(__user[[:space:]]\+/ (/g" \
-e "s/[[:space:]]__force[[:space:]]\+/ /g" \
-e "s/(__force[[:space:]]\+/ (/g" \
-e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \
-e "s/(__iomem[[:space:]]\+/ (/g" \
-e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \
-e "s/[[:space:]]__attribute_const__$$//" \
-e "/^\#include <linux\/compiler.h>/d"
_dst := $(if $(dst),$(dst),$(obj))
.PHONY: __headersinst
__headersinst:
ifeq (,$(patsubst include/asm/%,,$(obj)/))
# For producing the generated stuff in include/asm for biarch builds, include
# both sets of Kbuild files; we'll generate anything which is mentioned in
# _either_ arch, and recurse into subdirectories which are mentioned in either
# arch. Since some directories may exist in one but not the other, we must
# use '-include'.
GENASM := 1
archasm := $(subst include/asm,asm-$(ARCH),$(obj))
altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
-include $(srctree)/include/$(archasm)/Kbuild
-include $(srctree)/include/$(altarchasm)/Kbuild
else
include $(srctree)/$(obj)/Kbuild
endif
include scripts/Kbuild.include
# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then
# override $(_dst) so that we install to include/asm directly.
ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH))
_dst := include/asm
endif
header-y := $(sort $(header-y))
unifdef-y := $(sort $(unifdef-y))
subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
header-y := $(filter-out %/, $(header-y))
header-y := $(filter-out $(unifdef-y),$(header-y))
ifdef ALTARCH
ifeq ($(obj),include/asm-$(ARCH))
altarch-y := altarch-dir
endif
endif
# Make the definitions visible for recursive make invocations
export ALTARCH
export ARCHDEF
export ALTARCHDEF
quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@
cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst)
quiet_cmd_headers_install = INSTALL $(_dst)/$@
cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \
> $(INSTALL_HDR_PATH)/$(_dst)/$@
quiet_cmd_unifdef = UNIFDEF $(_dst)/$@
cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \
> $(INSTALL_HDR_PATH)/$(_dst)/$@ || :
quiet_cmd_mkdir = MKDIR $@
cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@
quiet_cmd_gen = GEN $(_dst)/$@
cmd_gen = \
STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \
(echo "/* File autogenerated by 'make headers_install' */" ; \
echo "\#ifndef $$STUBDEF" ; \
echo "\#define $$STUBDEF" ; \
echo "\# if $(ARCHDEF)" ; \
if [ -r $(srctree)/include/$(archasm)/$@ ]; then \
echo "\# include <$(archasm)/$@>" ; \
else \
echo "\# error $(archasm)/$@ does not exist in" \
"the $(ARCH) architecture" ; \
fi ; \
echo "\# elif $(ALTARCHDEF)" ; \
if [ -r $(srctree)/include/$(altarchasm)/$@ ]; then \
echo "\# include <$(altarchasm)/$@>" ; \
else \
echo "\# error $(altarchasm)/$@ does not exist in" \
"the $(ALTARCH) architecture" ; \
fi ; \
echo "\# else" ; \
echo "\# warning This machine appears to be" \
"neither $(ARCH) nor $(ALTARCH)." ; \
echo "\# endif" ; \
echo "\#endif /* $$STUBDEF */" ; \
) > $(INSTALL_HDR_PATH)/$(_dst)/$@
__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
.PHONY: $(header-y) $(unifdef-y) $(subdir-y)
# Rules for installing headers
$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst)
.PHONY: $(_dst)
$(_dst):
$(call cmd,mkdir)
ifdef GENASM
$(objhdr-y) $(header-y) $(unifdef-y):
$(call cmd,gen)
else
$(objhdr-y):
$(call cmd,o_hdr_install)
$(header-y):
$(call cmd,headers_install)
$(unifdef-y):
$(call cmd,unifdef)
endif
hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
.PHONY: altarch-dir
altarch-dir:
$(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
$(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm
# Recursion
$(subdir-y):
$(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)
|