David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 1 | # ========================================================================== |
| 2 | # Installing headers |
| 3 | # |
| 4 | # header-y files will be installed verbatim |
| 5 | # unifdef-y are the files where unifdef will be run before installing files |
| 6 | # objhdr-y are generated files that will be installed verbatim |
| 7 | # |
| 8 | # ========================================================================== |
| 9 | |
Sam Ravnborg | 07aea3a | 2006-07-23 20:47:50 +0200 | [diff] [blame] | 10 | UNIFDEF := scripts/unifdef -U__KERNEL__ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 11 | |
| 12 | # Eliminate the contents of (and inclusions of) compiler.h |
| 13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ |
Mike Frysinger | c051903 | 2007-07-09 11:43:55 -0700 | [diff] [blame] | 14 | -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ |
| 15 | -e "s/(__user[[:space:]]\{1,\}/ (/g" \ |
| 16 | -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ |
| 17 | -e "s/(__force[[:space:]]\{1,\}/ (/g" \ |
| 18 | -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ |
| 19 | -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ |
| 20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 21 | -e "s/[[:space:]]__attribute_const__$$//" \ |
| 22 | -e "/^\#include <linux\/compiler.h>/d" |
| 23 | |
| 24 | _dst := $(if $(dst),$(dst),$(obj)) |
| 25 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 26 | ifeq (,$(patsubst include/asm/%,,$(obj)/)) |
| 27 | # For producing the generated stuff in include/asm for biarch builds, include |
| 28 | # both sets of Kbuild files; we'll generate anything which is mentioned in |
| 29 | # _either_ arch, and recurse into subdirectories which are mentioned in either |
| 30 | # arch. Since some directories may exist in one but not the other, we must |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 31 | # use $(wildcard...). |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 32 | GENASM := 1 |
| 33 | archasm := $(subst include/asm,asm-$(ARCH),$(obj)) |
| 34 | altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 35 | KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 36 | else |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 37 | KBUILDFILES := $(srctree)/$(obj)/Kbuild |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 38 | endif |
| 39 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 40 | include $(KBUILDFILES) |
| 41 | |
| 42 | include scripts/Kbuild.include |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 43 | |
| 44 | # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then |
| 45 | # override $(_dst) so that we install to include/asm directly. |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 46 | # Unless $(BIASMDIR) is set, in which case we're probably doing |
| 47 | # a 'headers_install_all' build and we should keep the -$(ARCH) |
| 48 | # in the directory name. |
| 49 | ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR)) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 50 | _dst := include/asm |
| 51 | endif |
| 52 | |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 53 | header-y := $(sort $(header-y) $(unifdef-y)) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 54 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) |
| 55 | header-y := $(filter-out %/, $(header-y)) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 56 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 57 | # stamp files for header checks |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 58 | check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 59 | |
| 60 | # Work out what needs to be removed |
| 61 | oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 62 | unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 63 | |
| 64 | oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) |
| 65 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) |
| 66 | |
| 67 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) |
| 68 | header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 69 | objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) |
| 70 | check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) |
| 71 | |
| 72 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 73 | ifdef ALTARCH |
| 74 | ifeq ($(obj),include/asm-$(ARCH)) |
| 75 | altarch-y := altarch-dir |
| 76 | endif |
| 77 | endif |
| 78 | |
| 79 | # Make the definitions visible for recursive make invocations |
| 80 | export ALTARCH |
| 81 | export ARCHDEF |
| 82 | export ALTARCHDEF |
| 83 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 84 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 85 | cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ |
| 86 | $(INSTALL_HDR_PATH)/$(_dst) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 87 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 88 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 89 | cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ |
| 90 | | $(HDRSED) > $@ || : |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 91 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 92 | quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) |
Andrew Morton | 4e776b1 | 2006-10-04 02:15:20 -0700 | [diff] [blame] | 93 | cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 94 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 95 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 96 | quiet_cmd_remove = REMOVE $(_dst)/$@ |
| 97 | cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 98 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 99 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 100 | cmd_mkdir = mkdir -p $@ |
| 101 | |
| 102 | quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 103 | cmd_gen = \ |
David Woodhouse | 0db19c4 | 2007-07-06 02:39:52 -0700 | [diff] [blame] | 104 | FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@); \ |
Mike Frysinger | ec268be | 2007-01-30 14:35:55 -0800 | [diff] [blame] | 105 | STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 106 | (echo "/* File autogenerated by 'make headers_install' */" ; \ |
| 107 | echo "\#ifndef $$STUBDEF" ; \ |
| 108 | echo "\#define $$STUBDEF" ; \ |
| 109 | echo "\# if $(ARCHDEF)" ; \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 110 | if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \ |
| 111 | echo "\# include <$(archasm)/$$FNAME>" ; \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 112 | else \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 113 | echo "\# error $(archasm)/$$FNAME does not exist in" \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 114 | "the $(ARCH) architecture" ; \ |
| 115 | fi ; \ |
| 116 | echo "\# elif $(ALTARCHDEF)" ; \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 117 | if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \ |
| 118 | echo "\# include <$(altarchasm)/$$FNAME>" ; \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 119 | else \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 120 | echo "\# error $(altarchasm)/$$FNAME does not exist in" \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 121 | "the $(ALTARCH) architecture" ; \ |
| 122 | fi ; \ |
| 123 | echo "\# else" ; \ |
| 124 | echo "\# warning This machine appears to be" \ |
| 125 | "neither $(ARCH) nor $(ALTARCH)." ; \ |
| 126 | echo "\# endif" ; \ |
| 127 | echo "\#endif /* $$STUBDEF */" ; \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 128 | ) > $@ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 129 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 130 | .PHONY: __headersinst __headerscheck |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 131 | |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 132 | ifdef HDRCHECK |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 133 | __headerscheck: $(subdir-y) $(check-y) |
| 134 | @true |
| 135 | |
| 136 | $(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 137 | $(call cmd,check) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 138 | |
| 139 | # Other dependencies for $(check-y) |
David Woodhouse | df5f631 | 2007-05-21 19:53:35 -0400 | [diff] [blame] | 140 | include /dev/null $(wildcard $(check-y)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 141 | |
| 142 | # ... but leave $(check-y) as .PHONY for now until those deps are actually correct. |
| 143 | .PHONY: $(check-y) |
| 144 | |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 145 | else |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 146 | # Rules for installing headers |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 147 | __headersinst: $(subdir-y) $(header-y) $(altarch-y) $(objhdr-y) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 148 | @true |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 149 | |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 150 | $(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 151 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 152 | $(INSTALL_HDR_PATH)/$(_dst): |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 153 | $(call cmd,mkdir) |
| 154 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 155 | .PHONY: $(unwanted) |
| 156 | $(unwanted): |
| 157 | $(call cmd,remove) |
| 158 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 159 | ifdef GENASM |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 160 | $(objhdr-y) $(header-y): $(KBUILDFILES) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 161 | $(call cmd,gen) |
| 162 | |
| 163 | else |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 164 | $(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(KBUILDFILES) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 165 | $(call cmd,o_hdr_install) |
| 166 | |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 167 | $(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 168 | $(call cmd,unifdef) |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 169 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 170 | endif |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 171 | endif |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 172 | |
| 173 | hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
| 174 | |
| 175 | .PHONY: altarch-dir |
David Woodhouse | b512217 | 2006-09-16 12:15:45 -0700 | [diff] [blame] | 176 | # All the files in the normal arch dir must be created first, since we test |
| 177 | # for their existence. |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame^] | 178 | altarch-dir: $(subdir-y) $(header-y) $(objhdr-y) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 179 | $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 180 | $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 181 | |
| 182 | # Recursion |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 183 | .PHONY: $(subdir-y) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 184 | $(subdir-y): |
| 185 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) |