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