diff options
| author | Sam Ravnborg <sam@ravnborg.org> | 2008-06-07 07:18:26 -0400 |
|---|---|---|
| committer | Sam Ravnborg <sam@ravnborg.org> | 2008-07-25 16:08:40 -0400 |
| commit | 62284a37dcd6725921410fb75446d270cc726b4f (patch) | |
| tree | 40c0a2e7a7b5dd1f4030fb38b4278ace2feadecf /scripts/Makefile.headersinst | |
| parent | 283039fb7ded6b863eacc9cfd67232297622e52d (diff) | |
kbuild: code refactoring in Makefile.headerinst
No functional changes just improved readability
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/Makefile.headersinst')
| -rw-r--r-- | scripts/Makefile.headersinst | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 1fb8c003920f..599adc63b84c 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | UNIFDEF := scripts/unifdef -U__KERNEL__ | 10 | UNIFDEF := scripts/unifdef -U__KERNEL__ |
| 11 | 11 | ||
| 12 | # Eliminate the contents of (and inclusions of) compiler.h | 12 | # Eliminate the contents of (and inclusions of) compiler.h |
| 13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ | 13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ |
| 14 | -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ | 14 | -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ |
| 15 | -e "s/(__user[[:space:]]\{1,\}/ (/g" \ | 15 | -e "s/(__user[[:space:]]\{1,\}/ (/g" \ |
| 16 | -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ | 16 | -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ |
| @@ -37,6 +37,8 @@ ifeq ($(obj),include/asm-$(ARCH)$(BIASMDIR)) | |||
| 37 | _dst := include/asm | 37 | _dst := include/asm |
| 38 | endif | 38 | endif |
| 39 | 39 | ||
| 40 | install := $(INSTALL_HDR_PATH)/$(_dst) | ||
| 41 | |||
| 40 | header-y := $(sort $(header-y) $(unifdef-y)) | 42 | header-y := $(sort $(header-y) $(unifdef-y)) |
| 41 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) | 43 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) |
| 42 | header-y := $(filter-out %/, $(header-y)) | 44 | header-y := $(filter-out %/, $(header-y)) |
| @@ -45,34 +47,34 @@ header-y := $(filter-out %/, $(header-y)) | |||
| 45 | check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) | 47 | check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) |
| 46 | 48 | ||
| 47 | # Work out what needs to be removed | 49 | # Work out what needs to be removed |
| 48 | oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) | 50 | oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) |
| 49 | unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) | 51 | unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) |
| 50 | 52 | ||
| 51 | oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) | 53 | oldcheckstamps := $(patsubst $(install)/%,%,$(wildcard $(install)/.check.*.h)) |
| 52 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) | 54 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) |
| 53 | 55 | ||
| 54 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) | 56 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) |
| 55 | header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) | 57 | header-y := $(patsubst %,$(install)/%,$(header-y)) |
| 56 | objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) | 58 | objhdr-y := $(patsubst %,$(install)/%,$(objhdr-y)) |
| 57 | check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) | 59 | check-y := $(patsubst %,$(install)/%,$(check-y)) |
| 58 | 60 | ||
| 59 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | 61 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 60 | cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ | 62 | cmd_o_hdr_install = cp $(patsubst $(install)/%,$(objtree)/$(obj)/%,$@) \ |
| 61 | $(INSTALL_HDR_PATH)/$(_dst) | 63 | $(install) |
| 62 | 64 | ||
| 63 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | 65 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 64 | cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ | 66 | cmd_unifdef = $(UNIFDEF) $(patsubst $(install)/%,$(srctree)/$(obj)/%,$@)\ |
| 65 | | $(HDRSED) > $@ || : | 67 | | $(HDRSED) > $@ || : |
| 66 | 68 | ||
| 67 | quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) | 69 | quiet_cmd_check = CHECK $(patsubst $(install)/.check.%,$(_dst)/%,$@) |
| 68 | cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ | 70 | cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ |
| 69 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ | 71 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ |
| 70 | 72 | ||
| 71 | quiet_cmd_remove = REMOVE $(_dst)/$@ | 73 | quiet_cmd_remove = REMOVE $(_dst)/$@ |
| 72 | cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ | 74 | cmd_remove = rm -f $(install)/$@ |
| 73 | 75 | ||
| 74 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) | 76 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 75 | cmd_mkdir = mkdir -p $@ | 77 | cmd_mkdir = mkdir -p $@ |
| 76 | 78 | ||
| 77 | .PHONY: __headersinst __headerscheck | 79 | .PHONY: __headersinst __headerscheck |
| 78 | 80 | ||
| @@ -80,13 +82,14 @@ ifdef HDRCHECK | |||
| 80 | __headerscheck: $(subdir-y) $(check-y) | 82 | __headerscheck: $(subdir-y) $(check-y) |
| 81 | @true | 83 | @true |
| 82 | 84 | ||
| 83 | $(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h | 85 | $(check-y) : $(install)/.check.%.h : $(install)/%.h |
| 84 | $(call cmd,check) | 86 | $(call cmd,check) |
| 85 | 87 | ||
| 86 | # Other dependencies for $(check-y) | 88 | # Other dependencies for $(check-y) |
| 87 | include /dev/null $(wildcard $(check-y)) | 89 | include /dev/null $(wildcard $(check-y)) |
| 88 | 90 | ||
| 89 | # ... but leave $(check-y) as .PHONY for now until those deps are actually correct. | 91 | # but leave $(check-y) as .PHONY for now until those |
| 92 | # deps are actually correct. | ||
| 90 | .PHONY: $(check-y) | 93 | .PHONY: $(check-y) |
| 91 | 94 | ||
| 92 | else | 95 | else |
| @@ -94,26 +97,29 @@ else | |||
| 94 | __headersinst: $(subdir-y) $(header-y) $(objhdr-y) | 97 | __headersinst: $(subdir-y) $(header-y) $(objhdr-y) |
| 95 | @true | 98 | @true |
| 96 | 99 | ||
| 97 | $(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) | 100 | $(objhdr-y) $(subdir-y) $(header-y): | $(install) $(unwanted) |
| 98 | 101 | ||
| 99 | $(INSTALL_HDR_PATH)/$(_dst): | 102 | $(install): |
| 100 | $(call cmd,mkdir) | 103 | $(call cmd,mkdir) |
| 101 | 104 | ||
| 105 | # Rules for removing unwanted header files | ||
| 102 | .PHONY: $(unwanted) | 106 | .PHONY: $(unwanted) |
| 103 | $(unwanted): | 107 | $(unwanted): |
| 104 | $(call cmd,remove) | 108 | $(call cmd,remove) |
| 105 | 109 | ||
| 106 | $(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file) | 110 | # Install generated files |
| 111 | $(objhdr-y): $(install)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file) | ||
| 107 | $(call cmd,o_hdr_install) | 112 | $(call cmd,o_hdr_install) |
| 108 | 113 | ||
| 109 | $(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) | 114 | # Unifdef header files and install them |
| 115 | $(header-y): $(install)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) | ||
| 110 | $(call cmd,unifdef) | 116 | $(call cmd,unifdef) |
| 111 | 117 | ||
| 112 | endif | 118 | endif |
| 113 | 119 | ||
| 114 | hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj | 120 | hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
| 115 | 121 | ||
| 116 | # Recursion | 122 | # Recursion |
| 117 | .PHONY: $(subdir-y) | 123 | .PHONY: $(subdir-y) |
| 118 | $(subdir-y): | 124 | $(subdir-y): |
| 119 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) | 125 | $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ |
