2006-06-18 10:58:39 +00:00
|
|
|
# ==========================================================================
|
|
|
|
# Installing headers
|
|
|
|
#
|
|
|
|
# header-y files will be installed verbatim
|
|
|
|
# unifdef-y are the files where unifdef will be run before installing files
|
|
|
|
# objhdr-y are generated files that will be installed verbatim
|
|
|
|
#
|
|
|
|
# ==========================================================================
|
|
|
|
|
2006-07-23 18:47:50 +00:00
|
|
|
UNIFDEF := scripts/unifdef -U__KERNEL__
|
2006-06-18 10:58:39 +00:00
|
|
|
|
|
|
|
# Eliminate the contents of (and inclusions of) compiler.h
|
2008-06-07 11:18:26 +00:00
|
|
|
HDRSED := sed -e "s/ inline / __inline__ /g" \
|
2007-07-09 18:43:55 +00:00
|
|
|
-e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
|
|
|
|
-e "s/(__user[[:space:]]\{1,\}/ (/g" \
|
|
|
|
-e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
|
|
|
|
-e "s/(__force[[:space:]]\{1,\}/ (/g" \
|
|
|
|
-e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
|
|
|
|
-e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
|
|
|
|
-e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \
|
2006-06-18 10:58:39 +00:00
|
|
|
-e "s/[[:space:]]__attribute_const__$$//" \
|
|
|
|
-e "/^\#include <linux\/compiler.h>/d"
|
|
|
|
|
|
|
|
_dst := $(if $(dst),$(dst),$(obj))
|
|
|
|
|
2008-06-05 17:19:47 +00:00
|
|
|
kbuild-file := $(srctree)/$(obj)/Kbuild
|
|
|
|
include $(kbuild-file)
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2008-06-05 17:19:47 +00:00
|
|
|
include scripts/Kbuild.include
|
2006-09-24 21:15:14 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
install := $(INSTALL_HDR_PATH)/$(_dst)
|
|
|
|
|
2008-06-05 14:52:15 +00:00
|
|
|
header-y := $(sort $(header-y) $(unifdef-y))
|
2006-06-18 10:58:39 +00:00
|
|
|
subdir-y := $(patsubst %/,%,$(filter %/, $(header-y)))
|
|
|
|
header-y := $(filter-out %/, $(header-y))
|
|
|
|
|
2006-09-24 21:15:14 +00:00
|
|
|
# stamp files for header checks
|
2008-06-05 14:52:15 +00:00
|
|
|
check-y := $(patsubst %,.check.%,$(header-y) $(objhdr-y))
|
2006-09-24 21:15:14 +00:00
|
|
|
|
|
|
|
# Work out what needs to be removed
|
2008-06-07 11:18:26 +00:00
|
|
|
oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
|
|
|
|
unwanted := $(filter-out $(header-y) $(objhdr-y),$(oldheaders))
|
2006-09-24 21:15:14 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
oldcheckstamps := $(patsubst $(install)/%,%,$(wildcard $(install)/.check.*.h))
|
|
|
|
unwanted += $(filter-out $(check-y),$(oldcheckstamps))
|
2006-09-24 21:15:14 +00:00
|
|
|
|
|
|
|
# Prefix them all with full paths to $(INSTALL_HDR_PATH)
|
2008-06-07 11:18:26 +00:00
|
|
|
header-y := $(patsubst %,$(install)/%,$(header-y))
|
|
|
|
objhdr-y := $(patsubst %,$(install)/%,$(objhdr-y))
|
|
|
|
check-y := $(patsubst %,$(install)/%,$(check-y))
|
2006-09-24 21:15:14 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
|
|
|
|
cmd_o_hdr_install = cp $(patsubst $(install)/%,$(objtree)/$(obj)/%,$@) \
|
|
|
|
$(install)
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
|
|
|
|
cmd_unifdef = $(UNIFDEF) $(patsubst $(install)/%,$(srctree)/$(obj)/%,$@)\
|
|
|
|
| $(HDRSED) > $@ || :
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
quiet_cmd_check = CHECK $(patsubst $(install)/.check.%,$(_dst)/%,$@)
|
|
|
|
cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
|
|
|
|
$(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
|
2006-09-24 21:15:14 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
quiet_cmd_remove = REMOVE $(_dst)/$@
|
|
|
|
cmd_remove = rm -f $(install)/$@
|
2006-06-18 11:02:10 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
|
|
|
|
cmd_mkdir = mkdir -p $@
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2006-09-24 21:15:14 +00:00
|
|
|
.PHONY: __headersinst __headerscheck
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2006-06-18 11:02:10 +00:00
|
|
|
ifdef HDRCHECK
|
2006-09-24 21:15:14 +00:00
|
|
|
__headerscheck: $(subdir-y) $(check-y)
|
|
|
|
@true
|
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
$(check-y) : $(install)/.check.%.h : $(install)/%.h
|
2006-06-18 11:02:10 +00:00
|
|
|
$(call cmd,check)
|
2006-09-24 21:15:14 +00:00
|
|
|
|
|
|
|
# Other dependencies for $(check-y)
|
2007-05-21 23:53:35 +00:00
|
|
|
include /dev/null $(wildcard $(check-y))
|
2006-09-24 21:15:14 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
# but leave $(check-y) as .PHONY for now until those
|
|
|
|
# deps are actually correct.
|
2006-09-24 21:15:14 +00:00
|
|
|
.PHONY: $(check-y)
|
|
|
|
|
2006-06-18 11:02:10 +00:00
|
|
|
else
|
2006-06-18 10:58:39 +00:00
|
|
|
# Rules for installing headers
|
2008-06-05 17:19:47 +00:00
|
|
|
__headersinst: $(subdir-y) $(header-y) $(objhdr-y)
|
2006-09-24 21:15:14 +00:00
|
|
|
@true
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
$(objhdr-y) $(subdir-y) $(header-y): | $(install) $(unwanted)
|
2006-06-18 10:58:39 +00:00
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
$(install):
|
2006-06-18 10:58:39 +00:00
|
|
|
$(call cmd,mkdir)
|
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
# Rules for removing unwanted header files
|
2006-09-24 21:15:14 +00:00
|
|
|
.PHONY: $(unwanted)
|
|
|
|
$(unwanted):
|
|
|
|
$(call cmd,remove)
|
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
# Install generated files
|
|
|
|
$(objhdr-y): $(install)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file)
|
2006-06-18 10:58:39 +00:00
|
|
|
$(call cmd,o_hdr_install)
|
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
# Unifdef header files and install them
|
|
|
|
$(header-y): $(install)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file)
|
2006-06-18 10:58:39 +00:00
|
|
|
$(call cmd,unifdef)
|
2008-06-05 14:52:15 +00:00
|
|
|
|
2006-06-18 10:58:39 +00:00
|
|
|
endif
|
|
|
|
|
2008-06-07 11:18:26 +00:00
|
|
|
hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
|
2006-06-18 10:58:39 +00:00
|
|
|
|
|
|
|
# Recursion
|
2006-09-24 21:15:14 +00:00
|
|
|
.PHONY: $(subdir-y)
|
2006-06-18 10:58:39 +00:00
|
|
|
$(subdir-y):
|
2008-06-07 11:18:26 +00:00
|
|
|
$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
|