Blame view
scripts/Makefile.headersinst
4.02 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 27 28 29 |
# Recursion __headers: $(subdirs) .PHONY: $(subdirs) $(subdirs): |
a8ff49a1d kbuild: pass dst=... |
30 |
$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@ |
05d8cba4a kbuild: skip inst... |
31 32 33 34 35 36 |
# Skip header install/check for include/uapi and arch/$(hdr-arch)/include/uapi. # We have only sub-directories there. skip-inst := $(if $(filter %/uapi,$(obj)),1) ifeq ($(skip-inst),) |
fcc8487d4 uapi: export all ... |
37 |
# Kbuild file is optional |
283039fb7 kbuild: drop supp... |
38 |
kbuild-file := $(srctree)/$(obj)/Kbuild |
fcc8487d4 uapi: export all ... |
39 |
-include $(kbuild-file) |
8d730cfb5 Basic implementat... |
40 |
|
a8ff49a1d kbuild: pass dst=... |
41 |
installdir := $(INSTALL_HDR_PATH)/$(dst) |
87ebb94e2 kbuild: remove us... |
42 |
gendir := $(objtree)/$(subst include/,include/generated/,$(obj)) |
fcc8487d4 uapi: export all ... |
43 44 45 46 47 |
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 ... |
48 |
|
7712401ae kbuild: optimize ... |
49 |
# files used to track state of install/check |
10b63956f UAPI: Plumb the U... |
50 51 |
install-file := $(installdir)/.install check-file := $(installdir)/.check |
de7891258 Use dependencies ... |
52 |
|
7712401ae kbuild: optimize ... |
53 |
# all headers files for this dir |
09c3776c5 kbuild: remove wr... |
54 |
all-files := $(header-files) $(genhdr-files) |
10b63956f UAPI: Plumb the U... |
55 |
output-files := $(addprefix $(installdir)/, $(all-files)) |
fcc8487d4 uapi: export all ... |
56 57 58 59 60 61 |
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 ... |
62 |
|
7712401ae kbuild: optimize ... |
63 |
# Work out what needs to be removed |
10b63956f UAPI: Plumb the U... |
64 |
oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) |
7712401ae kbuild: optimize ... |
65 |
unwanted := $(filter-out $(all-files),$(oldheaders)) |
8d730cfb5 Basic implementat... |
66 |
|
7712401ae kbuild: optimize ... |
67 |
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
10b63956f UAPI: Plumb the U... |
68 |
unwanted-file := $(addprefix $(installdir)/, $(unwanted)) |
de7891258 Use dependencies ... |
69 |
|
7712401ae kbuild: optimize ... |
70 |
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
684753599 Basic implementat... |
71 |
|
7712401ae kbuild: optimize ... |
72 73 |
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) |
db1bec4f5 kbuild: install a... |
74 |
cmd_install = \ |
fcc8487d4 uapi: export all ... |
75 76 |
$(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \ $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \ |
db1bec4f5 kbuild: install a... |
77 |
touch $@ |
8d730cfb5 Basic implementat... |
78 |
|
7712401ae kbuild: optimize ... |
79 80 |
quiet_cmd_remove = REMOVE $(unwanted) cmd_remove = rm -f $(unwanted-file) |
8d730cfb5 Basic implementat... |
81 |
|
7712401ae kbuild: optimize ... |
82 |
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
7211b8b90 kbuild: fix "Argu... |
83 84 85 |
# 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... |
86 |
echo "$(installdir)/$${f}"; done \ |
7211b8b90 kbuild: fix "Argu... |
87 88 |
| xargs \ $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ |
7712401ae kbuild: optimize ... |
89 |
touch $@ |
de7891258 Use dependencies ... |
90 |
|
7712401ae kbuild: optimize ... |
91 92 |
ifndef HDRCHECK # Rules for installing headers |
05d8cba4a kbuild: skip inst... |
93 |
__headers: $(install-file) |
7712401ae kbuild: optimize ... |
94 |
@: |
de7891258 Use dependencies ... |
95 |
|
7712401ae kbuild: optimize ... |
96 |
targets += $(install-file) |
7c025b2af Makefile.headersi... |
97 |
$(install-file): scripts/headers_install.sh \ |
fcc8487d4 uapi: export all ... |
98 99 |
$(addprefix $(srcdir)/,$(header-files)) \ $(addprefix $(gendir)/,$(genhdr-files)) FORCE |
7712401ae kbuild: optimize ... |
100 101 102 |
$(if $(unwanted),$(call cmd,remove),) $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) $(call if_changed,install) |
de7891258 Use dependencies ... |
103 |
|
684753599 Basic implementat... |
104 |
else |
05d8cba4a kbuild: skip inst... |
105 |
__headers: $(check-file) |
7712401ae kbuild: optimize ... |
106 |
@: |
8d730cfb5 Basic implementat... |
107 |
|
7712401ae kbuild: optimize ... |
108 109 110 |
targets += $(check-file) $(check-file): scripts/headers_check.pl $(output-files) FORCE $(call if_changed,check) |
8d730cfb5 Basic implementat... |
111 |
|
7712401ae kbuild: optimize ... |
112 |
endif |
de7891258 Use dependencies ... |
113 |
|
7712401ae kbuild: optimize ... |
114 115 116 |
targets := $(wildcard $(sort $(targets))) cmd_files := $(wildcard \ $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
4e420aa94 kbuild: always un... |
117 |
|
7712401ae kbuild: optimize ... |
118 119 |
ifneq ($(cmd_files),) include $(cmd_files) |
8d730cfb5 Basic implementat... |
120 |
endif |
05d8cba4a kbuild: skip inst... |
121 |
endif # skip-inst |
7712401ae kbuild: optimize ... |
122 123 124 |
.PHONY: $(PHONY) PHONY += FORCE FORCE: ; |