Makefile 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. # Include only those top-level files that are needed by make, plus the GPL copy
  24. TAR_CONTENT := $(KBUILD_ALLDIRS) kernel.spec .config .scmversion Makefile \
  25. Kbuild Kconfig COPYING $(wildcard localversion*)
  26. TAR_CONTENT := $(addprefix $(KERNELPATH)/,$(TAR_CONTENT))
  27. MKSPEC := $(srctree)/scripts/package/mkspec
  28. # rpm-pkg
  29. # ---------------------------------------------------------------------------
  30. rpm-pkg rpm: FORCE
  31. @if test "$(objtree)" != "$(srctree)"; then \
  32. echo "Building source + binary RPM is not possible outside the"; \
  33. echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
  34. echo "binrpm-pkg target instead."; \
  35. false; \
  36. fi
  37. $(MAKE) clean
  38. ln -sf $(srctree) $(KERNELPATH)
  39. $(CONFIG_SHELL) $(MKSPEC) >$(objtree)/kernel.spec
  40. $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion
  41. tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(TAR_CONTENT)
  42. rm $(KERNELPATH)
  43. rm -f $(objtree)/.scmversion
  44. $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
  45. mv -f $(objtree)/.tmp_version $(objtree)/.version
  46. rpmbuild --target $(UTS_MACHINE) -ta $(KERNELPATH).tar.gz
  47. rm $(KERNELPATH).tar.gz kernel.spec
  48. # binrpm-pkg
  49. # ---------------------------------------------------------------------------
  50. binrpm-pkg: FORCE
  51. $(MAKE) KBUILD_SRC=
  52. $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
  53. $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
  54. mv -f $(objtree)/.tmp_version $(objtree)/.version
  55. rpmbuild --define "_builddir $(objtree)" --target \
  56. $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
  57. rm binkernel.spec
  58. # Deb target
  59. # ---------------------------------------------------------------------------
  60. quiet_cmd_builddeb = BUILDDEB
  61. cmd_builddeb = set -e; \
  62. test `id -u` = 0 || \
  63. test -n "$(KBUILD_PKG_ROOTCMD)" || { \
  64. which fakeroot >/dev/null 2>&1 && \
  65. KBUILD_PKG_ROOTCMD="fakeroot -u"; \
  66. } || { \
  67. echo; \
  68. echo "builddeb must be run as root (or using fakeroot)."; \
  69. echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \
  70. echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \
  71. echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \
  72. false; \
  73. } && \
  74. \
  75. $$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \
  76. $(srctree)/scripts/package/builddeb
  77. deb-pkg: FORCE
  78. $(MAKE) KBUILD_SRC=
  79. $(call cmd,builddeb)
  80. clean-dirs += $(objtree)/debian/
  81. # tarball targets
  82. # ---------------------------------------------------------------------------
  83. tar%pkg: FORCE
  84. $(MAKE) KBUILD_SRC=
  85. $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
  86. clean-dirs += $(objtree)/tar-install/
  87. # perf-pkg - generate a source tarball with perf source
  88. # ---------------------------------------------------------------------------
  89. perf-tar=perf-$(KERNELVERSION)
  90. quiet_cmd_perf_tar = TAR
  91. cmd_perf_tar = \
  92. git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \
  93. HEAD^{tree} $$(cd $(srctree); \
  94. echo $$(cat $(srctree)/tools/perf/MANIFEST)) \
  95. -o $(perf-tar).tar; \
  96. mkdir -p $(perf-tar); \
  97. git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \
  98. (cd $(srctree)/tools/perf; \
  99. util/PERF-VERSION-GEN ../../$(perf-tar)/ 2>/dev/null); \
  100. tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \
  101. rm -r $(perf-tar); \
  102. $(if $(findstring tar-src,$@),, \
  103. $(if $(findstring bz2,$@),bzip2, \
  104. $(if $(findstring gz,$@),gzip, \
  105. $(if $(findstring xz,$@),xz, \
  106. $(error unknown target $@)))) \
  107. -f -9 $(perf-tar).tar)
  108. perf-%pkg: FORCE
  109. $(call cmd,perf_tar)
  110. # Help text displayed when executing 'make help'
  111. # ---------------------------------------------------------------------------
  112. help: FORCE
  113. @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
  114. @echo ' binrpm-pkg - Build only the binary kernel package'
  115. @echo ' deb-pkg - Build the kernel as a deb package'
  116. @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
  117. @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
  118. @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
  119. @echo ' tarxz-pkg - Build the kernel as a xz compressed tarball'
  120. @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball'
  121. @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball'
  122. @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball'
  123. @echo ' perf-tarxz-src-pkg - Build $(perf-tar).tar.xz source tarball'