kbuild: drop support of ALTARCH for headers_*
[safe/jmp/linux-2.6] / scripts / Makefile.headersinst
1 # ==========================================================================
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
10 UNIFDEF := scripts/unifdef -U__KERNEL__
11
12 # Eliminate the contents of (and inclusions of) compiler.h
13 HDRSED  := sed  -e "s/ inline / __inline__ /g" \
14                 -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" \
21                 -e "s/[[:space:]]__attribute_const__$$//" \
22                 -e "/^\#include <linux\/compiler.h>/d"
23
24 _dst := $(if $(dst),$(dst),$(obj))
25
26 kbuild-file := $(srctree)/$(obj)/Kbuild
27 include $(kbuild-file)
28
29 include scripts/Kbuild.include
30
31 # If this is include/asm-$(ARCH) then override $(_dst) so that
32 # we install to include/asm directly.
33 # 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.
36 ifeq ($(obj),include/asm-$(ARCH)$(BIASMDIR))
37      _dst := include/asm
38 endif
39
40 header-y        := $(sort $(header-y) $(unifdef-y))
41 subdir-y        := $(patsubst %/,%,$(filter %/, $(header-y)))
42 header-y        := $(filter-out %/, $(header-y))
43
44 # stamp files for header checks
45 check-y         := $(patsubst %,.check.%,$(header-y) $(objhdr-y))
46
47 # Work out what needs to be removed
48 oldheaders      := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h))
49 unwanted        := $(filter-out $(header-y) $(objhdr-y),$(oldheaders))
50
51 oldcheckstamps  := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h))
52 unwanted        += $(filter-out $(check-y),$(oldcheckstamps))
53
54 # Prefix them all with full paths to $(INSTALL_HDR_PATH)
55 header-y        := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y))
56 objhdr-y        := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y))
57 check-y         := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y))
58
59 quiet_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)
62
63 quiet_cmd_unifdef         = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
64       cmd_unifdef         = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
65                                    | $(HDRSED) > $@ || :
66
67 quiet_cmd_check           = CHECK   $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
68       cmd_check           = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
69                               $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
70
71 quiet_cmd_remove          = REMOVE  $(_dst)/$@
72       cmd_remove          = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
73
74 quiet_cmd_mkdir           = MKDIR   $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
75       cmd_mkdir           = mkdir -p $@
76
77 .PHONY: __headersinst __headerscheck
78
79 ifdef HDRCHECK
80 __headerscheck: $(subdir-y) $(check-y)
81         @true
82
83 $(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h 
84         $(call cmd,check)
85
86 # Other dependencies for $(check-y)
87 include /dev/null $(wildcard $(check-y))
88
89 # ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
90 .PHONY: $(check-y)
91
92 else
93 # Rules for installing headers
94 __headersinst: $(subdir-y) $(header-y) $(objhdr-y)
95         @true
96
97 $(objhdr-y) $(subdir-y) $(header-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted)
98
99 $(INSTALL_HDR_PATH)/$(_dst):
100         $(call cmd,mkdir)
101
102 .PHONY: $(unwanted)
103 $(unwanted):
104         $(call cmd,remove)
105
106 $(objhdr-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(kbuild-file)
107         $(call cmd,o_hdr_install)
108
109 $(header-y): $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(kbuild-file)
110         $(call cmd,unifdef)
111
112 endif
113
114 hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
115
116 # Recursion
117 .PHONY: $(subdir-y)
118 $(subdir-y):
119         $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel)