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 | |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 26 | kbuild-file := $(srctree)/$(obj)/Kbuild |
| 27 | include $(kbuild-file) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 28 | |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 29 | include scripts/Kbuild.include |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 30 | |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 31 | # If this is include/asm-$(ARCH) then override $(_dst) so that |
| 32 | # we install to include/asm directly. |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 33 | # Unless $(BIASMDIR) is set, in which case we're probably doing |
| 34 | # a 'headers_install_all' build and we should keep the -$(ARCH) |
| 35 | # in the directory name. |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 36 | ifeq ($(obj),include/asm-$(ARCH)$(BIASMDIR)) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 37 | _dst := include/asm |
| 38 | endif |
| 39 | |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame] | 40 | header-y := $(sort $(header-y) $(unifdef-y)) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 41 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) |
| 42 | header-y := $(filter-out %/, $(header-y)) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 43 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 44 | # stamp files for header checks |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame] | 45 | check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 46 | |
| 47 | # Work out what needs to be removed |
| 48 | oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame] | 49 | unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 50 | |
| 51 | oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) |
| 52 | unwanted += $(filter-out $(check-y),$(oldcheckstamps)) |
| 53 | |
| 54 | # Prefix them all with full paths to $(INSTALL_HDR_PATH) |
| 55 | header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 56 | objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) |
| 57 | check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) |
| 58 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 59 | quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 60 | cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ |
| 61 | $(INSTALL_HDR_PATH)/$(_dst) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 62 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 63 | quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 64 | cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ |
| 65 | | $(HDRSED) > $@ || : |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 66 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 67 | quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) |
Andrew Morton | 4e776b1 | 2006-10-04 02:15:20 -0700 | [diff] [blame] | 68 | cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \ |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 69 | $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@ |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 70 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 71 | quiet_cmd_remove = REMOVE $(_dst)/$@ |
| 72 | cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 73 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 74 | quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) |
| 75 | cmd_mkdir = mkdir -p $@ |
| 76 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 77 | .PHONY: __headersinst __headerscheck |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 78 | |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 79 | ifdef HDRCHECK |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 80 | __headerscheck: $(subdir-y) $(check-y) |
| 81 | @true |
| 82 | |
| 83 | $(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] | 84 | $(call cmd,check) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 85 | |
| 86 | # Other dependencies for $(check-y) |
David Woodhouse | df5f631 | 2007-05-21 19:53:35 -0400 | [diff] [blame] | 87 | include /dev/null $(wildcard $(check-y)) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 88 | |
| 89 | # ... but leave $(check-y) as .PHONY for now until those deps are actually correct. |
| 90 | .PHONY: $(check-y) |
| 91 | |
David Woodhouse | 6847535 | 2006-06-18 12:02:10 +0100 | [diff] [blame] | 92 | else |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 93 | # Rules for installing headers |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 94 | __headersinst: $(subdir-y) $(header-y) $(objhdr-y) |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 95 | @true |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 96 | |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame] | 97 | $(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) |
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 | $(INSTALL_HDR_PATH)/$(_dst): |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 100 | $(call cmd,mkdir) |
| 101 | |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 102 | .PHONY: $(unwanted) |
| 103 | $(unwanted): |
| 104 | $(call cmd,remove) |
| 105 | |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 106 | $(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 107 | $(call cmd,o_hdr_install) |
| 108 | |
Sam Ravnborg | 283039f | 2008-06-05 19:19:47 +0200 | [diff] [blame^] | 109 | $(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 110 | $(call cmd,unifdef) |
Sam Ravnborg | 4e420aa | 2008-06-05 16:52:15 +0200 | [diff] [blame] | 111 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 112 | endif |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 113 | |
| 114 | hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj |
| 115 | |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 116 | # Recursion |
David Woodhouse | de78912 | 2006-09-24 22:15:14 +0100 | [diff] [blame] | 117 | .PHONY: $(subdir-y) |
David Woodhouse | 8d730cf | 2006-06-18 11:58:39 +0100 | [diff] [blame] | 118 | $(subdir-y): |
| 119 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) |