diff options
Diffstat (limited to 'scripts/Makefile.headersinst')
| -rw-r--r-- | scripts/Makefile.headersinst | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index d3bae5e7b601..06ba4a70bd4d 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
| @@ -3,13 +3,12 @@ | |||
| 3 | # | 3 | # |
| 4 | # header-y - list files to be installed. They are preprocessed | 4 | # header-y - list files to be installed. They are preprocessed |
| 5 | # to remove __KERNEL__ section of the file | 5 | # to remove __KERNEL__ section of the file |
| 6 | # objhdr-y - Same as header-y but for generated files | 6 | # genhdr-y - Same as header-y but in a generated/ directory |
| 7 | # genhdr-y - Same as objhdr-y but in a generated/ directory | ||
| 8 | # | 7 | # |
| 9 | # ========================================================================== | 8 | # ========================================================================== |
| 10 | 9 | ||
| 11 | # called may set destination dir (when installing to asm/) | 10 | # called may set destination dir (when installing to asm/) |
| 12 | _dst := $(if $(dst),$(dst),$(obj)) | 11 | _dst := $(or $(destination-y),$(dst),$(obj)) |
| 13 | 12 | ||
| 14 | # generated header directory | 13 | # generated header directory |
| 15 | gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) | 14 | gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) |
| @@ -17,49 +16,64 @@ gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj))) | |||
| 17 | kbuild-file := $(srctree)/$(obj)/Kbuild | 16 | kbuild-file := $(srctree)/$(obj)/Kbuild |
| 18 | include $(kbuild-file) | 17 | include $(kbuild-file) |
| 19 | 18 | ||
| 20 | _dst := $(if $(destination-y),$(destination-y),$(_dst)) | 19 | old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild |
| 20 | ifneq ($(wildcard $(old-kbuild-file)),) | ||
| 21 | include $(old-kbuild-file) | ||
| 22 | endif | ||
| 21 | 23 | ||
| 22 | include scripts/Kbuild.include | 24 | include scripts/Kbuild.include |
| 23 | 25 | ||
| 24 | install := $(INSTALL_HDR_PATH)/$(_dst) | 26 | installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst)) |
| 25 | 27 | ||
| 26 | header-y := $(sort $(header-y)) | 28 | header-y := $(sort $(header-y)) |
| 27 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) | 29 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) |
| 28 | header-y := $(filter-out %/, $(header-y)) | 30 | header-y := $(filter-out %/, $(header-y)) |
| 29 | 31 | ||
| 30 | # files used to track state of install/check | 32 | # files used to track state of install/check |
| 31 | install-file := $(install)/.install | 33 | install-file := $(installdir)/.install |
| 32 | check-file := $(install)/.check | 34 | check-file := $(installdir)/.check |
| 33 | 35 | ||
| 34 | # generic-y list all files an architecture uses from asm-generic | 36 | # generic-y list all files an architecture uses from asm-generic |
| 35 | # Use this to build a list of headers which require a wrapper | 37 | # Use this to build a list of headers which require a wrapper |
| 36 | wrapper-files := $(filter $(header-y), $(generic-y)) | 38 | wrapper-files := $(filter $(header-y), $(generic-y)) |
| 37 | 39 | ||
| 40 | srcdir := $(srctree)/$(obj) | ||
| 41 | gendir := $(objtree)/$(gen) | ||
| 42 | |||
| 43 | oldsrcdir := $(srctree)/$(subst /uapi,,$(obj)) | ||
| 44 | |||
| 38 | # all headers files for this dir | 45 | # all headers files for this dir |
| 39 | header-y := $(filter-out $(generic-y), $(header-y)) | 46 | header-y := $(filter-out $(generic-y), $(header-y)) |
| 40 | all-files := $(header-y) $(objhdr-y) $(genhdr-y) $(wrapper-files) | 47 | all-files := $(header-y) $(genhdr-y) $(wrapper-files) |
| 41 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ | 48 | output-files := $(addprefix $(installdir)/, $(all-files)) |
| 42 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) \ | 49 | |
| 43 | $(addprefix $(objtree)/$(gen)/,$(genhdr-y)) | 50 | input-files := $(foreach hdr, $(header-y), \ |
| 44 | output-files := $(addprefix $(install)/, $(all-files)) | 51 | $(or \ |
| 52 | $(wildcard $(srcdir)/$(hdr)), \ | ||
| 53 | $(wildcard $(oldsrcdir)/$(hdr)), \ | ||
| 54 | $(error Missing UAPI file $(srcdir)/$(hdr)) \ | ||
| 55 | )) \ | ||
| 56 | $(foreach hdr, $(genhdr-y), \ | ||
| 57 | $(or \ | ||
| 58 | $(wildcard $(gendir)/$(hdr)), \ | ||
| 59 | $(error Missing generated UAPI file $(gendir)/$(hdr)) \ | ||
| 60 | )) | ||
| 45 | 61 | ||
| 46 | # Work out what needs to be removed | 62 | # Work out what needs to be removed |
| 47 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) | 63 | oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) |
| 48 | unwanted := $(filter-out $(all-files),$(oldheaders)) | 64 | unwanted := $(filter-out $(all-files),$(oldheaders)) |
| 49 | 65 | ||
| 50 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) | 66 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
| 51 | unwanted-file := $(addprefix $(install)/, $(unwanted)) | 67 | unwanted-file := $(addprefix $(installdir)/, $(unwanted)) |
| 52 | 68 | ||
| 53 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) | 69 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
| 54 | 70 | ||
| 55 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ | 71 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ |
| 56 | file$(if $(word 2, $(all-files)),s)) | 72 | file$(if $(word 2, $(all-files)),s)) |
| 57 | cmd_install = \ | 73 | cmd_install = \ |
| 58 | $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ | 74 | $(PERL) $< $(installdir) $(SRCARCH) $(input-files); \ |
| 59 | $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ | ||
| 60 | $(PERL) $< $(objtree)/$(gen) $(install) $(SRCARCH) $(genhdr-y); \ | ||
| 61 | for F in $(wrapper-files); do \ | 75 | for F in $(wrapper-files); do \ |
| 62 | echo "\#include <asm-generic/$$F>" > $(install)/$$F; \ | 76 | echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ |
| 63 | done; \ | 77 | done; \ |
| 64 | touch $@ | 78 | touch $@ |
| 65 | 79 | ||
| @@ -70,7 +84,7 @@ quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) | |||
| 70 | # Headers list can be pretty long, xargs helps to avoid | 84 | # Headers list can be pretty long, xargs helps to avoid |
| 71 | # the "Argument list too long" error. | 85 | # the "Argument list too long" error. |
| 72 | cmd_check = for f in $(all-files); do \ | 86 | cmd_check = for f in $(all-files); do \ |
| 73 | echo "$(install)/$${f}"; done \ | 87 | echo "$(installdir)/$${f}"; done \ |
| 74 | | xargs \ | 88 | | xargs \ |
| 75 | $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ | 89 | $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ |
| 76 | touch $@ | 90 | touch $@ |
