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" \ |
| 14 | -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ |
| 15 | -e "s/(__user[[:space:]]\+/ (/g" \ |
| 16 | -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ |
| 17 | -e "s/(__force[[:space:]]\+/ (/g" \ |
| 18 | -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ |
| 19 | -e "s/(__iomem[[:space:]]\+/ (/g" \ |
| 20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ |
| 21 | -e "s/[[:space:]]__attribute_const__$$//" \ |
| 22 | -e "/^\#include <linux\/compiler.h>/d" |
| 23 | |
| 24 | _dst := $(if $(dst),$(dst),$(obj)) |
| 25 | |
| 26 | .PHONY: __headersinst |
| 27 | __headersinst: |
| 28 | |
| 29 | |
| 30 | ifeq (,$(patsubst include/asm/%,,$(obj)/)) |
| 31 | # For producing the generated stuff in include/asm for biarch builds, include |
| 32 | # both sets of Kbuild files; we'll generate anything which is mentioned in |
| 33 | # _either_ arch, and recurse into subdirectories which are mentioned in either |
| 34 | # arch. Since some directories may exist in one but not the other, we must |
| 35 | # use '-include'. |
| 36 | GENASM := 1 |
| 37 | archasm := $(subst include/asm,asm-$(ARCH),$(obj)) |
| 38 | altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) |
| 39 | -include $(srctree)/include/$(archasm)/Kbuild |
| 40 | -include $(srctree)/include/$(altarchasm)/Kbuild |
| 41 | else |
| 42 | include $(srctree)/$(obj)/Kbuild |
| 43 | endif |
| 44 | |
| 45 | include scripts/Kbuild.include |
| 46 | |
| 47 | # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then |
| 48 | # override $(_dst) so that we install to include/asm directly. |
| 49 | ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)) |
| 50 | _dst := include/asm |
| 51 | endif |
| 52 | |
| 53 | header-y := $(sort $(header-y)) |
| 54 | unifdef-y := $(sort $(unifdef-y)) |
| 55 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) |
| 56 | header-y := $(filter-out %/, $(header-y)) |
| 57 | header-y := $(filter-out $(unifdef-y),$(header-y)) |
| 58 | |
| 59 | ifdef ALTARCH |
| 60 | ifeq ($(obj),include/asm-$(ARCH)) |
| 61 | altarch-y := altarch-dir |
| 62 | endif |
| 63 | endif |
| 64 | |
| 65 | # Make the definitions visible for recursive make invocations |
| 66 | export ALTARCH |
| 67 | export ARCHDEF |
| 68 | export ALTARCHDEF |
| 69 | |
| 70 | quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@ |
| 71 | cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst) |
| 72 | |
| 73 | quiet_cmd_headers_install = INSTALL $(_dst)/$@ |
| 74 | cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ |
| 75 | > $(INSTALL_HDR_PATH)/$(_dst)/$@ |
| 76 | |
| 77 | quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ |
| 78 | cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ |
| 79 | > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : |
| 80 | |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 81 | quiet_cmd_check = CHECK $(_dst)/$@ |
| 82 | cmd_check = $(srctree)/scripts/hdrcheck.sh \ |
| 83 | $(INSTALL_HDR_PATH)/include \ |
| 84 | $(INSTALL_HDR_PATH)/$(_dst)/$@ |
| 85 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 86 | quiet_cmd_mkdir = MKDIR $@ |
| 87 | cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ |
| 88 | |
| 89 | quiet_cmd_gen = GEN $(_dst)/$@ |
| 90 | cmd_gen = \ |
| 91 | STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \ |
| 92 | (echo "/* File autogenerated by 'make headers_install' */" ; \ |
| 93 | echo "\#ifndef $$STUBDEF" ; \ |
| 94 | echo "\#define $$STUBDEF" ; \ |
| 95 | echo "\# if $(ARCHDEF)" ; \ |
David Woodhouse | b512217 | 2006-09-16 12:15:45 -0700 | [diff] [blame] | 96 | if [ -r $(INSTALL_HDR_PATH)/include/$(archasm)/$@ ]; then \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 97 | echo "\# include <$(archasm)/$@>" ; \ |
| 98 | else \ |
| 99 | echo "\# error $(archasm)/$@ does not exist in" \ |
| 100 | "the $(ARCH) architecture" ; \ |
| 101 | fi ; \ |
| 102 | echo "\# elif $(ALTARCHDEF)" ; \ |
David Woodhouse | b512217 | 2006-09-16 12:15:45 -0700 | [diff] [blame] | 103 | if [ -r $(INSTALL_HDR_PATH)/include/$(altarchasm)/$@ ]; then \ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 104 | echo "\# include <$(altarchasm)/$@>" ; \ |
| 105 | else \ |
| 106 | echo "\# error $(altarchasm)/$@ does not exist in" \ |
| 107 | "the $(ALTARCH) architecture" ; \ |
| 108 | fi ; \ |
| 109 | echo "\# else" ; \ |
| 110 | echo "\# warning This machine appears to be" \ |
| 111 | "neither $(ARCH) nor $(ALTARCH)." ; \ |
| 112 | echo "\# endif" ; \ |
| 113 | echo "\#endif /* $$STUBDEF */" ; \ |
| 114 | ) > $(INSTALL_HDR_PATH)/$(_dst)/$@ |
| 115 | |
| 116 | __headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) |
| 117 | |
| 118 | .PHONY: $(header-y) $(unifdef-y) $(subdir-y) |
| 119 | |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 120 | ifdef HDRCHECK |
| 121 | # Rules for checking headers |
| 122 | $(objhdr-y) $(header-y) $(unifdef-y): |
| 123 | $(call cmd,check) |
| 124 | else |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 125 | # Rules for installing headers |
| 126 | |
| 127 | $(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) |
| 128 | |
| 129 | .PHONY: $(_dst) |
| 130 | $(_dst): |
| 131 | $(call cmd,mkdir) |
| 132 | |
| 133 | ifdef GENASM |
| 134 | $(objhdr-y) $(header-y) $(unifdef-y): |
| 135 | $(call cmd,gen) |
| 136 | |
| 137 | else |
| 138 | $(objhdr-y): |
| 139 | $(call cmd,o_hdr_install) |
| 140 | |
| 141 | $(header-y): |
| 142 | $(call cmd,headers_install) |
| 143 | |
| 144 | $(unifdef-y): |
| 145 | $(call cmd,unifdef) |
| 146 | endif |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 147 | endif |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 148 | |
| 149 | hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
| 150 | |
| 151 | .PHONY: altarch-dir |
David Woodhouse | b512217 | 2006-09-16 12:15:45 -0700 | [diff] [blame] | 152 | # All the files in the normal arch dir must be created first, since we test |
| 153 | # for their existence. |
| 154 | altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 155 | $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) |
| 156 | $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm |
| 157 | |
| 158 | # Recursion |
| 159 | $(subdir-y): |
| 160 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) |