Blame view
scripts/Makefile.headersinst
3.98 KB
b24413180 License cleanup: ... |
1 |
# SPDX-License-Identifier: GPL-2.0 |
8d730cfb5 Basic implementat... |
2 3 4 |
# ========================================================================== # Installing headers # |
fcc8487d4 uapi: export all ... |
5 |
# All headers under include/uapi, include/generated/uapi, |
61562f981 uapi: export all ... |
6 |
# arch/<arch>/include/uapi and arch/<arch>/include/generated/uapi are |
fcc8487d4 uapi: export all ... |
7 8 |
# exported. # They are preprocessed to remove __KERNEL__ section of the file. |
8d730cfb5 Basic implementat... |
9 10 |
# # ========================================================================== |
05d8cba4a kbuild: skip inst... |
11 12 13 14 15 16 |
PHONY := __headers __headers: include scripts/Kbuild.include srcdir := $(srctree)/$(obj) |
2f263d145 kbuild: fix heade... |
17 18 19 20 21 22 23 24 |
# When make is run under a fakechroot environment, the function # $(wildcard $(srcdir)/*/.) doesn't only return directories, but also regular # files. So, we are using a combination of sort/dir/wildcard which works # with fakechroot. subdirs := $(patsubst $(srcdir)/%/,%,\ $(filter-out $(srcdir)/,\ $(sort $(dir $(wildcard $(srcdir)/*/))))) |
05d8cba4a kbuild: skip inst... |
25 26 |
# Recursion __headers: $(subdirs) |
e474ed457 kbuild: specify F... |
27 |
PHONY += $(subdirs) |
05d8cba4a kbuild: skip inst... |
28 |
$(subdirs): |
a8ff49a1d kbuild: pass dst=... |
29 |
$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@ |
05d8cba4a kbuild: skip inst... |
30 |
|
9d022c540 kbuild: replace $... |
31 |
# Skip header install/check for include/uapi and arch/$(SRCARCH)/include/uapi. |
05d8cba4a kbuild: skip inst... |
32 33 34 35 |
# We have only sub-directories there. skip-inst := $(if $(filter %/uapi,$(obj)),1) ifeq ($(skip-inst),) |
fcc8487d4 uapi: export all ... |
36 |
# Kbuild file is optional |
283039fb7 kbuild: drop supp... |
37 |
kbuild-file := $(srctree)/$(obj)/Kbuild |
fcc8487d4 uapi: export all ... |
38 |
-include $(kbuild-file) |
8d730cfb5 Basic implementat... |
39 |
|
a8ff49a1d kbuild: pass dst=... |
40 |
installdir := $(INSTALL_HDR_PATH)/$(dst) |
87ebb94e2 kbuild: remove us... |
41 |
gendir := $(objtree)/$(subst include/,include/generated/,$(obj)) |
fcc8487d4 uapi: export all ... |
42 43 44 45 46 |
header-files := $(notdir $(wildcard $(srcdir)/*.h)) header-files += $(notdir $(wildcard $(srcdir)/*.agh)) header-files := $(filter-out $(no-export-headers), $(header-files)) genhdr-files := $(notdir $(wildcard $(gendir)/*.h)) genhdr-files := $(filter-out $(header-files), $(genhdr-files)) |
de7891258 Use dependencies ... |
47 |
|
7712401ae kbuild: optimize ... |
48 |
# files used to track state of install/check |
10b63956f UAPI: Plumb the U... |
49 50 |
install-file := $(installdir)/.install check-file := $(installdir)/.check |
de7891258 Use dependencies ... |
51 |
|
7712401ae kbuild: optimize ... |
52 |
# all headers files for this dir |
09c3776c5 kbuild: remove wr... |
53 |
all-files := $(header-files) $(genhdr-files) |
10b63956f UAPI: Plumb the U... |
54 |
output-files := $(addprefix $(installdir)/, $(all-files)) |
fcc8487d4 uapi: export all ... |
55 56 57 58 59 60 |
ifneq ($(mandatory-y),) missing := $(filter-out $(all-files),$(mandatory-y)) ifneq ($(missing),) $(error Some mandatory headers ($(missing)) are missing in $(obj)) endif endif |
de7891258 Use dependencies ... |
61 |
|
7712401ae kbuild: optimize ... |
62 |
# Work out what needs to be removed |
10b63956f UAPI: Plumb the U... |
63 |
oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) |
7712401ae kbuild: optimize ... |
64 |
unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb5 Basic implementat... |
65 |
|
7712401ae kbuild: optimize ... |
66 |
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
10b63956f UAPI: Plumb the U... |
67 |
unwanted-file := $(addprefix $(installdir)/, $(unwanted)) |
de7891258 Use dependencies ... |
68 |
|
7712401ae kbuild: optimize ... |
69 |
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
684753599 Basic implementat... |
70 |
|
7712401ae kbuild: optimize ... |
71 72 |
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) |
db1bec4f5 kbuild: install a... |
73 |
cmd_install = \ |
fcc8487d4 uapi: export all ... |
74 75 |
$(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \ $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \ |
db1bec4f5 kbuild: install a... |
76 |
touch $@ |
8d730cfb5 Basic implementat... |
77 |
|
7712401ae kbuild: optimize ... |
78 79 |
quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted-file) |
8d730cfb5 Basic implementat... |
80 |
|
7712401ae kbuild: optimize ... |
81 |
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b90 kbuild: fix "Argu... |
82 83 84 |
# Headers list can be pretty long, xargs helps to avoid # the "Argument list too long" error. cmd_check = for f in $(all-files); do \ |
10b63956f UAPI: Plumb the U... |
85 |
echo "$(installdir)/$${f}"; done \ |
7211b8b90 kbuild: fix "Argu... |
86 87 |
| xargs \ $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ |
7712401ae kbuild: optimize ... |
88 |
touch $@ |
de7891258 Use dependencies ... |
89 |
|
7712401ae kbuild: optimize ... |
90 91 |
ifndef HDRCHECK # Rules for installing headers |
05d8cba4a kbuild: skip inst... |
92 |
__headers: $(install-file) |
7712401ae kbuild: optimize ... |
93 |
@: |
de7891258 Use dependencies ... |
94 |
|
7712401ae kbuild: optimize ... |
95 |
targets += $(install-file) |
7c025b2af Makefile.headersi... |
96 |
$(install-file): scripts/headers_install.sh \ |
fcc8487d4 uapi: export all ... |
97 98 |
$(addprefix $(srcdir)/,$(header-files)) \ $(addprefix $(gendir)/,$(genhdr-files)) FORCE |
7712401ae kbuild: optimize ... |
99 100 101 |
$(if $(unwanted),$(call cmd,remove),) $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) $(call if_changed,install) |
de7891258 Use dependencies ... |
102 |
|
684753599 Basic implementat... |
103 |
else |
05d8cba4a kbuild: skip inst... |
104 |
__headers: $(check-file) |
7712401ae kbuild: optimize ... |
105 |
@: |
8d730cfb5 Basic implementat... |
106 |
|
7712401ae kbuild: optimize ... |
107 108 109 |
targets += $(check-file) $(check-file): scripts/headers_check.pl $(output-files) FORCE $(call if_changed,check) |
8d730cfb5 Basic implementat... |
110 |
|
7712401ae kbuild: optimize ... |
111 |
endif |
de7891258 Use dependencies ... |
112 |
|
7712401ae kbuild: optimize ... |
113 |
cmd_files := $(wildcard \ |
2982c9535 kbuild: remove re... |
114 |
$(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) |
4e420aa94 kbuild: always un... |
115 |
|
7712401ae kbuild: optimize ... |
116 117 |
ifneq ($(cmd_files),) include $(cmd_files) |
8d730cfb5 Basic implementat... |
118 |
endif |
05d8cba4a kbuild: skip inst... |
119 |
endif # skip-inst |
7712401ae kbuild: optimize ... |
120 121 |
PHONY += FORCE FORCE: ; |
e474ed457 kbuild: specify F... |
122 123 |
.PHONY: $(PHONY) |