Commit | Line | Data |
---|---|---|
8d730cfb DW |
1 | # ========================================================================== |
2 | # Installing headers | |
3 | # | |
4 | # header-y files will be installed verbatim | |
5 | # unifdef-y are the files where unifdef will be run before installing files | |
6 | # objhdr-y are generated files that will be installed verbatim | |
7 | # | |
8 | # ========================================================================== | |
9 | ||
07aea3a7 | 10 | UNIFDEF := scripts/unifdef -U__KERNEL__ |
8d730cfb DW |
11 | |
12 | # Eliminate the contents of (and inclusions of) compiler.h | |
62284a37 | 13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ |
c0519037 MF |
14 | -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ |
15 | -e "s/(__user[[:space:]]\{1,\}/ (/g" \ | |
16 | -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ | |
17 | -e "s/(__force[[:space:]]\{1,\}/ (/g" \ | |
18 | -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ | |
19 | -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ | |
20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ | |
8d730cfb DW |
21 | -e "s/[[:space:]]__attribute_const__$$//" \ |
22 | -e "/^\#include <linux\/compiler.h>/d" | |
23 | ||
24 | _dst := $(if $(dst),$(dst),$(obj)) | |
25 | ||
283039fb SR |
26 | kbuild-file := $(srctree)/$(obj)/Kbuild |
27 | include $(kbuild-file) | |
8d730cfb | 28 | |
283039fb | 29 | include scripts/Kbuild.include |
de789125 | 30 | |
62284a37 SR |
31 | install := $(INSTALL_HDR_PATH)/$(_dst) |
32 | ||
4e420aa9 | 33 | header-y := $(sort $(header-y) $(unifdef-y)) |
8d730cfb DW |
34 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) |
35 | header-y := $(filter-out %/, $(header-y)) | |
8d730cfb | 36 | |
de789125 | 37 | # stamp files for header checks |
4e420aa9 | 38 | check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) |
de789125 DW |
39 | |
40 | # Work out what needs to be removed | |
62284a37 SR |
41 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) |
42 | unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) | |
de789125 | 43 | |
62284a37 SR |
44 | oldcheckstamps := $(patsubst $(install)/%,%,$(wildcard $(install)/.check.*.h)) |
45 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) | |
de789125 DW |
46 | |
47 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) | |
62284a37 SR |
48 | header-y := $(patsubst %,$(install)/%,$(header-y)) |
49 | objhdr-y := $(patsubst %,$(install)/%,$(objhdr-y)) | |
50 | check-y := $(patsubst %,$(install)/%,$(check-y)) | |
de789125 | 51 | |
62284a37 SR |
52 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
53 | cmd_o_hdr_install = cp $(patsubst $(install)/%,$(objtree)/$(obj)/%,$@) \ | |
54 | $(install) | |
8d730cfb | 55 | |
62284a37 SR |
56 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
57 | cmd_unifdef = $(UNIFDEF) $(patsubst $(install)/%,$(srctree)/$(obj)/%,$@)\ | |
58 | | $(HDRSED) > $@ || : | |
8d730cfb | 59 | |
62284a37 SR |
60 | quiet_cmd_check = CHECK $(patsubst $(install)/.check.%,$(_dst)/%,$@) |
61 | cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ | |
62 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ | |
de789125 | 63 | |
62284a37 SR |
64 | quiet_cmd_remove = REMOVE $(_dst)/$@ |
65 | cmd_remove = rm -f $(install)/$@ | |
68475359 | 66 | |
62284a37 SR |
67 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
68 | cmd_mkdir = mkdir -p $@ | |
8d730cfb | 69 | |
de789125 | 70 | .PHONY: __headersinst __headerscheck |
8d730cfb | 71 | |
68475359 | 72 | ifdef HDRCHECK |
de789125 DW |
73 | __headerscheck: $(subdir-y) $(check-y) |
74 | @true | |
75 | ||
62284a37 | 76 | $(check-y) : $(install)/.check.%.h : $(install)/%.h |
68475359 | 77 | $(call cmd,check) |
de789125 DW |
78 | |
79 | # Other dependencies for $(check-y) | |
df5f6311 | 80 | include /dev/null $(wildcard $(check-y)) |
de789125 | 81 | |
62284a37 SR |
82 | # but leave $(check-y) as .PHONY for now until those |
83 | # deps are actually correct. | |
de789125 DW |
84 | .PHONY: $(check-y) |
85 | ||
68475359 | 86 | else |
8d730cfb | 87 | # Rules for installing headers |
283039fb | 88 | __headersinst: $(subdir-y) $(header-y) $(objhdr-y) |
de789125 | 89 | @true |
8d730cfb | 90 | |
62284a37 | 91 | $(objhdr-y) $(subdir-y) $(header-y): | $(install) $(unwanted) |
8d730cfb | 92 | |
62284a37 | 93 | $(install): |
8d730cfb DW |
94 | $(call cmd,mkdir) |
95 | ||
62284a37 | 96 | # Rules for removing unwanted header files |
de789125 DW |
97 | .PHONY: $(unwanted) |
98 | $(unwanted): | |
99 | $(call cmd,remove) | |
100 | ||
62284a37 SR |
101 | # Install generated files |
102 | $(objhdr-y): $(install)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file) | |
8d730cfb DW |
103 | $(call cmd,o_hdr_install) |
104 | ||
62284a37 SR |
105 | # Unifdef header files and install them |
106 | $(header-y): $(install)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) | |
8d730cfb | 107 | $(call cmd,unifdef) |
4e420aa9 | 108 | |
8d730cfb DW |
109 | endif |
110 | ||
62284a37 | 111 | hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
8d730cfb | 112 | |
8d730cfb | 113 | # Recursion |
de789125 | 114 | .PHONY: $(subdir-y) |
8d730cfb | 115 | $(subdir-y): |
62284a37 | 116 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ |