Commit db1bec4f5271d7799d481cd4d95fdc268bdd7614
1 parent
6b36ab27d7
Exists in
master
and in
7 other branches
kbuild: install all headers when arch is changed
We see some header files that are selected dependent on the actual architecture so force a reinstallation of all header files when the arch changes. This slows down "make headers_check_all" but then we better reflect reality. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Showing 2 changed files with 12 additions and 8 deletions Inline Diff
scripts/Makefile.headersinst
1 | # ========================================================================== | 1 | # ========================================================================== |
2 | # Installing headers | 2 | # Installing headers |
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 | # unifdef-y - Same as header-y. Obsolete | 6 | # unifdef-y - Same as header-y. Obsolete |
7 | # objhdr-y - Same as header-y but for generated files | 7 | # objhdr-y - Same as header-y but for generated files |
8 | # | 8 | # |
9 | # ========================================================================== | 9 | # ========================================================================== |
10 | 10 | ||
11 | # called may set destination dir (when installing to asm/) | 11 | # called may set destination dir (when installing to asm/) |
12 | _dst := $(if $(dst),$(dst),$(obj)) | 12 | _dst := $(if $(dst),$(dst),$(obj)) |
13 | 13 | ||
14 | kbuild-file := $(srctree)/$(obj)/Kbuild | 14 | kbuild-file := $(srctree)/$(obj)/Kbuild |
15 | include $(kbuild-file) | 15 | include $(kbuild-file) |
16 | 16 | ||
17 | include scripts/Kbuild.include | 17 | include scripts/Kbuild.include |
18 | 18 | ||
19 | install := $(INSTALL_HDR_PATH)/$(_dst) | 19 | install := $(INSTALL_HDR_PATH)/$(_dst) |
20 | 20 | ||
21 | header-y := $(sort $(header-y) $(unifdef-y)) | 21 | header-y := $(sort $(header-y) $(unifdef-y)) |
22 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) | 22 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) |
23 | header-y := $(filter-out %/, $(header-y)) | 23 | header-y := $(filter-out %/, $(header-y)) |
24 | 24 | ||
25 | # files used to track state of install/check | 25 | # files used to track state of install/check |
26 | install-file := $(install)/.install | 26 | install-file := $(install)/.install |
27 | check-file := $(install)/.check | 27 | check-file := $(install)/.check |
28 | 28 | ||
29 | # all headers files for this dir | 29 | # all headers files for this dir |
30 | all-files := $(header-y) $(objhdr-y) | 30 | all-files := $(header-y) $(objhdr-y) |
31 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ | 31 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ |
32 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) | 32 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) |
33 | output-files := $(addprefix $(install)/, $(all-files)) | 33 | output-files := $(addprefix $(install)/, $(all-files)) |
34 | 34 | ||
35 | # Work out what needs to be removed | 35 | # Work out what needs to be removed |
36 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) | 36 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) |
37 | unwanted := $(filter-out $(all-files),$(oldheaders)) | 37 | unwanted := $(filter-out $(all-files),$(oldheaders)) |
38 | 38 | ||
39 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) | 39 | # Prefix unwanted with full paths to $(INSTALL_HDR_PATH) |
40 | unwanted-file := $(addprefix $(install)/, $(unwanted)) | 40 | unwanted-file := $(addprefix $(install)/, $(unwanted)) |
41 | 41 | ||
42 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) | 42 | printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) |
43 | 43 | ||
44 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ | 44 | quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ |
45 | file$(if $(word 2, $(all-files)),s)) | 45 | file$(if $(word 2, $(all-files)),s)) |
46 | cmd_install = $(PERL) $< $(srctree)/$(obj) $(install) $(header-y); \ | 46 | cmd_install = \ |
47 | $(PERL) $< $(objtree)/$(obj) $(install) $(objhdr-y); \ | 47 | $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ |
48 | touch $@ | 48 | $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ |
49 | touch $@ | ||
49 | 50 | ||
50 | quiet_cmd_remove = REMOVE $(unwanted) | 51 | quiet_cmd_remove = REMOVE $(unwanted) |
51 | cmd_remove = rm -f $(unwanted-file) | 52 | cmd_remove = rm -f $(unwanted-file) |
52 | 53 | ||
53 | quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) | 54 | quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) |
54 | cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \ | 55 | cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \ |
55 | $(addprefix $(install)/, $(all-files)); \ | 56 | $(addprefix $(install)/, $(all-files)); \ |
56 | touch $@ | 57 | touch $@ |
57 | 58 | ||
58 | PHONY += __headersinst __headerscheck | 59 | PHONY += __headersinst __headerscheck |
59 | 60 | ||
60 | ifndef HDRCHECK | 61 | ifndef HDRCHECK |
61 | # Rules for installing headers | 62 | # Rules for installing headers |
62 | __headersinst: $(subdirs) $(install-file) | 63 | __headersinst: $(subdirs) $(install-file) |
63 | @: | 64 | @: |
64 | 65 | ||
65 | targets += $(install-file) | 66 | targets += $(install-file) |
66 | $(install-file): scripts/headers_install.pl $(input-files) FORCE | 67 | $(install-file): scripts/headers_install.pl $(input-files) FORCE |
67 | $(if $(unwanted),$(call cmd,remove),) | 68 | $(if $(unwanted),$(call cmd,remove),) |
68 | $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) | 69 | $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) |
69 | $(call if_changed,install) | 70 | $(call if_changed,install) |
70 | 71 | ||
71 | else | 72 | else |
72 | __headerscheck: $(subdirs) $(check-file) | 73 | __headerscheck: $(subdirs) $(check-file) |
73 | @: | 74 | @: |
74 | 75 | ||
75 | targets += $(check-file) | 76 | targets += $(check-file) |
76 | $(check-file): scripts/headers_check.pl $(output-files) FORCE | 77 | $(check-file): scripts/headers_check.pl $(output-files) FORCE |
77 | $(call if_changed,check) | 78 | $(call if_changed,check) |
78 | 79 | ||
79 | endif | 80 | endif |
80 | 81 | ||
81 | # Recursion | 82 | # Recursion |
82 | hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj | 83 | hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
83 | .PHONY: $(subdirs) | 84 | .PHONY: $(subdirs) |
84 | $(subdirs): | 85 | $(subdirs): |
85 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ | 86 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ |
86 | 87 | ||
87 | targets := $(wildcard $(sort $(targets))) | 88 | targets := $(wildcard $(sort $(targets))) |
88 | cmd_files := $(wildcard \ | 89 | cmd_files := $(wildcard \ |
89 | $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) | 90 | $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) |
90 | 91 | ||
91 | ifneq ($(cmd_files),) | 92 | ifneq ($(cmd_files),) |
92 | include $(cmd_files) | 93 | include $(cmd_files) |
93 | endif | 94 | endif |
94 | 95 | ||
95 | .PHONY: $(PHONY) | 96 | .PHONY: $(PHONY) |
96 | PHONY += FORCE | 97 | PHONY += FORCE |
97 | FORCE: ; | 98 | FORCE: ; |
98 | 99 |
scripts/headers_install.pl
1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl |
2 | # | 2 | # |
3 | # headers_install prepare the listed header files for use in | 3 | # headers_install prepare the listed header files for use in |
4 | # user space and copy the files to their destination. | 4 | # user space and copy the files to their destination. |
5 | # | 5 | # |
6 | # Usage: headers_install.pl odir installdir [files...] | 6 | # Usage: headers_install.pl readdir installdir arch [files...] |
7 | # odir: dir to open files | 7 | # readdir: dir to open files |
8 | # install: dir to install the files | 8 | # installdir: dir to install the files |
9 | # files: list of files to check | 9 | # arch: current architecture |
10 | # arch is used to force a reinstallation when the arch | ||
11 | # changes because kbuild then detect a command line change. | ||
12 | # files: list of files to check | ||
10 | # | 13 | # |
11 | # Step in preparation for users space: | 14 | # Step in preparation for users space: |
12 | # 1) Drop all use of compiler.h definitions | 15 | # 1) Drop all use of compiler.h definitions |
13 | # 2) Drop include of compiler.h | 16 | # 2) Drop include of compiler.h |
14 | # 3) Drop all sections defined out by __KERNEL__ (using unifdef) | 17 | # 3) Drop all sections defined out by __KERNEL__ (using unifdef) |
15 | 18 | ||
16 | use strict; | 19 | use strict; |
17 | use warnings; | 20 | use warnings; |
18 | 21 | ||
19 | my ($readdir, $installdir, @files) = @ARGV; | 22 | my ($readdir, $installdir, $arch, @files) = @ARGV; |
20 | 23 | ||
21 | my $unifdef = "scripts/unifdef -U__KERNEL__"; | 24 | my $unifdef = "scripts/unifdef -U__KERNEL__"; |
22 | 25 | ||
23 | foreach my $file (@files) { | 26 | foreach my $file (@files) { |
24 | my $tmpfile = "$installdir/$file.tmp"; | 27 | my $tmpfile = "$installdir/$file.tmp"; |
25 | open(my $infile, '<', "$readdir/$file") | 28 | open(my $infile, '<', "$readdir/$file") |
26 | or die "$readdir/$file: $!\n"; | 29 | or die "$readdir/$file: $!\n"; |
27 | open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n"; | 30 | open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n"; |
28 | while (my $line = <$infile>) { | 31 | while (my $line = <$infile>) { |
29 | $line =~ s/([\s(])__user\s/$1/g; | 32 | $line =~ s/([\s(])__user\s/$1/g; |
30 | $line =~ s/([\s(])__force\s/$1/g; | 33 | $line =~ s/([\s(])__force\s/$1/g; |
31 | $line =~ s/([\s(])__iomem\s/$1/g; | 34 | $line =~ s/([\s(])__iomem\s/$1/g; |
32 | $line =~ s/\s__attribute_const__\s/ /g; | 35 | $line =~ s/\s__attribute_const__\s/ /g; |
33 | $line =~ s/\s__attribute_const__$//g; | 36 | $line =~ s/\s__attribute_const__$//g; |
34 | $line =~ s/^#include <linux\/compiler.h>//; | 37 | $line =~ s/^#include <linux\/compiler.h>//; |
35 | printf $outfile "%s", $line; | 38 | printf $outfile "%s", $line; |
36 | } | 39 | } |
37 | close $outfile; | 40 | close $outfile; |
38 | close $infile; | 41 | close $infile; |
39 | system $unifdef . " $tmpfile > $installdir/$file"; | 42 | system $unifdef . " $tmpfile > $installdir/$file"; |
40 | unlink $tmpfile; | 43 | unlink $tmpfile; |
41 | } | 44 | } |
42 | exit 0; | 45 | exit 0; |
43 | 46 |