Thomas Gleixner | ec8f24b | 2019-05-19 13:07:45 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | # Makefile for the different targets used to generate full packages of a kernel |
Masahiro Yamada | 000ec95 | 2019-08-21 16:02:04 +0900 | [diff] [blame] | 3 | |
| 4 | include $(srctree)/scripts/Kbuild.include |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | # RPM target |
| 7 | # --------------------------------------------------------------------------- |
| 8 | # The rpm target generates two rpm files: |
| 9 | # /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm |
| 10 | # /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm |
| 11 | # The src.rpm files includes all source for the kernel being built |
| 12 | # The <arch>.rpm includes kernel configuration, modules etc. |
| 13 | # |
| 14 | # Process to create the rpm files |
| 15 | # a) clean the kernel |
| 16 | # b) Generate .spec file |
| 17 | # c) Build a tar ball, using symlink to make kernel version |
| 18 | # first entry in the path |
| 19 | # d) and pack the result to a tar.gz file |
| 20 | # e) generate the rpm files, based on kernel.spec |
| 21 | # - Use /. to avoid tar packing just the symlink |
| 22 | |
Frans Pop | db9038c | 2009-08-25 22:15:39 +0200 | [diff] [blame] | 23 | # Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT, |
| 24 | # but the binrpm-pkg target can; for some reason O= gets ignored. |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | # Remove hyphens since they have special meaning in RPM filenames |
Arun Sharma | e1287eb | 2011-05-04 13:48:11 -0700 | [diff] [blame] | 27 | KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) |
Masahiro Yamada | 82526ef | 2021-04-20 02:05:05 +0900 | [diff] [blame] | 28 | KDEB_SOURCENAME ?= linux-upstream |
Riku Voipio | b41d920 | 2018-04-05 14:22:29 +0300 | [diff] [blame] | 29 | KBUILD_PKG_ROOTCMD ?="fakeroot -u" |
Riku Voipio | 3716001 | 2015-09-02 12:57:24 +0300 | [diff] [blame] | 30 | export KDEB_SOURCENAME |
Michal Marek | 6615d6c | 2013-04-12 14:12:50 +0200 | [diff] [blame] | 31 | # Include only those top-level files that are needed by make, plus the GPL copy |
Riku Voipio | 2680382 | 2015-09-02 12:57:08 +0300 | [diff] [blame] | 32 | TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \ |
Michal Marek | 6615d6c | 2013-04-12 14:12:50 +0200 | [diff] [blame] | 33 | Kbuild Kconfig COPYING $(wildcard localversion*) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | MKSPEC := $(srctree)/scripts/package/mkspec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Riku Voipio | 2680382 | 2015-09-02 12:57:08 +0300 | [diff] [blame] | 36 | quiet_cmd_src_tar = TAR $(2).tar.gz |
| 37 | cmd_src_tar = \ |
| 38 | if test "$(objtree)" != "$(srctree)"; then \ |
Masahiro Yamada | 262dad6 | 2017-12-06 19:32:57 +0900 | [diff] [blame] | 39 | echo >&2; \ |
| 40 | echo >&2 " ERROR:"; \ |
| 41 | echo >&2 " Building source tarball is not possible outside the"; \ |
| 42 | echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ |
| 43 | echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \ |
| 44 | echo >&2; \ |
Riku Voipio | 2680382 | 2015-09-02 12:57:08 +0300 | [diff] [blame] | 45 | false; \ |
| 46 | fi ; \ |
| 47 | $(srctree)/scripts/setlocalversion --save-scmversion; \ |
Denis Efremov | e4a42c8 | 2020-06-08 12:59:44 +0300 | [diff] [blame] | 48 | tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ |
Masahiro Yamada | 2dbc644 | 2017-11-15 18:17:07 +0900 | [diff] [blame] | 49 | --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \ |
| 50 | rm -f $(objtree)/.scmversion |
Riku Voipio | 2680382 | 2015-09-02 12:57:08 +0300 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | # rpm-pkg |
Sam Ravnborg | 0131705 | 2006-03-08 18:39:05 +0100 | [diff] [blame] | 53 | # --------------------------------------------------------------------------- |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 54 | PHONY += rpm-pkg |
| 55 | rpm-pkg: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | $(MAKE) clean |
Michal Marek | 6501320 | 2013-04-13 21:21:15 +0200 | [diff] [blame] | 57 | $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec |
Riku Voipio | 2680382 | 2015-09-02 12:57:08 +0300 | [diff] [blame] | 58 | $(call cmd,src_tar,$(KERNELPATH),kernel.spec) |
Masahiro Yamada | 8a16a07 | 2017-09-30 10:10:11 +0900 | [diff] [blame] | 59 | +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \ |
| 60 | --define='_smp_mflags %{nil}' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | # binrpm-pkg |
Sam Ravnborg | 0131705 | 2006-03-08 18:39:05 +0100 | [diff] [blame] | 63 | # --------------------------------------------------------------------------- |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 64 | PHONY += binrpm-pkg |
| 65 | binrpm-pkg: |
Masahiro Yamada | 175209c | 2019-02-14 12:05:14 +0900 | [diff] [blame] | 66 | $(MAKE) -f $(srctree)/Makefile |
Michal Marek | 6501320 | 2013-04-13 21:21:15 +0200 | [diff] [blame] | 67 | $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec |
Masahiro Yamada | 606625b | 2017-09-30 10:10:09 +0900 | [diff] [blame] | 68 | +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ |
Luiz Capitulino | f66ba56 | 2013-05-15 12:06:26 -0400 | [diff] [blame] | 69 | $(UTS_MACHINE) -bb $(objtree)/binkernel.spec |
Masahiro Yamada | af60e20 | 2017-09-30 10:10:10 +0900 | [diff] [blame] | 70 | |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 71 | PHONY += deb-pkg |
| 72 | deb-pkg: |
Riku Voipio | 3716001 | 2015-09-02 12:57:24 +0300 | [diff] [blame] | 73 | $(MAKE) clean |
Riku Voipio | b41d920 | 2018-04-05 14:22:29 +0300 | [diff] [blame] | 74 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian |
Riku Voipio | 3716001 | 2015-09-02 12:57:24 +0300 | [diff] [blame] | 75 | $(call cmd,src_tar,$(KDEB_SOURCENAME)) |
Riku Voipio | b41d920 | 2018-04-05 14:22:29 +0300 | [diff] [blame] | 76 | origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ |
| 77 | mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz |
Kacper Kołodziej | 117948a | 2019-02-05 13:37:52 +0100 | [diff] [blame] | 78 | +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc |
Riku Voipio | 3716001 | 2015-09-02 12:57:24 +0300 | [diff] [blame] | 79 | |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 80 | PHONY += bindeb-pkg |
| 81 | bindeb-pkg: |
Riku Voipio | b41d920 | 2018-04-05 14:22:29 +0300 | [diff] [blame] | 82 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian |
Kacper Kołodziej | 117948a | 2019-02-05 13:37:52 +0100 | [diff] [blame] | 83 | +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc |
Riku Voipio | b41d920 | 2018-04-05 14:22:29 +0300 | [diff] [blame] | 84 | |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 85 | PHONY += intdeb-pkg |
| 86 | intdeb-pkg: |
Riku Voipio | b41d920 | 2018-04-05 14:22:29 +0300 | [diff] [blame] | 87 | +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Paolo Pisati | 5704d45 | 2017-11-27 12:07:34 +0100 | [diff] [blame] | 89 | # snap-pkg |
| 90 | # --------------------------------------------------------------------------- |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 91 | PHONY += snap-pkg |
| 92 | snap-pkg: |
Paolo Pisati | 5704d45 | 2017-11-27 12:07:34 +0100 | [diff] [blame] | 93 | rm -rf $(objtree)/snap |
| 94 | mkdir $(objtree)/snap |
| 95 | $(MAKE) clean |
| 96 | $(call cmd,src_tar,$(KERNELPATH)) |
| 97 | sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \ |
| 98 | s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \ |
| 99 | $(srctree)/scripts/package/snapcraft.template > \ |
| 100 | $(objtree)/snap/snapcraft.yaml |
| 101 | cd $(objtree)/snap && \ |
| 102 | snapcraft --target-arch=$(UTS_MACHINE) |
| 103 | |
Jan-Benedict Glaw | 6d983fe | 2005-05-24 11:27:37 +0200 | [diff] [blame] | 104 | # tarball targets |
| 105 | # --------------------------------------------------------------------------- |
Paweł Jasiak | 88f5e1e | 2021-10-08 13:37:59 +0200 | [diff] [blame] | 106 | tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg tarzst-pkg |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 107 | PHONY += $(tar-pkgs) |
| 108 | $(tar-pkgs): |
Masahiro Yamada | 175209c | 2019-02-14 12:05:14 +0900 | [diff] [blame] | 109 | $(MAKE) -f $(srctree)/Makefile |
Trevor Bourget | a6e0487 | 2019-05-27 16:54:23 -0700 | [diff] [blame] | 110 | +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ |
Jan-Benedict Glaw | 6d983fe | 2005-05-24 11:27:37 +0200 | [diff] [blame] | 111 | |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 112 | # perf-pkg - generate a source tarball with perf source |
| 113 | # --------------------------------------------------------------------------- |
| 114 | |
| 115 | perf-tar=perf-$(KERNELVERSION) |
| 116 | |
| 117 | quiet_cmd_perf_tar = TAR |
| 118 | cmd_perf_tar = \ |
matt mooney | 3bdccc8 | 2011-05-13 16:41:12 -0700 | [diff] [blame] | 119 | git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ |
| 120 | HEAD^{tree} $$(cd $(srctree); \ |
Riku Voipio | 4b63f60 | 2015-09-01 17:14:21 +0300 | [diff] [blame] | 121 | echo $$(cat tools/perf/MANIFEST)) \ |
matt mooney | 3bdccc8 | 2011-05-13 16:41:12 -0700 | [diff] [blame] | 122 | -o $(perf-tar).tar; \ |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 123 | mkdir -p $(perf-tar); \ |
matt mooney | 3bdccc8 | 2011-05-13 16:41:12 -0700 | [diff] [blame] | 124 | git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ |
David Ahern | a614d01 | 2013-11-06 08:55:35 -0700 | [diff] [blame] | 125 | (cd $(srctree)/tools/perf; \ |
Riku Voipio | 4b63f60 | 2015-09-01 17:14:21 +0300 | [diff] [blame] | 126 | util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \ |
David Ahern | a614d01 | 2013-11-06 08:55:35 -0700 | [diff] [blame] | 127 | tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 128 | rm -r $(perf-tar); \ |
| 129 | $(if $(findstring tar-src,$@),, \ |
Denis Efremov | e4a42c8 | 2020-06-08 12:59:44 +0300 | [diff] [blame] | 130 | $(if $(findstring bz2,$@),$(KBZIP2), \ |
| 131 | $(if $(findstring gz,$@),$(KGZIP), \ |
Denis Efremov | 8dfb61d | 2020-06-05 10:39:55 +0300 | [diff] [blame] | 132 | $(if $(findstring xz,$@),$(XZ), \ |
Paweł Jasiak | 88f5e1e | 2021-10-08 13:37:59 +0200 | [diff] [blame] | 133 | $(if $(findstring zst,$@),$(ZSTD), \ |
| 134 | $(error unknown target $@))))) \ |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 135 | -f -9 $(perf-tar).tar) |
| 136 | |
Paweł Jasiak | 88f5e1e | 2021-10-08 13:37:59 +0200 | [diff] [blame] | 137 | perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \ |
| 138 | perf-tarxz-src-pkg perf-tarzst-src-pkg |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 139 | PHONY += $(perf-tar-pkgs) |
| 140 | $(perf-tar-pkgs): |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 141 | $(call cmd,perf_tar) |
| 142 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | # Help text displayed when executing 'make help' |
| 144 | # --------------------------------------------------------------------------- |
Masahiro Yamada | 6a4f6a2 | 2019-08-21 16:02:03 +0900 | [diff] [blame] | 145 | PHONY += help |
| 146 | help: |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 147 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' |
Riku Voipio | 3716001 | 2015-09-02 12:57:24 +0300 | [diff] [blame] | 148 | @echo ' binrpm-pkg - Build only the binary kernel RPM package' |
| 149 | @echo ' deb-pkg - Build both source and binary deb kernel packages' |
| 150 | @echo ' bindeb-pkg - Build only the binary kernel deb package' |
Geert Uytterhoeven | a64c044 | 2019-10-25 13:52:32 +0200 | [diff] [blame] | 151 | @echo ' snap-pkg - Build only the binary kernel snap package' |
| 152 | @echo ' (will connect to external hosts)' |
Matteo Croce | af7db99 | 2019-11-04 14:11:44 +0100 | [diff] [blame] | 153 | @echo ' dir-pkg - Build the kernel as a plain directory structure' |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 154 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
| 155 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' |
| 156 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' |
Zdenek Kaspar | 9a17f40 | 2011-01-30 12:18:51 +0100 | [diff] [blame] | 157 | @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball' |
Paweł Jasiak | 88f5e1e | 2021-10-08 13:37:59 +0200 | [diff] [blame] | 158 | @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball' |
Arnaldo Carvalho de Melo | 8e5564e | 2010-05-31 11:13:21 -0300 | [diff] [blame] | 159 | @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball' |
| 160 | @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' |
| 161 | @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' |
Zdenek Kaspar | 9a17f40 | 2011-01-30 12:18:51 +0100 | [diff] [blame] | 162 | @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball' |
Paweł Jasiak | 88f5e1e | 2021-10-08 13:37:59 +0200 | [diff] [blame] | 163 | @echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball' |
Masahiro Yamada | 000ec95 | 2019-08-21 16:02:04 +0900 | [diff] [blame] | 164 | |
| 165 | .PHONY: $(PHONY) |