packaging.mk 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ########################################################################### ###
  2. #@Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  3. #@License Dual MIT/GPLv2
  4. #
  5. # The contents of this file are subject to the MIT license as set out below.
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # Alternatively, the contents of this file may be used under the terms of
  18. # the GNU General Public License Version 2 ("GPL") in which case the provisions
  19. # of GPL are applicable instead of those above.
  20. #
  21. # If you wish to allow use of your version of this file only under the terms of
  22. # GPL, and not to allow others to use your version of this file under the terms
  23. # of the MIT license, indicate your decision by deleting the provisions above
  24. # and replace them with the notice and other provisions required by GPL as set
  25. # out in the file called "GPL-COPYING" included in this distribution. If you do
  26. # not delete the provisions above, a recipient may use your version of this file
  27. # under the terms of either the MIT license or GPL.
  28. #
  29. # This License is also included in this distribution in the file called
  30. # "MIT-COPYING".
  31. #
  32. # EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  33. # PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  34. # BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  35. # PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  36. # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  37. # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  38. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  39. ### ###########################################################################
  40. .PHONY: rpm_specs
  41. rpm_specs: ddk_rpm_spec llvm_rpm_spec mesa_rpm_spec
  42. # DDK spec file
  43. #
  44. .PHONY: ddk_rpm_spec
  45. ddk_rpm_spec: $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec
  46. $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec: METAG_VERSION := $(METAG_VERSION_NEEDED)
  47. $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec: MIPS_VERSION := $(MIPS_VERSION_NEEDED)
  48. $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec: RISCV_VERSION := $(RISCV_VERSION_NEEDED)
  49. $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec: $(MAKE_TOP)/packaging/pvr-rogue-ddk.spec
  50. $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec: $(PVRVERSION_H) $(CONFIG_MK)
  51. $(RELATIVE_OUT)/packaging/pvr-rogue-ddk.spec: | $(RELATIVE_OUT)/packaging
  52. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  53. $(SED) \
  54. -e 's,@DDK_VERSION@,$(PVRVERSION_MAJ).$(PVRVERSION_MIN).$(PVRVERSION_BUILD),g' \
  55. -e 's,@METAG_VERSION@,$(METAG_VERSION),g' \
  56. -e 's,@MIPS_VERSION@,$(MIPS_VERSION),g' \
  57. -e 's,@RISCV_VERSION@,$(RISCV_VERSION),g' \
  58. $< > $@
  59. $(RELATIVE_OUT)/packaging:
  60. @mkdir -p $@
  61. # LLVM spec file
  62. #
  63. # Generate llvm-img rpm spec file and copy patches referenced in the spec file
  64. # to the same location.
  65. #
  66. LLVM_PATCH_DIR := $(TOP)/compiler/llvmufgen/rogue/patches
  67. LLVM_PATCHES := $(sort $(notdir $(wildcard $(LLVM_PATCH_DIR)/*)))
  68. LLVM_OUT_DIR := $(RELATIVE_OUT)/packaging/llvm-img
  69. .PHONY: llvm_rpm_spec
  70. llvm_rpm_spec: $(LLVM_OUT_DIR)/llvm-img.spec
  71. $(LLVM_OUT_DIR)/llvm-img.spec: LLVM_PATCH_DIR := $(LLVM_PATCH_DIR)
  72. $(LLVM_OUT_DIR)/llvm-img.spec: $(MAKE_TOP)/packaging/llvm-img.spec
  73. $(LLVM_OUT_DIR)/lolvm-img.spec: $(addprefix $(LLVM_PATCH_DIR)/, $(LLVM_PATCHES))
  74. $(LLVM_OUT_DIR)/llvm-img.spec: | $(LLVM_OUT_DIR)
  75. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  76. $(CP) $< $@
  77. $(CP) $(wildcard $(LLVM_PATCH_DIR)/*) $(dir $@)
  78. $(LLVM_OUT_DIR):
  79. @mkdir -p $@
  80. # Mesa spec file
  81. #
  82. # Generate mesa-img rpm spec file. This involves generating 'patch' lines
  83. # based upon the patches found in the Mesa patch directory. This is done
  84. # to protect against Mesa patches being added and removed (something that
  85. # happens fairly often). All referenced patches get copied to the location
  86. # of the generated spec file.
  87. #
  88. MESA_PATCH_DIR := $(LWS_GIT_PATCH_DIR)/mesa/mesa-21.0.1
  89. MESA_PATCHES := $(sort $(notdir $(wildcard $(MESA_PATCH_DIR)/*)))
  90. MESA_OUT_DIR := $(RELATIVE_OUT)/packaging/mesa-img
  91. .PHONY: mesa_rpm_spec
  92. mesa_rpm_spec: $(MESA_OUT_DIR)/mesa-img.spec
  93. $(MESA_OUT_DIR)/mesa-img.spec: MESA_PATCH_DIR := $(MESA_PATCH_DIR)
  94. $(MESA_OUT_DIR)/mesa-img.spec: MESA_PATCHES := $(MESA_PATCHES)
  95. $(MESA_OUT_DIR)/mesa-img.spec: SUBST_PATCHES_TXT := $(MESA_OUT_DIR)/subst_patches.txt
  96. $(MESA_OUT_DIR)/mesa-img.spec: SUBST_APPLY_PATCHES_TXT := $(MESA_OUT_DIR)/subst_apply_patches.txt
  97. $(MESA_OUT_DIR)/mesa-img.spec: $(MAKE_TOP)/packaging/mesa-img.spec
  98. $(MESA_OUT_DIR)/mesa-img.spec: $(addprefix $(MESA_PATCH_DIR)/, $(MESA_PATCHES))
  99. $(MESA_OUT_DIR)/mesa-img.spec: | $(MESA_OUT_DIR)
  100. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  101. $(if $(V),,@)patch_nums=$$(seq -s ' ' 0 $$(expr $$(echo $(MESA_PATCHES) | wc -w) - 1)); \
  102. echo "# Gbp-Ignore-Patches: $${patch_nums}" > $(SUBST_PATCHES_TXT)
  103. $(if $(V),,@)i=0; for patch in $(MESA_PATCHES); do \
  104. echo "Patch$${i}: $${patch}" >> $(SUBST_PATCHES_TXT); \
  105. i=$$(expr $${i} + 1); \
  106. done
  107. $(if $(V),,@)i=0; for patch in $(MESA_PATCHES); do \
  108. echo "%patch$${i} -p1" >> $(SUBST_APPLY_PATCHES_TXT); \
  109. i=$$(expr $${i} + 1); \
  110. done
  111. $(SED) \
  112. -e '/@PATCHES@/ {' -e 'r $(SUBST_PATCHES_TXT)' -e 'd' -e '}' \
  113. -e '/@APPLY_PATCHES@/ {' -e 'r $(SUBST_APPLY_PATCHES_TXT)' -e 'd' -e '}' \
  114. $< > $@
  115. $(RM) $(SUBST_PATCHES_TXT)
  116. $(RM) $(SUBST_APPLY_PATCHES_TXT)
  117. $(RM) $(MESA_OUT_DIR)/*.patch
  118. $(CP) $(wildcard $(MESA_PATCH_DIR)/*) $(dir $@)
  119. $(MESA_OUT_DIR):
  120. @mkdir -p $@