summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-06-04 06:14:02 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-06-15 06:57:02 -0400
commit59b2bd05f5f4dc62979c2e82ddd384f07e8f10bc (patch)
treeebb1a1d1d41a40074c3baab8fc0135ad4031abf3 /Makefile
parentbdd7714b6f4cca75dd1b234306077150060c2f45 (diff)
kbuild: add 'headers' target to build up uapi headers in usr/include
In Linux build system, build targets and installation targets are separated. Examples are: - 'make vmlinux' -> 'make install' - 'make modules' -> 'make modules_install' - 'make dtbs' -> 'make dtbs_install' - 'make vdso' -> 'make vdso_install' The intention is to run the build targets under the normal privilege, then the installation targets under the root privilege since we need the write permission to the system directories. We have 'make headers_install' but the corresponding 'make headers' stage does not exist. The purpose of headers_install is to provide the kernel interface to C library. So, nobody would try to install headers to /usr/include directly. If 'sudo make INSTALL_HDR_PATH=/usr/include headers_install' were run, some build artifacts in the kernel tree would be owned by root because some of uapi headers are generated by 'uapi-asm-generic', 'archheaders' targets. Anyway, I believe it makes sense to split the header installation into two stages. [1] 'make headers' Process headers in uapi directories by scripts/headers_install.sh and copy them to usr/include [2] 'make headers_install' Copy '*.h' verbatim from usr/include to $(INSTALL_HDR_PATH)/include For the backward compatibility, 'headers_install' depends on 'headers'. Some samples expect uapi headers in usr/include. So, the 'headers' target is useful to build up them in the fixed location usr/include irrespective of INSTALL_HDR_PATH. Another benefit is to stop polluting the final destination with the time-stamp files '.install' and '.check'. Maybe you can see them in your toolchains. Lastly, my main motivation is to prepare for compile-testing uapi headers. To build something, we have to save an object and .*.cmd somewhere. The usr/include/ will be the work directory for that. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile23
1 files changed, 15 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 39ee585b52b1..11445a7dd820 100644
--- a/Makefile
+++ b/Makefile
@@ -262,7 +262,7 @@ old_version_h := include/linux/version.h
262clean-targets := %clean mrproper cleandocs 262clean-targets := %clean mrproper cleandocs
263no-dot-config-targets := $(clean-targets) \ 263no-dot-config-targets := $(clean-targets) \
264 cscope gtags TAGS tags help% %docs check% coccicheck \ 264 cscope gtags TAGS tags help% %docs check% coccicheck \
265 $(version_h) headers_% archheaders archscripts \ 265 $(version_h) headers headers_% archheaders archscripts \
266 %asm-generic kernelversion %src-pkg 266 %asm-generic kernelversion %src-pkg
267no-sync-config-targets := $(no-dot-config-targets) install %install \ 267no-sync-config-targets := $(no-dot-config-targets) install %install \
268 kernelrelease 268 kernelrelease
@@ -1178,25 +1178,32 @@ headerdep:
1178#Default location for installed headers 1178#Default location for installed headers
1179export INSTALL_HDR_PATH = $(objtree)/usr 1179export INSTALL_HDR_PATH = $(objtree)/usr
1180 1180
1181PHONY += archheaders archscripts 1181quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
1182 1182 cmd_headers_install = \
1183PHONY += __headers 1183 mkdir -p $(INSTALL_HDR_PATH); \
1184__headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts 1184 rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
1185 usr/include $(INSTALL_HDR_PATH)
1185 1186
1186PHONY += headers_install 1187PHONY += headers_install
1187headers_install: __headers 1188headers_install: headers
1189 $(call cmd,headers_install)
1190
1191PHONY += archheaders archscripts
1192
1193PHONY += headers
1194headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
1188 $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \ 1195 $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \
1189 $(error Headers not exportable for the $(SRCARCH) architecture)) 1196 $(error Headers not exportable for the $(SRCARCH) architecture))
1190 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include 1197 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include
1191 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include 1198 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include
1192 1199
1193PHONY += headers_check 1200PHONY += headers_check
1194headers_check: headers_install 1201headers_check: headers
1195 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1 1202 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
1196 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include HDRCHECK=1 1203 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi dst=include HDRCHECK=1
1197 1204
1198ifdef CONFIG_HEADERS_INSTALL 1205ifdef CONFIG_HEADERS_INSTALL
1199prepare: headers_install 1206prepare: headers
1200endif 1207endif
1201 1208
1202ifdef CONFIG_HEADERS_CHECK 1209ifdef CONFIG_HEADERS_CHECK