mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 13:22:23 +00:00
e0e2fa4b51
Remove perl from make headers_install by replacing a perl script (doing a simple regex search and replace) with a smaller, faster, simpler, POSIX-2008 shell script implementation. The new shell script is a single for loop calling sed and piping its output through unifdef to produce the target file. Same as last time except for minor tweak to deal with code review from here: http://lkml.indiana.edu/hypermail/linux/kernel/1302.3/00078.html (Note that this drops the "arch" argument, which isn't used. Kbuild already points to the right input files on the command line.) Signed-off-by: Rob Landley <rob@landley.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Josh Boyer <jwboyer@redhat.com> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> Cc: David Howells <dhowell@redhat.com> Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
133 lines
4.3 KiB
Makefile
133 lines
4.3 KiB
Makefile
# ==========================================================================
|
|
# Installing headers
|
|
#
|
|
# header-y - list files to be installed. They are preprocessed
|
|
# to remove __KERNEL__ section of the file
|
|
# genhdr-y - Same as header-y but in a generated/ directory
|
|
#
|
|
# ==========================================================================
|
|
|
|
# generated header directory
|
|
gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj)))
|
|
|
|
kbuild-file := $(srctree)/$(obj)/Kbuild
|
|
include $(kbuild-file)
|
|
|
|
# called may set destination dir (when installing to asm/)
|
|
_dst := $(if $(destination-y),$(destination-y),$(if $(dst),$(dst),$(obj)))
|
|
|
|
old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild
|
|
ifneq ($(wildcard $(old-kbuild-file)),)
|
|
include $(old-kbuild-file)
|
|
endif
|
|
|
|
include scripts/Kbuild.include
|
|
|
|
installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst))
|
|
|
|
header-y := $(sort $(header-y))
|
|
subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
|
|
header-y := $(filter-out %/, $(header-y))
|
|
|
|
# files used to track state of install/check
|
|
install-file := $(installdir)/.install
|
|
check-file := $(installdir)/.check
|
|
|
|
# generic-y list all files an architecture uses from asm-generic
|
|
# Use this to build a list of headers which require a wrapper
|
|
wrapper-files := $(filter $(header-y), $(generic-y))
|
|
|
|
srcdir := $(srctree)/$(obj)
|
|
gendir := $(objtree)/$(gen)
|
|
|
|
oldsrcdir := $(srctree)/$(subst /uapi,,$(obj))
|
|
|
|
# all headers files for this dir
|
|
header-y := $(filter-out $(generic-y), $(header-y))
|
|
all-files := $(header-y) $(genhdr-y) $(wrapper-files)
|
|
output-files := $(addprefix $(installdir)/, $(all-files))
|
|
|
|
input-files := $(foreach hdr, $(header-y), \
|
|
$(if $(wildcard $(srcdir)/$(hdr)), \
|
|
$(wildcard $(srcdir)/$(hdr)), \
|
|
$(if $(wildcard $(oldsrcdir)/$(hdr)), \
|
|
$(wildcard $(oldsrcdir)/$(hdr)), \
|
|
$(error Missing UAPI file $(srcdir)/$(hdr))) \
|
|
)) \
|
|
$(foreach hdr, $(genhdr-y), \
|
|
$(if $(wildcard $(gendir)/$(hdr)), \
|
|
$(wildcard $(gendir)/$(hdr)), \
|
|
$(error Missing generated UAPI file $(gendir)/$(hdr)) \
|
|
))
|
|
|
|
# Work out what needs to be removed
|
|
oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
|
|
unwanted := $(filter-out $(all-files),$(oldheaders))
|
|
|
|
# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
|
|
unwanted-file := $(addprefix $(installdir)/, $(unwanted))
|
|
|
|
printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
|
|
|
|
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
|
|
file$(if $(word 2, $(all-files)),s))
|
|
cmd_install = \
|
|
$(CONFIG_SHELL) $< $(installdir) $(input-files); \
|
|
for F in $(wrapper-files); do \
|
|
echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \
|
|
done; \
|
|
touch $@
|
|
|
|
quiet_cmd_remove = REMOVE $(unwanted)
|
|
cmd_remove = rm -f $(unwanted-file)
|
|
|
|
quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
|
|
# Headers list can be pretty long, xargs helps to avoid
|
|
# the "Argument list too long" error.
|
|
cmd_check = for f in $(all-files); do \
|
|
echo "$(installdir)/$${f}"; done \
|
|
| xargs \
|
|
$(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \
|
|
touch $@
|
|
|
|
PHONY += __headersinst __headerscheck
|
|
|
|
ifndef HDRCHECK
|
|
# Rules for installing headers
|
|
__headersinst: $(subdirs) $(install-file)
|
|
@:
|
|
|
|
targets += $(install-file)
|
|
$(install-file): scripts/headers_install.sh $(input-files) FORCE
|
|
$(if $(unwanted),$(call cmd,remove),)
|
|
$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
|
|
$(call if_changed,install)
|
|
|
|
else
|
|
__headerscheck: $(subdirs) $(check-file)
|
|
@:
|
|
|
|
targets += $(check-file)
|
|
$(check-file): scripts/headers_check.pl $(output-files) FORCE
|
|
$(call if_changed,check)
|
|
|
|
endif
|
|
|
|
# Recursion
|
|
hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
|
|
.PHONY: $(subdirs)
|
|
$(subdirs):
|
|
$(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
|
|
|
|
targets := $(wildcard $(sort $(targets)))
|
|
cmd_files := $(wildcard \
|
|
$(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
|
|
|
|
ifneq ($(cmd_files),)
|
|
include $(cmd_files)
|
|
endif
|
|
|
|
.PHONY: $(PHONY)
|
|
PHONY += FORCE
|
|
FORCE: ;
|