Blame view

scripts/Makefile.package 6.62 KB
ec8f24b7f   Thomas Gleixner   treewide: Add SPD...
1
  # SPDX-License-Identifier: GPL-2.0-only
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  # Makefile for the different targets used to generate full packages of a kernel
000ec95fb   Masahiro Yamada   kbuild: pkg: rena...
3
4
  
  include $(srctree)/scripts/Kbuild.include
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  # 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
db9038c89   Frans Pop   kbuild: fix the b...
22
23
  # Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
  # but the binrpm-pkg target can; for some reason O= gets ignored.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
  # Remove hyphens since they have special meaning in RPM filenames
e1287eb89   Arun Sharma   Replace '-' in ke...
25
  KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
3716001bc   Riku Voipio   deb-pkg: add sour...
26
  KDEB_SOURCENAME ?= linux-$(KERNELRELEASE)
b41d920ac   Riku Voipio   kbuild: deb-pkg: ...
27
  KBUILD_PKG_ROOTCMD ?="fakeroot -u"
3716001bc   Riku Voipio   deb-pkg: add sour...
28
  export KDEB_SOURCENAME
6615d6c32   Michal Marek   rpm-pkg: Do not p...
29
  # Include only those top-level files that are needed by make, plus the GPL copy
268038214   Riku Voipio   package/Makefile:...
30
  TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
6615d6c32   Michal Marek   rpm-pkg: Do not p...
31
                 Kbuild Kconfig COPYING $(wildcard localversion*)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
  MKSPEC     := $(srctree)/scripts/package/mkspec
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
33

268038214   Riku Voipio   package/Makefile:...
34
35
36
  quiet_cmd_src_tar = TAR     $(2).tar.gz
        cmd_src_tar = \
  if test "$(objtree)" != "$(srctree)"; then \
262dad68e   Masahiro Yamada   kbuild: pkg: make...
37
38
39
40
41
42
  	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; \
268038214   Riku Voipio   package/Makefile:...
43
44
45
  	false; \
  fi ; \
  $(srctree)/scripts/setlocalversion --save-scmversion; \
e4a42c82e   Denis Efremov   kbuild: fix broke...
46
  tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \
2dbc644ac   Masahiro Yamada   kbuild: pkg: use ...
47
48
  	--transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
  rm -f $(objtree)/.scmversion
268038214   Riku Voipio   package/Makefile:...
49

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
  # rpm-pkg
0131705d5   Sam Ravnborg   kbuild: replace P...
51
  # ---------------------------------------------------------------------------
6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
52
53
  PHONY += rpm-pkg
  rpm-pkg:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
54
  	$(MAKE) clean
