Files

169 lines
7.1 KiB
Makefile
Raw Permalink Normal View History

# SPDX-License-Identifier: GPL-2.0-only
2005-04-16 15:20:36 -07:00
# Makefile for the different targets used to generate full packages of a kernel
include $(srctree)/scripts/Kbuild.include
2005-04-16 15:20:36 -07:00
# RPM target
# ---------------------------------------------------------------------------
# The rpm target generates two rpm files:
# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
# The src.rpm files includes all source for the kernel being built
# The <arch>.rpm includes kernel configuration, modules etc.
#
# Process to create the rpm files
# a) clean the kernel
# b) Generate .spec file
# c) Build a tar ball, using symlink to make kernel version
# first entry in the path
# d) and pack the result to a tar.gz file
# e) generate the rpm files, based on kernel.spec
# - Use /. to avoid tar packing just the symlink
# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
# but the binrpm-pkg target can; for some reason O= gets ignored.
2005-04-16 15:20:36 -07:00
# Remove hyphens since they have special meaning in RPM filenames
2011-05-04 13:48:11 -07:00
KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
KDEB_SOURCENAME ?= linux-upstream
KBUILD_PKG_ROOTCMD ?="fakeroot -u"
2015-09-02 12:57:24 +03:00
export KDEB_SOURCENAME
# 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 samples scripts \
security sound tools usr virt \
.config .scmversion Makefile \
Kbuild Kconfig COPYING $(wildcard localversion*)
2005-04-16 15:20:36 -07:00
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, or use the"; \
echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \
echo >&2; \
false; \
fi ; \
$(srctree)/scripts/setlocalversion --save-scmversion; \
tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
rm -f $(objtree)/.scmversion
2005-04-16 15:20:36 -07:00
# rpm-pkg
2006-03-08 18:39:05 +01:00
# ---------------------------------------------------------------------------
PHONY += rpm-pkg
rpm-pkg:
2005-04-16 15:20:36 -07:00
$(MAKE) clean
2013-04-13 21:21:15 +02:00
$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \
--define='_smp_mflags %{nil}'
2005-04-16 15:20:36 -07:00
# binrpm-pkg
2006-03-08 18:39:05 +01:00
# ---------------------------------------------------------------------------
PHONY += binrpm-pkg
binrpm-pkg:
$(MAKE) -f $(srctree)/Makefile
2013-04-13 21:21:15 +02:00
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
PHONY += deb-pkg
deb-pkg:
2015-09-02 12:57:24 +03:00
$(MAKE) clean
$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
2015-09-02 12:57:24 +03:00
$(call cmd,src_tar,$(KDEB_SOURCENAME))
origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
2015-09-02 12:57:24 +03:00
PHONY += bindeb-pkg
bindeb-pkg:
$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
PHONY += intdeb-pkg
intdeb-pkg:
+$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
2005-04-16 15:20:36 -07:00
2017-11-27 12:07:34 +01:00
# snap-pkg
# ---------------------------------------------------------------------------
PHONY += snap-pkg
snap-pkg:
2017-11-27 12:07:34 +01:00
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)
2005-05-24 11:27:37 +02:00
# tarball targets
# ---------------------------------------------------------------------------
2021-10-08 13:37:59 +02:00
tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg tarzst-pkg
PHONY += $(tar-pkgs)
$(tar-pkgs):
$(MAKE) -f $(srctree)/Makefile
+$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
2005-05-24 11:27:37 +02:00
# perf-pkg - generate a source tarball with perf source
# ---------------------------------------------------------------------------
perf-tar=perf-$(KERNELVERSION)
quiet_cmd_perf_tar = TAR
cmd_perf_tar = \
2011-05-13 16:41:12 -07:00
git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
HEAD^{tree} $$(cd $(srctree); \
echo $$(cat tools/perf/MANIFEST)) \
2011-05-13 16:41:12 -07:00
-o $(perf-tar).tar; \
mkdir -p $(perf-tar); \
2011-05-13 16:41:12 -07:00
git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
(cd $(srctree)/tools/perf; \
util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
rm -r $(perf-tar); \
$(if $(findstring tar-src,$@),, \
$(if $(findstring bz2,$@),$(KBZIP2), \
$(if $(findstring gz,$@),$(KGZIP), \
2020-06-05 10:39:55 +03:00
$(if $(findstring xz,$@),$(XZ), \
2021-10-08 13:37:59 +02:00
$(if $(findstring zst,$@),$(ZSTD), \
$(error unknown target $@))))) \
-f -9 $(perf-tar).tar)
2021-10-08 13:37:59 +02:00
perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \
perf-tarxz-src-pkg perf-tarzst-src-pkg
PHONY += $(perf-tar-pkgs)
$(perf-tar-pkgs):
$(call cmd,perf_tar)
2005-04-16 15:20:36 -07:00
# Help text displayed when executing 'make help'
# ---------------------------------------------------------------------------
PHONY += help
help:
@echo ' rpm-pkg - Build both source and binary RPM kernel packages'
2015-09-02 12:57:24 +03:00
@echo ' binrpm-pkg - Build only the binary kernel RPM package'
@echo ' deb-pkg - Build both source and binary deb kernel packages'
@echo ' bindeb-pkg - Build only the binary kernel deb package'
2019-10-25 13:52:32 +02:00
@echo ' snap-pkg - Build only the binary kernel snap package'
@echo ' (will connect to external hosts)'
2019-11-04 14:11:44 +01:00
@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'
2011-01-30 12:18:51 +01:00
@echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
2021-10-08 13:37:59 +02:00
@echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
@echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
@echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
@echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
2011-01-30 12:18:51 +01:00
@echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
2021-10-08 13:37:59 +02:00
@echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball'
.PHONY: $(PHONY)