Commit | Line | Data |
---|---|---|
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 LT |
24 | # Do we have rpmbuild, otherwise fall back to the older rpm |
25 | RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ | |
26 | else echo rpm; fi) | |
27 | ||
28 | # Remove hyphens since they have special meaning in RPM filenames | |
e1287eb8 | 29 | KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) |
6615d6c3 MM |
30 | # Include only those top-level files that are needed by make, plus the GPL copy |
31 | TAR_CONTENT := $(KBUILD_ALLDIRS) kernel.spec .config .scmversion Makefile \ | |
32 | Kbuild Kconfig COPYING $(wildcard localversion*) | |
33 | TAR_CONTENT := $(addprefix $(KERNELPATH)/,$(TAR_CONTENT)) | |
1da177e4 | 34 | MKSPEC := $(srctree)/scripts/package/mkspec |
1da177e4 LT |
35 | |
36 | # rpm-pkg | |
0131705d | 37 | # --------------------------------------------------------------------------- |
1da177e4 LT |
38 | $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile |
39 | $(CONFIG_SHELL) $(MKSPEC) > $@ | |
40 | ||
0131705d | 41 | rpm-pkg rpm: $(objtree)/kernel.spec FORCE |
4c6e00cf | 42 | @if test "$(objtree)" != "$(srctree)"; then \ |
db9038c8 FP |
43 | echo "Building source + binary RPM is not possible outside the"; \ |
44 | echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ | |
45 | echo "binrpm-pkg target instead."; \ | |
46 | false; \ | |
47 | fi | |
1da177e4 | 48 | $(MAKE) clean |
403d3cc4 | 49 | ln -sf $(srctree) $(KERNELPATH) |
b003afe3 | 50 | $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion |
403d3cc4 MM |
51 | tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(TAR_CONTENT) |
52 | rm $(KERNELPATH) | |
b925dbfe | 53 | rm -f $(objtree)/.scmversion |
1da177e4 LT |
54 | set -e; \ |
55 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version | |
56 | set -e; \ | |
57 | mv -f $(objtree)/.tmp_version $(objtree)/.version | |
403d3cc4 MM |
58 | $(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz |
59 | rm $(KERNELPATH).tar.gz | |
1da177e4 LT |
60 | |
61 | clean-files := $(objtree)/kernel.spec | |
62 | ||
63 | # binrpm-pkg | |
0131705d | 64 | # --------------------------------------------------------------------------- |
1da177e4 LT |
65 | $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile |
66 | $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ | |
4f193362 | 67 | |
0131705d | 68 | binrpm-pkg: $(objtree)/binkernel.spec FORCE |
a91f98a2 | 69 | $(MAKE) KBUILD_SRC= |
1da177e4 LT |
70 | set -e; \ |
71 | $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version | |
72 | set -e; \ | |
73 | mv -f $(objtree)/.tmp_version $(objtree)/.version | |
74 | ||
db9038c8 | 75 | $(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \ |
c39dd502 | 76 | $(UTS_MACHINE) -bb $< |
1da177e4 LT |
77 | |
78 | clean-files += $(objtree)/binkernel.spec | |
79 | ||
80 | # Deb target | |
81 | # --------------------------------------------------------------------------- | |
db1d1865 JN |
82 | quiet_cmd_builddeb = BUILDDEB |
83 | cmd_builddeb = set -e; \ | |
84 | test `id -u` = 0 || \ | |
85 | test -n "$(KBUILD_PKG_ROOTCMD)" || { \ | |
86 | which fakeroot >/dev/null 2>&1 && \ | |
87 | KBUILD_PKG_ROOTCMD="fakeroot -u"; \ | |
88 | } || { \ | |
89 | echo; \ | |
90 | echo "builddeb must be run as root (or using fakeroot)."; \ | |
91 | echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \ | |
92 | echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \ | |
93 | echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \ | |
94 | false; \ | |
95 | } && \ | |
96 | \ | |
97 | $$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \ | |
98 | $(srctree)/scripts/package/builddeb | |
99 | ||
0131705d | 100 | deb-pkg: FORCE |
a91f98a2 | 101 | $(MAKE) KBUILD_SRC= |
db1d1865 | 102 | $(call cmd,builddeb) |
1da177e4 LT |
103 | |
104 | clean-dirs += $(objtree)/debian/ | |
105 | ||
106 | ||
6d983fea JBG |
107 | # tarball targets |
108 | # --------------------------------------------------------------------------- | |
0131705d | 109 | tar%pkg: FORCE |
6073aa64 | 110 | $(MAKE) KBUILD_SRC= |
6d983fea JBG |
111 | $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ |
112 | ||
113 | clean-dirs += $(objtree)/tar-install/ | |
114 | ||
115 | ||
8e5564e6 ACM |
116 | # perf-pkg - generate a source tarball with perf source |
117 | # --------------------------------------------------------------------------- | |
118 | ||
119 | perf-tar=perf-$(KERNELVERSION) | |
120 | ||
121 | quiet_cmd_perf_tar = TAR | |
122 | cmd_perf_tar = \ | |
3bdccc88 | 123 | git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ |
124 | HEAD^{tree} $$(cd $(srctree); \ | |
125 | echo $$(cat $(srctree)/tools/perf/MANIFEST)) \ | |
126 | -o $(perf-tar).tar; \ | |
8e5564e6 | 127 | mkdir -p $(perf-tar); \ |
3bdccc88 | 128 | git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ |
8e5564e6 ACM |
129 | tar rf $(perf-tar).tar $(perf-tar)/HEAD; \ |
130 | rm -r $(perf-tar); \ | |
131 | $(if $(findstring tar-src,$@),, \ | |
132 | $(if $(findstring bz2,$@),bzip2, \ | |
133 | $(if $(findstring gz,$@),gzip, \ | |
9a17f400 ZK |
134 | $(if $(findstring xz,$@),xz, \ |
135 | $(error unknown target $@)))) \ | |
8e5564e6 ACM |
136 | -f -9 $(perf-tar).tar) |
137 | ||
138 | perf-%pkg: FORCE | |
139 | $(call cmd,perf_tar) | |
140 | ||
1da177e4 LT |
141 | # Help text displayed when executing 'make help' |
142 | # --------------------------------------------------------------------------- | |
0131705d | 143 | help: FORCE |
8e5564e6 ACM |
144 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' |
145 | @echo ' binrpm-pkg - Build only the binary kernel package' | |
0f60be20 | 146 | @echo ' deb-pkg - Build the kernel as a deb package' |
8e5564e6 ACM |
147 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
148 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' | |
149 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' | |
9a17f400 | 150 | @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball' |
8e5564e6 ACM |
151 | @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball' |
152 | @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' | |
153 | @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' | |
9a17f400 | 154 | @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball' |
1da177e4 | 155 |