mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 04:34:08 +08:00
d55571c008
- Refactor scripts/kallsyms to make it faster and easier to maintain - Clean up menuconfig - Provide Clang with hard-coded target triple instead of CROSS_COMPILE - Use -z pack-relative-relocs flags instead of --use-android-relr-tags for arm64 CONFIG_RELR - Add srcdeb-pkg target to build only a Debian source package - Add KDEB_SOURCE_COMPRESS option to specify the compression for a Debian source package - Misc cleanups and fixes -----BEGIN PGP SIGNATURE----- iQJJBAABCgAzFiEEbmPs18K1szRHjPqEPYsBB53g2wYFAmRM9usVHG1hc2FoaXJv eUBrZXJuZWwub3JnAAoJED2LAQed4NsGg+UQAKbDv/rlBLsdFOWnFgh8IUE58uUb UF/lmbyPQPZS1+z8WS/ec4ONigPd0gcfjI8klaZuYJ2j5xK0Nf+J8KRQlG9vLCDJ O0jPV77mKRMkz6UIaa5Dd8MNje8Pn+6T1qev1I9+0dBhyS2csHds3NuDuI/kDehB V1097moJcTEUGbNWTgnIA3LckIP51OMUgmT94gntcWcTvuGahRmn+Vvn4pijd6rn r3081wejYl+gZ9DGobRT7yXTsGNkHBHJcmK7VaocAL29haNt+rEULvAC1ABEUkaE tJMLodybbBiNH441EuUHJBA90yWUxL2EDmTz7kvvYrwem5FsFx6dpuKUXcJpCxW7 x66qOQHrHC7ZY98heMs07TLz+5yMhAseBSGgf6QDSvX7CP20kCgf7q0IikfhByMo ZWrxj5Zg+P6qoqP5NuoZM4waOarz4wN96OAdB4ao3tbMb0kmzdpvI7W9ZuLaBmEP iTYm5r6if++a4a09V4WfWOyE0+7TYwSWwl271pIeovZy0p77ulgiYFo8/a9XqKlS CrUP1r85zkDHYN/RS4DcbXkqa4RnfYUBd/9h/5zAMLOWwGLRets+/xA4sD2QE9nV xzel3AhVrE3uX0QEPOZnFWTUb5TXkYuhrDxkqRGit61XUeP0Ohy6P1ri8f1dI74J 2huTmg+CZkyfXEff =UuFY -----END PGP SIGNATURE----- Merge tag 'kbuild-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild Pull Kbuild updates from Masahiro Yamada: - Refactor scripts/kallsyms to make it faster and easier to maintain - Clean up menuconfig - Provide Clang with hard-coded target triple instead of CROSS_COMPILE - Use -z pack-relative-relocs flags instead of --use-android-relr-tags for arm64 CONFIG_RELR - Add srcdeb-pkg target to build only a Debian source package - Add KDEB_SOURCE_COMPRESS option to specify the compression for a Debian source package - Misc cleanups and fixes * tag 'kbuild-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kbuild: deb-pkg: specify targets in debian/rules as .PHONY sparc: unify sparc32/sparc64 archhelp kbuild: rpm-pkg: remove kernel-drm PROVIDES kbuild: deb-pkg: add KDEB_SOURCE_COMPRESS to specify source compression kbuild: add srcdeb-pkg target Makefile: use -z pack-relative-relocs kbuild: clang: do not use CROSS_COMPILE for target triple kconfig: menuconfig: reorder functions to remove forward declarations kconfig: menuconfig: remove unused M_EVENT macro kconfig: menuconfig: remove OLD_NCURSES macro kbuild: builddeb: Eliminate debian/arch use scripts/kallsyms: update the usage in the comment block scripts/kallsyms: decrease expand_symbol() / cleanup_symbol_name() calls scripts/kallsyms: change the output order scripts/kallsyms: move compiler-generated symbol patterns to mksysmap scripts/kallsyms: exclude symbols generated by itself dynamically scripts/mksysmap: use sed with in-line comments scripts/mksysmap: remove comments described in nm(1) scripts/kallsyms: remove redundant code for omitting U and N kallsyms: expand symbol name into comment for debugging
272 lines
9.7 KiB
Makefile
272 lines
9.7 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
# Makefile for the different targets used to generate full packages of a kernel
|
|
|
|
include $(srctree)/scripts/Kbuild.include
|
|
include $(srctree)/scripts/Makefile.lib
|
|
|
|
KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
|
|
# Include only those top-level files that are needed by make, plus the GPL copy
|
|
TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \
|
|
include init io_uring ipc kernel lib mm net rust \
|
|
samples scripts security sound tools usr virt \
|
|
.config Makefile \
|
|
Kbuild Kconfig COPYING $(wildcard localversion*)
|
|
MKSPEC := $(srctree)/scripts/package/mkspec
|
|
|
|
quiet_cmd_src_tar = TAR $(2).tar.gz
|
|
cmd_src_tar = \
|
|
if test "$(objtree)" != "$(srctree)"; then \
|
|
echo >&2; \
|
|
echo >&2 " ERROR:"; \
|
|
echo >&2 " Building source tarball is not possible outside the"; \
|
|
echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT"; \
|
|
echo >&2; \
|
|
false; \
|
|
fi ; \
|
|
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
|
|
--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3)
|
|
|
|
# Git
|
|
# ---------------------------------------------------------------------------
|
|
|
|
filechk_HEAD = git -C $(srctree) rev-parse --verify HEAD 2>/dev/null
|
|
|
|
.tmp_HEAD: check-git FORCE
|
|
$(call filechk,HEAD)
|
|
|
|
PHONY += check-git
|
|
check-git:
|
|
@if ! $(srctree)/scripts/check-git; then \
|
|
echo >&2 "error: creating source package requires git repository"; \
|
|
false; \
|
|
fi
|
|
|
|
git-config-tar.gz = -c tar.tar.gz.command="$(KGZIP)"
|
|
git-config-tar.bz2 = -c tar.tar.bz2.command="$(KBZIP2)"
|
|
git-config-tar.lzma = -c tar.tar.lzma.command="$(LZMA)"
|
|
git-config-tar.xz = -c tar.tar.xz.command="$(XZ)"
|
|
git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
|
|
|
|
quiet_cmd_archive = ARCHIVE $@
|
|
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
|
|
--output=$$(realpath $@) $(archive-args)
|
|
|
|
suffix-gzip := .gz
|
|
suffix-bzip2 := .bz2
|
|
suffix-lzma := .lzma
|
|
suffix-xz := .xz
|
|
|
|
# Linux source tarball
|
|
# ---------------------------------------------------------------------------
|
|
|
|
linux-tarballs := $(addprefix linux, .tar.gz .tar.bz2 .tar.lzma .tar.xz)
|
|
|
|
targets += $(linux-tarballs)
|
|
$(linux-tarballs): archive-args = --prefix=linux/ $$(cat $<)
|
|
$(linux-tarballs): .tmp_HEAD FORCE
|
|
$(call if_changed,archive)
|
|
|
|
# rpm-pkg
|
|
# ---------------------------------------------------------------------------
|
|
PHONY += rpm-pkg
|
|
rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec)
|
|
rpm-pkg: srcrpm-pkg
|
|
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \
|
|
--define='_smp_mflags %{nil}'
|
|
|
|
# srcrpm-pkg
|
|
# ---------------------------------------------------------------------------
|
|
PHONY += srcrpm-pkg
|
|
srcrpm-pkg: linux.tar.gz
|
|
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
|
|
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -bs kernel.spec \
|
|
--define='_smp_mflags %{nil}' --define='_sourcedir rpmbuild/SOURCES' --define='_srcrpmdir .'
|
|
|
|
# binrpm-pkg
|
|
# ---------------------------------------------------------------------------
|
|
PHONY += binrpm-pkg
|
|
binrpm-pkg:
|
|
$(MAKE) -f $(srctree)/Makefile
|
|
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
|
|
+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
|
|
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
|
|
|
|
# deb-pkg srcdeb-pkg bindeb-pkg
|
|
# ---------------------------------------------------------------------------
|
|
|
|
KDEB_SOURCE_COMPRESS ?= gzip
|
|
|
|
supported-deb-source-compress := gzip bzip2 lzma xz
|
|
|
|
PHONY += linux.tar.unsupported-deb-src-compress
|
|
linux.tar.unsupported-deb-src-compress:
|
|
@echo "error: KDEB_SOURCE_COMPRESS=$(KDEB_SOURCE_COMPRESS) is not supported. The supported values are: $(supported-deb-source-compress)" >&2
|
|
@false
|
|
|
|
debian-orig-suffix := \
|
|
$(strip $(if $(filter $(supported-deb-source-compress), $(KDEB_SOURCE_COMPRESS)), \
|
|
$(suffix-$(KDEB_SOURCE_COMPRESS)),.unsupported-deb-src-compress))
|
|
|
|
quiet_cmd_debianize = GEN $@
|
|
cmd_debianize = $(srctree)/scripts/package/mkdebian $(mkdebian-opts)
|
|
|
|
debian: FORCE
|
|
$(call cmd,debianize)
|
|
|
|
PHONY += debian-orig
|
|
debian-orig: private source = $(shell dpkg-parsechangelog -S Source)
|
|
debian-orig: private version = $(shell dpkg-parsechangelog -S Version | sed 's/-[^-]*$$//')
|
|
debian-orig: private orig-name = $(source)_$(version).orig.tar$(debian-orig-suffix)
|
|
debian-orig: mkdebian-opts = --need-source
|
|
debian-orig: linux.tar$(debian-orig-suffix) debian
|
|
$(Q)if [ "$(df --output=target .. 2>/dev/null)" = "$(df --output=target $< 2>/dev/null)" ]; then \
|
|
ln -f $< ../$(orig-name); \
|
|
else \
|
|
cp $< ../$(orig-name); \
|
|
fi
|
|
|
|
KBUILD_PKG_ROOTCMD ?= 'fakeroot -u'
|
|
|
|
PHONY += deb-pkg srcdeb-pkg bindeb-pkg
|
|
|
|
deb-pkg: private build-type := source,binary
|
|
srcdeb-pkg: private build-type := source
|
|
bindeb-pkg: private build-type := binary
|
|
|
|
deb-pkg srcdeb-pkg: debian-orig
|
|
bindeb-pkg: debian
|
|
deb-pkg srcdeb-pkg bindeb-pkg:
|
|
+$(strip dpkg-buildpackage \
|
|
--build=$(build-type) --no-pre-clean --unsigned-changes \
|
|
$(if $(findstring source, $(build-type)), \
|
|
--unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \
|
|
$(if $(findstring binary, $(build-type)), \
|
|
-r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \
|
|
--no-check-builddeps) \
|
|
$(DPKG_FLAGS))
|
|
|
|
PHONY += intdeb-pkg
|
|
intdeb-pkg:
|
|
+$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
|
|
|
|
# snap-pkg
|
|
# ---------------------------------------------------------------------------
|
|
PHONY += snap-pkg
|
|
snap-pkg:
|
|
rm -rf $(objtree)/snap
|
|
mkdir $(objtree)/snap
|
|
$(MAKE) clean
|
|
$(call cmd,src_tar,$(KERNELPATH))
|
|
sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
|
|
s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
|
|
$(srctree)/scripts/package/snapcraft.template > \
|
|
$(objtree)/snap/snapcraft.yaml
|
|
cd $(objtree)/snap && \
|
|
snapcraft --target-arch=$(UTS_MACHINE)
|
|
|
|
# dir-pkg tar*-pkg - tarball targets
|
|
# ---------------------------------------------------------------------------
|
|
|
|
tar-install: FORCE
|
|
$(Q)$(MAKE) -f $(srctree)/Makefile
|
|
+$(Q)$(srctree)/scripts/package/buildtar $@
|
|
|
|
compress-tar.gz = -I "$(KGZIP)"
|
|
compress-tar.bz2 = -I "$(KBZIP2)"
|
|
compress-tar.xz = -I "$(XZ)"
|
|
compress-tar.zst = -I "$(ZSTD)"
|
|
|
|
quiet_cmd_tar = TAR $@
|
|
cmd_tar = cd $<; tar cf ../$@ $(compress-tar$(suffix $@)) --owner=root --group=root --sort=name *
|
|
|
|
dir-tarballs := $(addprefix linux-$(KERNELRELEASE)-$(ARCH), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
|
|
|
|
$(dir-tarballs): tar-install
|
|
$(call cmd,tar)
|
|
|
|
PHONY += dir-pkg
|
|
dir-pkg: tar-install
|
|
@echo "Kernel tree successfully created in $<"
|
|
|
|
PHONY += tar-pkg
|
|
tar-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar
|
|
@:
|
|
|
|
tar%-pkg: linux-$(KERNELRELEASE)-$(ARCH).tar.% FORCE
|
|
@:
|
|
|
|
# perf-tar*-src-pkg - generate a source tarball with perf source
|
|
# ---------------------------------------------------------------------------
|
|
|
|
.tmp_perf:
|
|
$(Q)mkdir .tmp_perf
|
|
|
|
.tmp_perf/HEAD: .tmp_HEAD | .tmp_perf
|
|
$(call cmd,copy)
|
|
|
|
quiet_cmd_perf_version_file = GEN $@
|
|
cmd_perf_version_file = cd $(srctree)/tools/perf; util/PERF-VERSION-GEN $(dir $(abspath $@))
|
|
|
|
# PERF-VERSION-FILE and .tmp_HEAD are independent, but this avoids updating the
|
|
# timestamp of PERF-VERSION-FILE.
|
|
# The best is to fix tools/perf/util/PERF-VERSION-GEN.
|
|
.tmp_perf/PERF-VERSION-FILE: .tmp_HEAD $(srctree)/tools/perf/util/PERF-VERSION-GEN | .tmp_perf
|
|
$(call cmd,perf_version_file)
|
|
|
|
perf-archive-args = --add-file=$$(realpath $(word 2, $^)) \
|
|
--add-file=$$(realpath $(word 3, $^)) \
|
|
$$(cat $(word 2, $^))^{tree} $$(cat $<)
|
|
|
|
|
|
perf-tarballs := $(addprefix perf-$(KERNELVERSION), .tar .tar.gz .tar.bz2 .tar.xz .tar.zst)
|
|
|
|
targets += $(perf-tarballs)
|
|
$(perf-tarballs): archive-args = --prefix=perf-$(KERNELVERSION)/ $(perf-archive-args)
|
|
$(perf-tarballs): tools/perf/MANIFEST .tmp_perf/HEAD .tmp_perf/PERF-VERSION-FILE FORCE
|
|
$(call if_changed,archive)
|
|
|
|
PHONY += perf-tar-src-pkg
|
|
perf-tar-src-pkg: perf-$(KERNELVERSION).tar
|
|
@:
|
|
|
|
perf-tar%-src-pkg: perf-$(KERNELVERSION).tar.% FORCE
|
|
@:
|
|
|
|
# Help text displayed when executing 'make help'
|
|
# ---------------------------------------------------------------------------
|
|
PHONY += help
|
|
help:
|
|
@echo ' rpm-pkg - Build both source and binary RPM kernel packages'
|
|
@echo ' srcrpm-pkg - Build only the source kernel RPM package'
|
|
@echo ' binrpm-pkg - Build only the binary kernel RPM package'
|
|
@echo ' deb-pkg - Build both source and binary deb kernel packages'
|
|
@echo ' srcdeb-pkg - Build only the source kernel deb package'
|
|
@echo ' bindeb-pkg - Build only the binary kernel deb package'
|
|
@echo ' snap-pkg - Build only the binary kernel snap package'
|
|
@echo ' (will connect to external hosts)'
|
|
@echo ' dir-pkg - Build the kernel as a plain directory structure'
|
|
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
|
|
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
|
|
@echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
|
|
@echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
|
|
@echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
|
|
@echo ' perf-tar-src-pkg - Build the perf source tarball with no compression'
|
|
@echo ' perf-targz-src-pkg - Build the perf source tarball with gzip compression'
|
|
@echo ' perf-tarbz2-src-pkg - Build the perf source tarball with bz2 compression'
|
|
@echo ' perf-tarxz-src-pkg - Build the perf source tarball with xz compression'
|
|
@echo ' perf-tarzst-src-pkg - Build the perf source tarball with zst compression'
|
|
|
|
PHONY += FORCE
|
|
FORCE:
|
|
|
|
# Read all saved command lines and dependencies for the $(targets) we
|
|
# may be building above, using $(if_changed{,_dep}). As an
|
|
# optimization, we don't need to read them if the target does not
|
|
# exist, we will rebuild anyway in that case.
|
|
|
|
existing-targets := $(wildcard $(sort $(targets)))
|
|
|
|
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
|
|
|
.PHONY: $(PHONY)
|