Makefile 5.7 KB

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