blob: 1fb8c003920fb4857282eb9860dbf4e16ae615d1 [file] [log] [blame]
David Woodhouse8d730cf2006-06-18 11:58:39 +01001# ==========================================================================
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 Ravnborg07aea3a2006-07-23 20:47:50 +020010UNIFDEF := scripts/unifdef -U__KERNEL__
David Woodhouse8d730cf2006-06-18 11:58:39 +010011
12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \
Mike Frysingerc0519032007-07-09 11:43:55 -070014 -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 Woodhouse8d730cf2006-06-18 11:58:39 +010021 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d"
23
24_dst := $(if $(dst),$(dst),$(obj))
25
Sam Ravnborg283039f2008-06-05 19:19:47 +020026kbuild-file := $(srctree)/$(obj)/Kbuild
27include $(kbuild-file)
David Woodhouse8d730cf2006-06-18 11:58:39 +010028
Sam Ravnborg283039f2008-06-05 19:19:47 +020029include scripts/Kbuild.include
David Woodhousede789122006-09-24 22:15:14 +010030
Sam Ravnborg283039f2008-06-05 19:19:47 +020031# If this is include/asm-$(ARCH) then override $(_dst) so that
32# we install to include/asm directly.
David Woodhousede789122006-09-24 22:15:14 +010033# 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 Ravnborg283039f2008-06-05 19:19:47 +020036ifeq ($(obj),include/asm-$(ARCH)$(BIASMDIR))
David Woodhouse8d730cf2006-06-18 11:58:39 +010037 _dst := include/asm
38endif
39
Sam Ravnborg4e420aa2008-06-05 16:52:15 +020040header-y := $(sort $(header-y) $(unifdef-y))
David Woodhouse8d730cf2006-06-18 11:58:39 +010041subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
42header-y := $(filter-out %/, $(header-y))
David Woodhouse8d730cf2006-06-18 11:58:39 +010043
David Woodhousede789122006-09-24 22:15:14 +010044# stamp files for header checks
Sam Ravnborg4e420aa2008-06-05 16:52:15 +020045check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y))
David Woodhousede789122006-09-24 22:15:14 +010046
47# Work out what needs to be removed
48oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h))
Sam Ravnborg4e420aa2008-06-05 16:52:15 +020049unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders))
David Woodhousede789122006-09-24 22:15:14 +010050
51oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h))
52unwanted += $(filter-out $(check-y),$(oldcheckstamps))
53
54# Prefix them all with full paths to $(INSTALL_HDR_PATH)
55header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y))
David Woodhousede789122006-09-24 22:15:14 +010056objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y))
57check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y))
58
David Woodhousede789122006-09-24 22:15:14 +010059quiet_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 Woodhouse8d730cf2006-06-18 11:58:39 +010062
David Woodhousede789122006-09-24 22:15:14 +010063quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
64 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
65 | $(HDRSED) > $@ || :
David Woodhouse8d730cf2006-06-18 11:58:39 +010066
David Woodhousede789122006-09-24 22:15:14 +010067quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
Andrew Morton4e776b12006-10-04 02:15:20 -070068 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
David Woodhousede789122006-09-24 22:15:14 +010069 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
David Woodhouse68475352006-06-18 12:02:10 +010070
David Woodhousede789122006-09-24 22:15:14 +010071quiet_cmd_remove = REMOVE $(_dst)/$@
72 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
David Woodhouse8d730cf2006-06-18 11:58:39 +010073
David Woodhousede789122006-09-24 22:15:14 +010074quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
75 cmd_mkdir = mkdir -p $@
76
David Woodhousede789122006-09-24 22:15:14 +010077.PHONY: __headersinst __headerscheck
David Woodhouse8d730cf2006-06-18 11:58:39 +010078
David Woodhouse68475352006-06-18 12:02:10 +010079ifdef HDRCHECK
David Woodhousede789122006-09-24 22:15:14 +010080__headerscheck: $(subdir-y) $(check-y)
81 @true
82
83$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
David Woodhouse68475352006-06-18 12:02:10 +010084 $(call cmd,check)
David Woodhousede789122006-09-24 22:15:14 +010085
86# Other dependencies for $(check-y)
David Woodhousedf5f6312007-05-21 19:53:35 -040087include /dev/null $(wildcard $(check-y))
David Woodhousede789122006-09-24 22:15:14 +010088
89# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
90.PHONY: $(check-y)
91
David Woodhouse68475352006-06-18 12:02:10 +010092else
David Woodhouse8d730cf2006-06-18 11:58:39 +010093# Rules for installing headers
Sam Ravnborg283039f2008-06-05 19:19:47 +020094__headersinst: $(subdir-y) $(header-y) $(objhdr-y)
David Woodhousede789122006-09-24 22:15:14 +010095 @true
David Woodhouse8d730cf2006-06-18 11:58:39 +010096
Sam Ravnborg4e420aa2008-06-05 16:52:15 +020097$(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted)
David Woodhouse8d730cf2006-06-18 11:58:39 +010098
David Woodhousede789122006-09-24 22:15:14 +010099$(INSTALL_HDR_PATH)/$(_dst):
David Woodhouse8d730cf2006-06-18 11:58:39 +0100100 $(call cmd,mkdir)
101
David Woodhousede789122006-09-24 22:15:14 +0100102.PHONY: $(unwanted)
103$(unwanted):
104 $(call cmd,remove)
105
Sam Ravnborg283039f2008-06-05 19:19:47 +0200106$(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file)
David Woodhouse8d730cf2006-06-18 11:58:39 +0100107 $(call cmd,o_hdr_install)
108
Sam Ravnborg283039f2008-06-05 19:19:47 +0200109$(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file)
David Woodhouse8d730cf2006-06-18 11:58:39 +0100110 $(call cmd,unifdef)
Sam Ravnborg4e420aa2008-06-05 16:52:15 +0200111
David Woodhouse8d730cf2006-06-18 11:58:39 +0100112endif
David Woodhouse8d730cf2006-06-18 11:58:39 +0100113
114hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
115
David Woodhouse8d730cf2006-06-18 11:58:39 +0100116# Recursion
David Woodhousede789122006-09-24 22:15:14 +0100117.PHONY: $(subdir-y)
David Woodhouse8d730cf2006-06-18 11:58:39 +0100118$(subdir-y):
119 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)