]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - scripts/package/Makefile
package/Makefile: move source tar creation to a function
[mirror_ubuntu-jammy-kernel.git] / scripts / package / Makefile
CommitLineData
1da177e4
LT
1# Makefile for the different targets used to generate full packages of a kernel
2# It uses the generic clean infrastructure of kbuild
3
1da177e4
LT
4# RPM target
5# ---------------------------------------------------------------------------
6# The rpm target generates two rpm files:
7# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
8# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
9# The src.rpm files includes all source for the kernel being built
10# The <arch>.rpm includes kernel configuration, modules etc.
11#
12# Process to create the rpm files
13# a) clean the kernel
14# b) Generate .spec file
15# c) Build a tar ball, using symlink to make kernel version
16# first entry in the path
17# d) and pack the result to a tar.gz file
18# e) generate the rpm files, based on kernel.spec
19# - Use /. to avoid tar packing just the symlink
20
db9038c8
FP
21# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
22# but the binrpm-pkg target can; for some reason O= gets ignored.
23
1da177e4 24# Remove hyphens since they have special meaning in RPM filenames
e1287eb8 25KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
6615d6c3 26# Include only those top-level files that are needed by make, plus the GPL copy
26803821 27TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
6615d6c3 28 Kbuild Kconfig COPYING $(wildcard localversion*)
1da177e4 29MKSPEC := $(srctree)/scripts/package/mkspec
1da177e4 30
26803821
RV
31quiet_cmd_src_tar = TAR $(2).tar.gz
32 cmd_src_tar = \
33if test "$(objtree)" != "$(srctree)"; then \
34 echo "Building source tarball is not possible outside the"; \
35 echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
36 echo "binrpm-pkg or bindeb-pkg target instead."; \
37 false; \
38fi ; \
39$(srctree)/scripts/setlocalversion --save-scmversion; \
40ln -sf $(srctree) $(2); \
41tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
42 $(addprefix $(2)/,$(TAR_CONTENT) $(3)); \
43rm -f $(2) $(objtree)/.scmversion
44
1da177e4 45# rpm-pkg
0131705d 46# ---------------------------------------------------------------------------
65013203 47rpm-pkg rpm: FORCE
1da177e4 48 $(MAKE) clean
65013203 49 $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
26803821 50 $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
1da177e4 51 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
1da177e4 52 mv -f $(objtree)/.tmp_version $(objtree)/.version
21a59991 53 rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
65013203 54 rm $(KERNELPATH).tar.gz kernel.spec
1da177e4
LT
55
56# binrpm-pkg
0131705d 57# ---------------------------------------------------------------------------
65013203 58binrpm-pkg: FORCE
a91f98a2 59 $(MAKE) KBUILD_SRC=
65013203 60 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
1da177e4 61 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
1da177e4
LT
62 mv -f $(objtree)/.tmp_version $(objtree)/.version
63
21a59991 64 rpmbuild --define "_builddir $(objtree)" --target \
f66ba560 65 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
65013203 66 rm binkernel.spec
1da177e4
LT
67
68# Deb target
69# ---------------------------------------------------------------------------
db1d1865
JN
70quiet_cmd_builddeb = BUILDDEB
71 cmd_builddeb = set -e; \
72 test `id -u` = 0 || \
73 test -n "$(KBUILD_PKG_ROOTCMD)" || { \
74 which fakeroot >/dev/null 2>&1 && \
75 KBUILD_PKG_ROOTCMD="fakeroot -u"; \
76 } || { \
77 echo; \
78 echo "builddeb must be run as root (or using fakeroot)."; \
79 echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \
80 echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \
81 echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \
82 false; \
83 } && \
84 \
85 $$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \
86 $(srctree)/scripts/package/builddeb
87
0131705d 88deb-pkg: FORCE
a91f98a2 89 $(MAKE) KBUILD_SRC=
db1d1865 90 $(call cmd,builddeb)
1da177e4
LT
91
92clean-dirs += $(objtree)/debian/
93
94
6d983fea
JBG
95# tarball targets
96# ---------------------------------------------------------------------------
0131705d 97tar%pkg: FORCE
6073aa64 98 $(MAKE) KBUILD_SRC=
6d983fea
JBG
99 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
100
101clean-dirs += $(objtree)/tar-install/
102
103
8e5564e6
ACM
104# perf-pkg - generate a source tarball with perf source
105# ---------------------------------------------------------------------------
106
107perf-tar=perf-$(KERNELVERSION)
108
109quiet_cmd_perf_tar = TAR
110 cmd_perf_tar = \
3bdccc88 111git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
112 HEAD^{tree} $$(cd $(srctree); \
113 echo $$(cat $(srctree)/tools/perf/MANIFEST)) \
114 -o $(perf-tar).tar; \
8e5564e6 115mkdir -p $(perf-tar); \
3bdccc88 116git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
a614d01b
DA
117(cd $(srctree)/tools/perf; \
118util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \
119tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
8e5564e6
ACM
120rm -r $(perf-tar); \
121$(if $(findstring tar-src,$@),, \
122$(if $(findstring bz2,$@),bzip2, \
123$(if $(findstring gz,$@),gzip, \
9a17f400
ZK
124$(if $(findstring xz,$@),xz, \
125$(error unknown target $@)))) \
8e5564e6
ACM
126 -f -9 $(perf-tar).tar)
127
128perf-%pkg: FORCE
129 $(call cmd,perf_tar)
130
1da177e4
LT
131# Help text displayed when executing 'make help'
132# ---------------------------------------------------------------------------
0131705d 133help: FORCE
8e5564e6
ACM
134 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
135 @echo ' binrpm-pkg - Build only the binary kernel package'
0f60be20 136 @echo ' deb-pkg - Build the kernel as a deb package'
8e5564e6
ACM
137 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
138 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
139 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
9a17f400 140 @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
8e5564e6
ACM
141 @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
142 @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
143 @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
9a17f400 144 @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'