0001
0002
0003
0004 include $(srctree)/scripts/Kbuild.include
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
0028 KDEB_SOURCENAME ?= linux-upstream
0029 KBUILD_PKG_ROOTCMD ?="fakeroot -u"
0030 export KDEB_SOURCENAME
0031
0032 TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
0033 Kbuild Kconfig COPYING $(wildcard localversion*)
0034 MKSPEC := $(srctree)/scripts/package/mkspec
0035
0036 quiet_cmd_src_tar = TAR $(2).tar.gz
0037 cmd_src_tar = \
0038 if test "$(objtree)" != "$(srctree)"; then \
0039 echo >&2; \
0040 echo >&2 " ERROR:"; \
0041 echo >&2 " Building source tarball is not possible outside the"; \
0042 echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
0043 echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \
0044 echo >&2; \
0045 false; \
0046 fi ; \
0047 $(srctree)/scripts/setlocalversion --save-scmversion; \
0048 tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
0049 --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
0050 rm -f $(objtree)/.scmversion
0051
0052
0053
0054 PHONY += rpm-pkg
0055 rpm-pkg:
0056 $(MAKE) clean
0057 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
0058 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
0059 +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ta $(KERNELPATH).tar.gz \
0060 --define='_smp_mflags %{nil}'
0061
0062
0063
0064 PHONY += binrpm-pkg
0065 binrpm-pkg:
0066 $(MAKE) -f $(srctree)/Makefile
0067 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
0068 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
0069 $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
0070
0071 PHONY += deb-pkg
0072 deb-pkg:
0073 $(MAKE) clean
0074 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
0075 $(call cmd,src_tar,$(KDEB_SOURCENAME))
0076 origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
0077 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
0078 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
0079
0080 PHONY += bindeb-pkg
0081 bindeb-pkg:
0082 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
0083 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
0084
0085 PHONY += intdeb-pkg
0086 intdeb-pkg:
0087 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
0088
0089
0090
0091 PHONY += snap-pkg
0092 snap-pkg:
0093 rm -rf $(objtree)/snap
0094 mkdir $(objtree)/snap
0095 $(MAKE) clean
0096 $(call cmd,src_tar,$(KERNELPATH))
0097 sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
0098 s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
0099 $(srctree)/scripts/package/snapcraft.template > \
0100 $(objtree)/snap/snapcraft.yaml
0101 cd $(objtree)/snap && \
0102 snapcraft --target-arch=$(UTS_MACHINE)
0103
0104
0105
0106 tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg tarzst-pkg
0107 PHONY += $(tar-pkgs)
0108 $(tar-pkgs):
0109 $(MAKE) -f $(srctree)/Makefile
0110 +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
0111
0112
0113
0114
0115 perf-tar=perf-$(KERNELVERSION)
0116
0117 quiet_cmd_perf_tar = TAR
0118 cmd_perf_tar = \
0119 git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
0120 HEAD^{tree} $$(cd $(srctree); \
0121 echo $$(cat tools/perf/MANIFEST)) \
0122 -o $(perf-tar).tar; \
0123 mkdir -p $(perf-tar); \
0124 git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
0125 (cd $(srctree)/tools/perf; \
0126 util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
0127 tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
0128 rm -r $(perf-tar); \
0129 $(if $(findstring tar-src,$@),, \
0130 $(if $(findstring bz2,$@),$(KBZIP2), \
0131 $(if $(findstring gz,$@),$(KGZIP), \
0132 $(if $(findstring xz,$@),$(XZ), \
0133 $(if $(findstring zst,$@),$(ZSTD), \
0134 $(error unknown target $@))))) \
0135 -f -9 $(perf-tar).tar)
0136
0137 perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \
0138 perf-tarxz-src-pkg perf-tarzst-src-pkg
0139 PHONY += $(perf-tar-pkgs)
0140 $(perf-tar-pkgs):
0141 $(call cmd,perf_tar)
0142
0143
0144
0145 PHONY += help
0146 help:
0147 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
0148 @echo ' binrpm-pkg - Build only the binary kernel RPM package'
0149 @echo ' deb-pkg - Build both source and binary deb kernel packages'
0150 @echo ' bindeb-pkg - Build only the binary kernel deb package'
0151 @echo ' snap-pkg - Build only the binary kernel snap package'
0152 @echo ' (will connect to external hosts)'
0153 @echo ' dir-pkg - Build the kernel as a plain directory structure'
0154 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
0155 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
0156 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
0157 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
0158 @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball'
0159 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
0160 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
0161 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
0162 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'
0163 @echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball'
0164
0165 .PHONY: $(PHONY)