kconfig: Check for libncurses before menuconfig
[linux-block.git] / scripts / Makefile.headersinst
CommitLineData
8d730cfb
DW
1# ==========================================================================
2# Installing headers
3#
fcc8487d 4# All headers under include/uapi, include/generated/uapi,
61562f98 5# arch/<arch>/include/uapi and arch/<arch>/include/generated/uapi are
fcc8487d
ND
6# exported.
7# They are preprocessed to remove __KERNEL__ section of the file.
8d730cfb
DW
8#
9# ==========================================================================
10
05d8cba4
MY
11PHONY := __headers
12__headers:
13
14include scripts/Kbuild.include
15
16srcdir := $(srctree)/$(obj)
17subdirs := $(patsubst $(srcdir)/%/.,%,$(wildcard $(srcdir)/*/.))
18# caller may set destination dir (when installing to asm/)
19_dst := $(if $(dst),$(dst),$(obj))
20
21# Recursion
22__headers: $(subdirs)
23
24.PHONY: $(subdirs)
25$(subdirs):
26 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
27
28# Skip header install/check for include/uapi and arch/$(hdr-arch)/include/uapi.
29# We have only sub-directories there.
30skip-inst := $(if $(filter %/uapi,$(obj)),1)
31
32ifeq ($(skip-inst),)
33
cb97914b
PA
34# generated header directory
35gen := $(if $(gen),$(gen),$(subst include/,include/generated/,$(obj)))
36
fcc8487d 37# Kbuild file is optional
283039fb 38kbuild-file := $(srctree)/$(obj)/Kbuild
fcc8487d 39-include $(kbuild-file)
8d730cfb 40
10b63956
DH
41old-kbuild-file := $(srctree)/$(subst uapi/,,$(obj))/Kbuild
42ifneq ($(wildcard $(old-kbuild-file)),)
43include $(old-kbuild-file)
44endif
c7bb349e 45
10b63956 46installdir := $(INSTALL_HDR_PATH)/$(subst uapi/,,$(_dst))
8d730cfb 47
fcc8487d 48gendir := $(objtree)/$(gen)
fcc8487d
ND
49header-files := $(notdir $(wildcard $(srcdir)/*.h))
50header-files += $(notdir $(wildcard $(srcdir)/*.agh))
51header-files := $(filter-out $(no-export-headers), $(header-files))
52genhdr-files := $(notdir $(wildcard $(gendir)/*.h))
53genhdr-files := $(filter-out $(header-files), $(genhdr-files))
de789125 54
7712401a 55# files used to track state of install/check
10b63956
DH
56install-file := $(installdir)/.install
57check-file := $(installdir)/.check
de789125 58
d8ecc5cd
SR
59# generic-y list all files an architecture uses from asm-generic
60# Use this to build a list of headers which require a wrapper
fcc8487d
ND
61generic-files := $(notdir $(wildcard $(srctree)/include/uapi/asm-generic/*.h))
62wrapper-files := $(filter $(generic-files), $(generic-y))
63wrapper-files := $(filter-out $(header-files), $(wrapper-files))
10b63956 64
7712401a 65# all headers files for this dir
fcc8487d 66all-files := $(header-files) $(genhdr-files) $(wrapper-files)
10b63956
DH
67output-files := $(addprefix $(installdir)/, $(all-files))
68
fcc8487d
ND
69ifneq ($(mandatory-y),)
70missing := $(filter-out $(all-files),$(mandatory-y))
71ifneq ($(missing),)
72$(error Some mandatory headers ($(missing)) are missing in $(obj))
73endif
74endif
de789125 75
7712401a 76# Work out what needs to be removed
10b63956 77oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
7712401a 78unwanted := $(filter-out $(all-files),$(oldheaders))
8d730cfb 79
7712401a 80# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
10b63956 81unwanted-file := $(addprefix $(installdir)/, $(unwanted))
de789125 82
7712401a 83printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
68475359 84
7712401a
SR
85quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
86 file$(if $(word 2, $(all-files)),s))
db1bec4f 87 cmd_install = \
fcc8487d
ND
88 $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \
89 $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \
d8ecc5cd 90 for F in $(wrapper-files); do \
10b63956 91 echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \
d8ecc5cd 92 done; \
db1bec4f 93 touch $@
8d730cfb 94
7712401a
SR
95quiet_cmd_remove = REMOVE $(unwanted)
96 cmd_remove = rm -f $(unwanted-file)
8d730cfb 97
7712401a 98quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
7211b8b9
SP
99# Headers list can be pretty long, xargs helps to avoid
100# the "Argument list too long" error.
101 cmd_check = for f in $(all-files); do \
10b63956 102 echo "$(installdir)/$${f}"; done \
7211b8b9
SP
103 | xargs \
104 $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \
7712401a 105 touch $@
de789125 106
7712401a
SR
107ifndef HDRCHECK
108# Rules for installing headers
05d8cba4 109__headers: $(install-file)
7712401a 110 @:
de789125 111
7712401a 112targets += $(install-file)
7c025b2a 113$(install-file): scripts/headers_install.sh \
fcc8487d
ND
114 $(addprefix $(srcdir)/,$(header-files)) \
115 $(addprefix $(gendir)/,$(genhdr-files)) FORCE
7712401a
SR
116 $(if $(unwanted),$(call cmd,remove),)
117 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
118 $(call if_changed,install)
de789125 119
68475359 120else
05d8cba4 121__headers: $(check-file)
7712401a 122 @:
8d730cfb 123
7712401a
SR
124targets += $(check-file)
125$(check-file): scripts/headers_check.pl $(output-files) FORCE
126 $(call if_changed,check)
8d730cfb 127
7712401a 128endif
de789125 129
7712401a
SR
130targets := $(wildcard $(sort $(targets)))
131cmd_files := $(wildcard \
132 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
4e420aa9 133
7712401a
SR
134ifneq ($(cmd_files),)
135 include $(cmd_files)
8d730cfb
DW
136endif
137
05d8cba4
MY
138endif # skip-inst
139
7712401a
SR
140.PHONY: $(PHONY)
141PHONY += FORCE
142FORCE: ;