Makefile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. # Makefile for the different targets used to generate full packages of a kernel
  2. # It uses the generic clean infrastructure of kbuild
  3. # RPM target
  4. # ---------------------------------------------------------------------------
  5. # The rpm target generates two rpm files:
  6. # /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
  7. # /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
  8. # The src.rpm files includes all source for the kernel being built
  9. # The <arch>.rpm includes kernel configuration, modules etc.
  10. #
  11. # Process to create the rpm files
  12. # a) clean the kernel
  13. # b) Generate .spec file
  14. # c) Build a tar ball, using symlink to make kernel version
  15. # first entry in the path
  16. # d) and pack the result to a tar.gz file
  17. # e) generate the rpm files, based on kernel.spec
  18. # - Use /. to avoid tar packing just the symlink
  19. # Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
  20. # but the binrpm-pkg target can; for some reason O= gets ignored.
  21. # Remove hyphens since they have special meaning in RPM filenames
  22. KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
  23. KDEB_SOURCENAME ?= linux-$(KERNELRELEASE)
  24. KBUILD_PKG_ROOTCMD ?="fakeroot -u"
  25. export KDEB_SOURCENAME
  26. # Include only those top-level files that are needed by make, plus the GPL copy
  27. TAR_CONTENT := $(KBUILD_ALLDIRS) .config .scmversion Makefile \
  28. Kbuild Kconfig COPYING $(wildcard localversion*)
  29. MKSPEC := $(srctree)/scripts/package/mkspec
  30. quiet_cmd_src_tar = TAR $(2).tar.gz
  31. cmd_src_tar = \
  32. set -e; \
  33. if test "$(objtree)" != "$(srctree)"; then \
  34. echo >&2; \
  35. echo >&2 " ERROR:"; \
  36. echo >&2 " Building source tarball is not possible outside the"; \
  37. echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
  38. echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \
  39. echo >&2; \
  40. false; \
  41. fi ; \
  42. $(srctree)/scripts/setlocalversion --save-scmversion; \
  43. tar -cz $(RCS_TAR_IGNORE) -f $(2).tar.gz \
  44. --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \
  45. rm -f $(objtree)/.scmversion
  46. # rpm-pkg
  47. # ---------------------------------------------------------------------------
  48. rpm-pkg: FORCE
  49. $(MAKE) clean
  50. $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
  51. $(call cmd,src_tar,$(KERNELPATH),kernel.spec)
  52. +rpmbuild $(RPMOPTS) --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz \
  53. --define='_smp_mflags %{nil}'
  54. # binrpm-pkg
  55. # ---------------------------------------------------------------------------
  56. binrpm-pkg: FORCE
  57. $(MAKE) KBUILD_SRC=
  58. $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
  59. +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
  60. $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
  61. clean-files += $(objtree)/*.spec
  62. deb-pkg: FORCE
  63. $(MAKE) clean
  64. $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
  65. $(call cmd,src_tar,$(KDEB_SOURCENAME))
  66. origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
  67. mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
  68. +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc
  69. bindeb-pkg: FORCE
  70. $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
  71. +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc
  72. intdeb-pkg: FORCE
  73. +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
  74. clean-dirs += $(objtree)/debian/
  75. # snap-pkg
  76. # ---------------------------------------------------------------------------
  77. snap-pkg: FORCE
  78. rm -rf $(objtree)/snap
  79. mkdir $(objtree)/snap
  80. $(MAKE) clean
  81. $(call cmd,src_tar,$(KERNELPATH))
  82. sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \
  83. s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \
  84. $(srctree)/scripts/package/snapcraft.template > \
  85. $(objtree)/snap/snapcraft.yaml
  86. cd $(objtree)/snap && \
  87. snapcraft --target-arch=$(UTS_MACHINE)
  88. clean-dirs += $(objtree)/snap/
  89. # tarball targets
  90. # ---------------------------------------------------------------------------
  91. tar%pkg: FORCE
  92. $(MAKE) KBUILD_SRC=
  93. $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
  94. clean-dirs += $(objtree)/tar-install/
  95. # perf-pkg - generate a source tarball with perf source
  96. # ---------------------------------------------------------------------------
  97. perf-tar=perf-$(KERNELVERSION)
  98. quiet_cmd_perf_tar = TAR
  99. cmd_perf_tar = \
  100. git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
  101. HEAD^{tree} $$(cd $(srctree); \
  102. echo $$(cat tools/perf/MANIFEST)) \
  103. -o $(perf-tar).tar; \
  104. mkdir -p $(perf-tar); \
  105. git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
  106. (cd $(srctree)/tools/perf; \
  107. util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \
  108. tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
  109. rm -r $(perf-tar); \
  110. $(if $(findstring tar-src,$@),, \
  111. $(if $(findstring bz2,$@),bzip2, \
  112. $(if $(findstring gz,$@),gzip, \
  113. $(if $(findstring xz,$@),xz, \
  114. $(error unknown target $@)))) \
  115. -f -9 $(perf-tar).tar)
  116. perf-%pkg: FORCE
  117. $(call cmd,perf_tar)
  118. # Help text displayed when executing 'make help'
  119. # ---------------------------------------------------------------------------
  120. help: FORCE
  121. @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
  122. @echo ' binrpm-pkg - Build only the binary kernel RPM package'
  123. @echo ' deb-pkg - Build both source and binary deb kernel packages'
  124. @echo ' bindeb-pkg - Build only the binary kernel deb package'
  125. @echo ' snap-pkg - Build only the binary kernel snap package (will connect to external hosts)'
  126. @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
  127. @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
  128. @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
  129. @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
  130. @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
  131. @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
  132. @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
  133. @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'