Commit | Line | Data |
---|---|---|
ec8f24b7 | 1 | # SPDX-License-Identifier: GPL-2.0-only |
1da177e4 | 2 | # Makefile for the different targets used to generate full packages of a kernel |
000ec95f MY |
3 | |
4 | include $(srctree)/scripts/Kbuild.include | |
1da177e4 | 5 | |
1da177e4 LT |
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 | ||
db9038c8 FP |
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 | ||
1da177e4 | 26 | # Remove hyphens since they have special meaning in RPM filenames |
e1287eb8 | 27 | KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) |
82526ef4 | 28 | KDEB_SOURCENAME ?= linux-upstream |
b41d920a | 29 | KBUILD_PKG_ROOTCMD ?="fakeroot -u" |
3716001b | 30 | export KDEB_SOURCENAME |
6615d6c3 | 31 | # Include only those top-level files that are needed by make, plus the GPL copy |
a3c4d4ab | 32 | TAR_CONTENT := Documentation LICENSES arch block certs crypto drivers fs \ |
df1f1ea9 PL |
33 | include init io_uring ipc kernel lib mm net rust \ |
34 | samples scripts security sound tools usr virt \ | |
f6e09b07 | 35 | .config Makefile \ |
6615d6c3 | 36 | Kbuild Kconfig COPYING $(wildcard localversion*) |
1da177e4 | 37 | MKSPEC := $(srctree)/scripts/package/mkspec |
1da177e4 | 38 | |
26803821 RV |
39 | quiet_cmd_src_tar = TAR $(2).tar.gz |
40 | cmd_src_tar = \ | |
41 | if test "$(objtree)" != "$(srctree)"; then \ | |
262dad68 MY |
42 | echo >&2; \ |
43 | echo >&2 " ERROR:"; \ | |
44 | echo >&2 " Building source tarball is not possible outside the"; \ | |
45 | echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ | |
7bf4582d | 46 | echo >&2 " binrpm-pkg target instead."; \ |
262dad68 | 47 | echo >&2; \ |
26803821 RV |
48 | false; \ |
49 | fi ; \ | |
e4a42c82 | 50 | tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ |
f6e09b07 | 51 | --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3) |
26803821 | 52 | |
7bf4582d MY |
53 | # .tmp_filelist .tmp_filelist_exclude |
54 | # --------------------------------------------------------------------------- | |
55 | ||
56 | scripts/list-gitignored: FORCE | |
57 | $(Q)$(MAKE) -f $(srctree)/Makefile scripts_package | |
58 | ||
59 | # 1f5d3a6b6532e25a5cdf1f311956b2b03d343a48 removed '*.rej' from .gitignore, | |
60 | # but it is definitely a generated file. | |
61 | filechk_filelist = \ | |
62 | $< --exclude='*.rej' --output=$@_exclude --prefix=./ --rootdir=$(srctree) --stat=- | |
63 | ||
64 | .tmp_filelist: scripts/list-gitignored FORCE | |
65 | $(call filechk,filelist) | |
66 | ||
67 | # tarball | |
68 | # --------------------------------------------------------------------------- | |
69 | ||
70 | quiet_cmd_tar = TAR $@ | |
71 | cmd_tar = tar -c -f $@ $(tar-compress-opt) $(tar-exclude-opt) \ | |
72 | --owner=0 --group=0 --sort=name \ | |
73 | --transform 's:^\.:$*:S' -C $(tar-rootdir) . | |
74 | ||
75 | tar-rootdir := $(srctree) | |
76 | ||
77 | %.tar.gz: private tar-compress-opt := -I $(KGZIP) | |
78 | %.tar.gz: | |
79 | $(call cmd,tar) | |
80 | ||
81 | # Linux source tarball | |
82 | # --------------------------------------------------------------------------- | |
83 | ||
84 | linux.tar.gz: tar-exclude-opt = --exclude=./$@ --exclude-from=$<_exclude | |
85 | linux.tar.gz: .tmp_filelist | |
86 | ||
1da177e4 | 87 | # rpm-pkg |
0131705d | 88 | # --------------------------------------------------------------------------- |
6a4f6a26 | 89 | PHONY += rpm-pkg |
1ec9bb70 MY |
90 | rpm-pkg: srpm = $(shell rpmspec --srpm --query --queryformat='%{name}-%{VERSION}-%{RELEASE}.src.rpm' kernel.spec) |
91 | rpm-pkg: srcrpm-pkg | |
92 | +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -rb $(srpm) \ | |
8a16a070 | 93 | --define='_smp_mflags %{nil}' |
1da177e4 | 94 | |
8818039f IV |
95 | # srcrpm-pkg |
96 | # --------------------------------------------------------------------------- | |
97 | PHONY += srcrpm-pkg | |
98 | srcrpm-pkg: | |
99 | $(MAKE) clean | |
100 | $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec | |
101 | $(call cmd,src_tar,$(KERNELPATH),kernel.spec) | |
102 | +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE)-linux -ts $(KERNELPATH).tar.gz \ | |
103 | --define='_smp_mflags %{nil}' --define='_srcrpmdir $(srctree)' | |
104 | ||
1da177e4 | 105 | # binrpm-pkg |
0131705d | 106 | # --------------------------------------------------------------------------- |
6a4f6a26 MY |
107 | PHONY += binrpm-pkg |
108 | binrpm-pkg: | |
175209cc | 109 | $(MAKE) -f $(srctree)/Makefile |
65013203 | 110 | $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec |
606625be | 111 | +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ |
6105e4f6 | 112 | $(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec |
af60e207 | 113 | |
6a4f6a26 | 114 | PHONY += deb-pkg |
7bf4582d | 115 | deb-pkg: linux.tar.gz |
b41d920a | 116 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian |
b41d920a | 117 | origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ |
7bf4582d MY |
118 | cp linux.tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz |
119 | +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) \ | |
120 | --build=source,binary --source-option=-sP -nc -us -uc | |
3716001b | 121 | |
6a4f6a26 MY |
122 | PHONY += bindeb-pkg |
123 | bindeb-pkg: | |
b41d920a | 124 | $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian |
117948ac | 125 | +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc |
b41d920a | 126 | |
6a4f6a26 MY |
127 | PHONY += intdeb-pkg |
128 | intdeb-pkg: | |
b41d920a | 129 | +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb |
1da177e4 | 130 | |
5704d455 PP |
131 | # snap-pkg |
132 | # --------------------------------------------------------------------------- | |
6a4f6a26 MY |
133 | PHONY += snap-pkg |
134 | snap-pkg: | |
5704d455 PP |
135 | rm -rf $(objtree)/snap |
136 | mkdir $(objtree)/snap | |
137 | $(MAKE) clean | |
138 | $(call cmd,src_tar,$(KERNELPATH)) | |
139 | sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \ | |
140 | s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \ | |
141 | $(srctree)/scripts/package/snapcraft.template > \ | |
142 | $(objtree)/snap/snapcraft.yaml | |
143 | cd $(objtree)/snap && \ | |
144 | snapcraft --target-arch=$(UTS_MACHINE) | |
145 | ||
6d983fea JBG |
146 | # tarball targets |
147 | # --------------------------------------------------------------------------- | |
88f5e1e6 | 148 | tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg tarzst-pkg |
6a4f6a26 MY |
149 | PHONY += $(tar-pkgs) |
150 | $(tar-pkgs): | |
175209cc | 151 | $(MAKE) -f $(srctree)/Makefile |
a6e04877 | 152 | +$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ |
6d983fea | 153 | |
8e5564e6 ACM |
154 | # perf-pkg - generate a source tarball with perf source |
155 | # --------------------------------------------------------------------------- | |
156 | ||
157 | perf-tar=perf-$(KERNELVERSION) | |
158 | ||
159 | quiet_cmd_perf_tar = TAR | |
160 | cmd_perf_tar = \ | |
3bdccc88 | 161 | git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ |
162 | HEAD^{tree} $$(cd $(srctree); \ | |
4b63f603 | 163 | echo $$(cat tools/perf/MANIFEST)) \ |
3bdccc88 | 164 | -o $(perf-tar).tar; \ |
8e5564e6 | 165 | mkdir -p $(perf-tar); \ |
3bdccc88 | 166 | git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ |
a614d01b | 167 | (cd $(srctree)/tools/perf; \ |
4b63f603 | 168 | util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \ |
a614d01b | 169 | tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ |
8e5564e6 ACM |
170 | rm -r $(perf-tar); \ |
171 | $(if $(findstring tar-src,$@),, \ | |
e4a42c82 DE |
172 | $(if $(findstring bz2,$@),$(KBZIP2), \ |
173 | $(if $(findstring gz,$@),$(KGZIP), \ | |
8dfb61dc | 174 | $(if $(findstring xz,$@),$(XZ), \ |
88f5e1e6 PJ |
175 | $(if $(findstring zst,$@),$(ZSTD), \ |
176 | $(error unknown target $@))))) \ | |
8e5564e6 ACM |
177 | -f -9 $(perf-tar).tar) |
178 | ||
88f5e1e6 PJ |
179 | perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg \ |
180 | perf-tarxz-src-pkg perf-tarzst-src-pkg | |
6a4f6a26 MY |
181 | PHONY += $(perf-tar-pkgs) |
182 | $(perf-tar-pkgs): | |
8e5564e6 ACM |
183 | $(call cmd,perf_tar) |
184 | ||
1da177e4 LT |
185 | # Help text displayed when executing 'make help' |
186 | # --------------------------------------------------------------------------- | |
6a4f6a26 MY |
187 | PHONY += help |
188 | help: | |
8e5564e6 | 189 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' |
9c9b55a5 | 190 | @echo ' srcrpm-pkg - Build only the source kernel RPM package' |
3716001b RV |
191 | @echo ' binrpm-pkg - Build only the binary kernel RPM package' |
192 | @echo ' deb-pkg - Build both source and binary deb kernel packages' | |
193 | @echo ' bindeb-pkg - Build only the binary kernel deb package' | |
a64c0440 GU |
194 | @echo ' snap-pkg - Build only the binary kernel snap package' |
195 | @echo ' (will connect to external hosts)' | |
af7db99a | 196 | @echo ' dir-pkg - Build the kernel as a plain directory structure' |
8e5564e6 ACM |
197 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
198 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' | |
199 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' | |
9a17f400 | 200 | @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball' |
88f5e1e6 | 201 | @echo ' tarzst-pkg - Build the kernel as a zstd compressed tarball' |
8e5564e6 ACM |
202 | @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball' |
203 | @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' | |
204 | @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' | |
9a17f400 | 205 | @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball' |
88f5e1e6 | 206 | @echo ' perf-tarzst-src-pkg - Build $(perf-tar).tar.zst source tarball' |
000ec95f | 207 | |
7bf4582d MY |
208 | PHONY += FORCE |
209 | FORCE: | |
210 | ||
000ec95f | 211 | .PHONY: $(PHONY) |