650132031   Michal Marek   rpm-pkg: Always r...
55
  	$(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
268038214   Riku Voipio   package/Makefile:...
56
  	$(call cmd,src_tar,$(KERNELPATH),kernel.spec)
8a16a070a   Masahiro Yamada   kbuild: rpm-pkg: ...
57
58
  	+rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
  	--define='_smp_mflags %{nil}'
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
  
  # binrpm-pkg
0131705d5   Sam Ravnborg   kbuild: replace P...
61
  # ---------------------------------------------------------------------------
6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
62
63
  PHONY += binrpm-pkg
  binrpm-pkg:
175209cce   Masahiro Yamada   kbuild: pkg: use ...
64
  	$(MAKE) -f $(srctree)/Makefile
650132031   Michal Marek   rpm-pkg: Always r...
65
  	$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
606625be4   Masahiro Yamada   kbuild: rpm-pkg: ...
66
  	+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
f66ba5609   Luiz Capitulino   package: Makefile...
67
  		$(UTS_MACHINE) -bb $(objtree)/binkernel.spec
af60e2070   Masahiro Yamada   kbuild: rpm-pkg: ...
68

6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
69
70
  PHONY += deb-pkg
  deb-pkg:
3716001bc   Riku Voipio   deb-pkg: add sour...
71
  	$(MAKE) clean
b41d920ac   Riku Voipio   kbuild: deb-pkg: ...
72
  	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
3716001bc   Riku Voipio   deb-pkg: add sour...
73
  	$(call cmd,src_tar,$(KDEB_SOURCENAME))
b41d920ac   Riku Voipio   kbuild: deb-pkg: ...
74
75
  	origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
  		mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
117948ac7   Kacper Kołodziej   kbuild: [bin]deb-...
76
  	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
3716001bc   Riku Voipio   deb-pkg: add sour...
77

6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
78
79
  PHONY += bindeb-pkg
  bindeb-pkg:
b41d920ac   Riku Voipio   kbuild: deb-pkg: ...
80
  	$(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
117948ac7   Kacper Kołodziej   kbuild: [bin]deb-...
81
  	+dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
b41d920ac   Riku Voipio   kbuild: deb-pkg: ...
82

6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
83
84
  PHONY += intdeb-pkg
  intdeb-pkg:
b41d920ac   Riku Voipio   kbuild: deb-pkg: ...
85
  	+$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86

5704d4557   Paolo Pisati   scripts/package: ...
87
88
  # snap-pkg
  # ---------------------------------------------------------------------------
6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
89
90
  PHONY += snap-pkg
  snap-pkg:
5704d4557   Paolo Pisati   scripts/package: ...
91
92
93
94
95
96
97
98
99
100
  	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)
6d983feab   Jan-Benedict Glaw   [PATCH] kbuild: c...
101
102
  # tarball targets
  # ---------------------------------------------------------------------------
af7db99a1   Matteo Croce   kbuild: Add make ...
103
  tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg
6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
104
105
  PHONY += $(tar-pkgs)
  $(tar-pkgs):
175209cce   Masahiro Yamada   kbuild: pkg: use ...
106
  	$(MAKE) -f $(srctree)/Makefile
a6e048770   Trevor Bourget   kbuild: tar-pkg: ...
107
  	+$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
6d983feab   Jan-Benedict Glaw   [PATCH] kbuild: c...
108

8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
109
110
111
112
113
114
115
  # perf-pkg - generate a source tarball with perf source
  # ---------------------------------------------------------------------------
  
  perf-tar=perf-$(KERNELVERSION)
  
  quiet_cmd_perf_tar = TAR
        cmd_perf_tar = \
3bdccc880   matt mooney   package: Makefile...
116
117
  git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/         \
  	HEAD^{tree} $$(cd $(srctree);                               \
4b63f6031   Riku Voipio   package Makefile:...
118
  		       echo $$(cat tools/perf/MANIFEST)) \
3bdccc880   matt mooney   package: Makefile...
119
  	-o $(perf-tar).tar;                                         \
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
120
  mkdir -p $(perf-tar);                                               \
3bdccc880   matt mooney   package: Makefile...
121
  git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD;    \
a614d01bd   David Ahern   perf tools: Fix v...
122
  (cd $(srctree)/tools/perf;                                          \
4b63f6031   Riku Voipio   package Makefile:...
123
  util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/);              \
a614d01bd   David Ahern   perf tools: Fix v...
124
  tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
125
126
  rm -r $(perf-tar);                                                  \
  $(if $(findstring tar-src,$@),,                                     \
e4a42c82e   Denis Efremov   kbuild: fix broke...
127
128
  $(if $(findstring bz2,$@),$(KBZIP2),                                 \
  $(if $(findstring gz,$@),$(KGZIP),                                  \
8dfb61dcb   Denis Efremov   kbuild: add varia...
129
  $(if $(findstring xz,$@),$(XZ),                                     \
9a17f4004   Zdenek Kaspar   kbuild: Add make ...
130
  $(error unknown target $@))))                                       \
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
131
  	-f -9 $(perf-tar).tar)
6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
132
133
134
  perf-tar-pkgs := perf-tar-src-pkg perf-targz-src-pkg perf-tarbz2-src-pkg perf-tarxz-src-pkg
  PHONY += $(perf-tar-pkgs)
  $(perf-tar-pkgs):
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
135
  	$(call cmd,perf_tar)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
136
137
  # Help text displayed when executing 'make help'
  # ---------------------------------------------------------------------------
6a4f6a26d   Masahiro Yamada   kbuild: pkg: add ...
138
139
  PHONY += help
  help:
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
140
  	@echo '  rpm-pkg             - Build both source and binary RPM kernel packages'
3716001bc   Riku Voipio   deb-pkg: add sour...
141
142
143
  	@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'
a64c0440d   Geert Uytterhoeven   kbuild: Wrap long...
144
145
  	@echo '  snap-pkg            - Build only the binary kernel snap package'
  	@echo '                        (will connect to external hosts)'
af7db99a1   Matteo Croce   kbuild: Add make ...
146
  	@echo '  dir-pkg             - Build the kernel as a plain directory structure'
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
147
148
149
  	@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'
9a17f4004   Zdenek Kaspar   kbuild: Add make ...
150
  	@echo '  tarxz-pkg           - Build the kernel as a xz compressed tarball'
8e5564e6c   Arnaldo Carvalho de Melo   perf tools: Make ...
151
152
153
  	@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'
9a17f4004   Zdenek Kaspar   kbuild: Add make ...
154
  	@echo '  perf-tarxz-src-pkg  - Build $(perf-tar).tar.xz source tarball'
000ec95fb   Masahiro Yamada   kbuild: pkg: rena...
155
156
  
  .PHONY: $(PHONY)