scripts.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. ifeq ($(SUPPORT_ANDROID_PLATFORM),)
  41. define if-kernel-component
  42. ifneq ($$(filter $(1),$$(KERNEL_COMPONENTS)),)
  43. M4DEFS_K += $(2)
  44. endif
  45. endef
  46. # common.m4 lives here
  47. #
  48. M4FLAGS := -I$(MAKE_TOP)/scripts
  49. # These defs are required for the init script
  50. M4DEFS_K := \
  51. -DPVRVERSION="$(PVRVERSION)" \
  52. -DPVR_BUILD_DIR=$(PVR_BUILD_DIR) \
  53. -DPVRSRV_MODNAME=$(PVRSRV_MODNAME) \
  54. -DPVR_SYSTEM=$(PVR_SYSTEM) \
  55. -DPVRTC_MODNAME=tc \
  56. -DPVRFENRIR_MODNAME=loki \
  57. -DSUPPORT_NATIVE_FENCE_SYNC=$(SUPPORT_NATIVE_FENCE_SYNC)
  58. # passing the BVNC value via init script is required
  59. # only in the case of a Guest OS running on a VZ setup
  60. ifneq ($(PVRSRV_VZ_NUM_OSID),)
  61. ifneq ($(PVRSRV_VZ_NUM_OSID), 0)
  62. ifneq ($(PVRSRV_VZ_NUM_OSID), 1)
  63. M4DEFS_K += -DRGX_BVNC=$(RGX_BVNC)
  64. endif
  65. endif
  66. endif
  67. ifneq ($(DISPLAY_CONTROLLER),)
  68. $(eval $(call if-kernel-component,$(DISPLAY_CONTROLLER),\
  69. -DDISPLAY_CONTROLLER=$(DISPLAY_CONTROLLER)))
  70. endif
  71. ifneq ($(HDMI_CONTROLLER),)
  72. $(eval $(call if-kernel-component,$(HDMI_CONTROLLER),\
  73. -DHDMI_CONTROLLER=$(HDMI_CONTROLLER)))
  74. endif
  75. ifneq ($(DMA_CONTROLLER),)
  76. $(eval $(call if-kernel-component,$(DMA_CONTROLLER),\
  77. -DDMA_CONTROLLER=$(DMA_CONTROLLER)))
  78. endif
  79. M4DEFS := \
  80. -DPDUMP_CLIENT_NAME=$(PDUMP_CLIENT_NAME)
  81. ifeq ($(WINDOW_SYSTEM),xorg)
  82. M4DEFS += -DSUPPORT_XORG=1
  83. M4DEFS += -DPVR_XORG_DESTDIR=$(LWS_PREFIX)/bin
  84. M4DEFS += -DPVR_CONF_DESTDIR=$(XORG_CONFDIR)
  85. else ifeq ($(WINDOW_SYSTEM),wayland)
  86. M4DEFS += -DPVR_WESTON_DESTDIR=$(LWS_PREFIX)/bin
  87. M4DEFS += -DSUPPORT_WAYLAND=1
  88. M4DEFS += -DSUPPORT_XWAYLAND=$(SUPPORT_XWAYLAND)
  89. endif
  90. ifeq ($(DTB_OVERLAY),1)
  91. M4DEFS += -DDTB_FILE=$(DTB_FILE_NAME)
  92. endif
  93. init_script_install_path := $${RC_DESTDIR}
  94. $(TARGET_NEUTRAL_OUT)/rc.pvr: $(PVRVERSION_H) $(CONFIG_MK) \
  95. $(MAKE_TOP)/scripts/rc.pvr.m4 $(MAKE_TOP)/scripts/common.m4 \
  96. $(MAKE_TOP)/$(PVR_BUILD_DIR)/rc.pvr.m4 \
  97. | $(TARGET_NEUTRAL_OUT)
  98. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  99. $(M4) $(M4FLAGS) $(M4DEFS) $(M4DEFS_K) $(MAKE_TOP)/scripts/rc.pvr.m4 \
  100. $(MAKE_TOP)/$(PVR_BUILD_DIR)/rc.pvr.m4 > $@
  101. $(CHMOD) +x $@
  102. .PHONY: init_script
  103. init_script: $(TARGET_NEUTRAL_OUT)/rc.pvr
  104. $(GENERATED_CODE_OUT)/init_script:
  105. $(make-directory)
  106. $(GENERATED_CODE_OUT)/init_script/.install: init_script_install_path := $(init_script_install_path)
  107. $(GENERATED_CODE_OUT)/init_script/.install: | $(GENERATED_CODE_OUT)/init_script
  108. @echo 'install_file rc.pvr $(init_script_install_path)/rc.pvr "boot script" 0755 0:0' >$@
  109. endif # ifeq ($(SUPPORT_ANDROID_PLATFORM),)
  110. # This code mimics the way Make processes our implicit/explicit goal list.
  111. # It tries to build up a list of components that were actually built, from
  112. # whence an install script is generated.
  113. #
  114. ifneq ($(MAKECMDGOALS),)
  115. BUILT_UM := $(MAKECMDGOALS)
  116. ifneq ($(filter build services_all components uninstall,$(MAKECMDGOALS)),)
  117. BUILT_UM += $(COMPONENTS)
  118. endif
  119. BUILT_UM := $(sort $(filter $(ALL_MODULES) init_script,$(BUILT_UM)))
  120. else
  121. BUILT_UM := $(sort $(COMPONENTS))
  122. endif
  123. ifneq ($(MAKECMDGOALS),)
  124. BUILT_FW := $(MAKECMDGOALS)
  125. ifneq ($(filter build services_all firmware uninstall,$(MAKECMDGOALS)),)
  126. BUILT_FW += $(FW_COMPONENTS)
  127. endif
  128. BUILT_FW := $(sort $(filter $(ALL_MODULES),$(BUILT_FW)))
  129. else
  130. BUILT_FW := $(sort $(FW_COMPONENTS))
  131. endif
  132. ifneq ($(MAKECMDGOALS),)
  133. BUILT_KM := $(MAKECMDGOALS)
  134. ifneq ($(filter build services_all kbuild uninstall,$(MAKECMDGOALS)),)
  135. BUILT_KM += $(KERNEL_COMPONENTS)
  136. endif
  137. BUILT_KM := $(sort $(filter $(ALL_MODULES),$(BUILT_KM)))
  138. else
  139. BUILT_KM := $(sort $(KERNEL_COMPONENTS))
  140. endif
  141. INSTALL_UM_MODULES := \
  142. $(strip $(foreach _m,$(BUILT_UM),\
  143. $(if $(filter $(doc_types) module_group,$($(_m)_type)),,\
  144. $(if $(filter host_%,$($(_m)_arch)),,\
  145. $(if $($(_m)_install_path),$(_m),\
  146. $(warning WARNING: UM $(_m)_install_path not defined))))))
  147. INSTALL_UM_MODULES := \
  148. $(sort $(INSTALL_UM_MODULES) \
  149. $(strip $(foreach _m,$(BUILT_UM),\
  150. $(if $(filter module_group,$($(_m)_type)),\
  151. $($(_m)_install_dependencies)))))
  152. # Build up a list of installable shared libraries. The shared_library module
  153. # type is specially guaranteed to define $(_m)_target, even if the Linux.mk
  154. # itself didn't. The list is formatted with <module>:<target> pairs e.g.
  155. # "moduleA:libmoduleA.so moduleB:libcustom.so" for later processing.
  156. ALL_SHARED_INSTALLABLE := \
  157. $(sort $(foreach _a,$(ALL_MODULES),\
  158. $(if $(filter shared_library,$($(_a)_type)),$(_a):$($(_a)_target),)))
  159. # Handle implicit install dependencies. Executables and shared libraries may
  160. # be linked against other shared libraries. Avoid requiring the user to
  161. # specify the program's binary dependencies explicitly with $(m)_install_extra
  162. INSTALL_UM_MODULES := \
  163. $(sort $(INSTALL_UM_MODULES) \
  164. $(foreach _a,$(ALL_SHARED_INSTALLABLE),\
  165. $(foreach _m,$(INSTALL_UM_MODULES),\
  166. $(foreach _l,$($(_m)_libs),\
  167. $(if $(filter lib$(_l).so,$(word 2,$(subst :, ,$(_a)))),\
  168. $(word 1,$(subst :, ,$(_a))))))))
  169. # Add explicit dependencies that must be installed
  170. INSTALL_UM_MODULES := \
  171. $(sort $(INSTALL_UM_MODULES) \
  172. $(foreach _m,$(INSTALL_UM_MODULES),\
  173. $($(_m)_install_dependencies)))
  174. define calculate-um-fragments
  175. # Work out which modules are required for this arch.
  176. INSTALL_UM_MODULES_$(1) := \
  177. $$(strip $$(foreach _m,$(INSTALL_UM_MODULES),\
  178. $$(if $$(filter $(1),$$(INTERNAL_ARCH_LIST_FOR_$$(_m))),$$(_m))))
  179. INSTALL_UM_FRAGMENTS_$(1) := $$(foreach _m,$$(INSTALL_UM_MODULES_$(1)),$(RELATIVE_OUT)/$(1)/intermediates/$$(_m)/.install)
  180. .PHONY: install_um_$(1)_debug
  181. install_um_$(1)_debug: $$(INSTALL_UM_FRAGMENTS_$(1))
  182. $(CAT) $$^
  183. endef
  184. $(foreach _t,$(TARGET_ALL_ARCH) target_neutral,$(eval $(call calculate-um-fragments,$(_t))))
  185. INSTALL_FW_FRAGMENTS := \
  186. $(strip $(foreach _m,$(BUILT_FW),\
  187. $(if $(filter-out custom,$($(_m)_type)),,\
  188. $(if $($(_m)_install_path),\
  189. $(RELATIVE_OUT)/target_neutral/intermediates/$(_m)/.install,))))
  190. .PHONY: install_fw_debug
  191. install_fw_debug: $(INSTALL_FW_FRAGMENTS)
  192. $(CAT) $^
  193. ifneq ($(filter init_script, $(INSTALL_UM_MODULES)),)
  194. INSTALL_UM_FRAGMENTS_target_neutral += $(GENERATED_CODE_OUT)/init_script/.install
  195. endif
  196. INSTALL_KM_FRAGMENTS := \
  197. $(strip $(foreach _m,$(BUILT_KM),\
  198. $(if $(filter-out kernel_module,$($(_m)_type)),,\
  199. $(if $($(_m)_install_path),\
  200. $(TARGET_PRIMARY_OUT)/intermediates/$(_m)/.install,\
  201. $(warning WARNING: KM $(_m)_install_path not defined)))))
  202. .PHONY: install_km_debug
  203. install_km_debug: $(INSTALL_KM_FRAGMENTS)
  204. $(CAT) $^
  205. ifneq ($(INSTALL_KM_FRAGMENTS),)
  206. $(TARGET_PRIMARY_OUT)/install_km.sh: $(INSTALL_KM_FRAGMENTS) $(CONFIG_KERNEL_MK) | $(TARGET_PRIMARY_OUT)
  207. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  208. $(ECHO) KERNELVERSION=$(KERNEL_ID) > $@
  209. $(ECHO) MOD_DESTDIR=$(patsubst %/,%,$(PVRSRV_MODULE_BASEDIR)) >> $@
  210. ifeq ($(SUPPORT_ANDROID_PLATFORM),)
  211. $(ECHO) check_module_directory /lib/modules/$(KERNEL_ID) >> $@
  212. endif
  213. $(CAT) $(INSTALL_KM_FRAGMENTS) >> $@
  214. install_script_km: $(TARGET_PRIMARY_OUT)/install_km.sh
  215. endif
  216. # Build UM arch scripts
  217. define create-install-um-script
  218. ifneq ($$(INSTALL_UM_FRAGMENTS_$(1)),)
  219. $(RELATIVE_OUT)/$(1)/install_um.sh: $$(INSTALL_UM_FRAGMENTS_$(1)) $(CONFIG_MK) | $(RELATIVE_OUT)/$(1)
  220. $(if $(V),,@echo " GEN " $$(call relative-to-top,$$@))
  221. $(CAT) $$(INSTALL_UM_FRAGMENTS_$(1)) > $$@
  222. install_script: $(RELATIVE_OUT)/$(1)/install_um.sh
  223. endif
  224. endef
  225. $(foreach _t,$(TARGET_ALL_ARCH) target_neutral,$(eval $(call create-install-um-script,$(_t))))
  226. # Build FW neutral script
  227. ifneq ($(INSTALL_FW_FRAGMENTS),)
  228. $(RELATIVE_OUT)/target_neutral/install_fw.sh: $(INSTALL_FW_FRAGMENTS) $(CONFIG_MK) | $(RELATIVE_OUT)/target_neutral
  229. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  230. $(CAT) $(INSTALL_FW_FRAGMENTS) > $@
  231. install_script_fw: $(RELATIVE_OUT)/target_neutral/install_fw.sh
  232. endif
  233. # Build the top-level install script that drives the install.
  234. ifneq ($(SUPPORT_ANDROID_PLATFORM),)
  235. ifneq ($(SUPPORT_ARC_PLATFORM),)
  236. install_sh_template := $(MAKE_TOP)/scripts/install.sh.tpl
  237. else
  238. install_sh_template := $(MAKE_TOP)/common/android/install.sh.tpl
  239. endif
  240. else
  241. install_sh_template := $(MAKE_TOP)/scripts/install.sh.tpl
  242. endif
  243. $(RELATIVE_OUT)/install.sh: $(PVRVERSION_H) | $(RELATIVE_OUT)
  244. # In customer packages only one of config.mk or config_kernel.mk will exist.
  245. # We can depend on either one, as long as we rebuild the install script when
  246. # the config options it uses change.
  247. $(RELATIVE_OUT)/install.sh: $(call if-exists,$(CONFIG_MK),$(CONFIG_KERNEL_MK))
  248. $(RELATIVE_OUT)/install.sh: $(install_sh_template)
  249. $(if $(V),,@echo " GEN " $(call relative-to-top,$@))
  250. $(ECHO) 's/\[PVRVERSION\]/$(subst /,\/,$(PVRVERSION))/g;' > $(RELATIVE_OUT)/install.sh.sed
  251. $(ECHO) 's/\[PVRBUILD\]/$(BUILD)/g;' >> $(RELATIVE_OUT)/install.sh.sed
  252. $(ECHO) 's/\[PRIMARY_ARCH\]/$(TARGET_PRIMARY_ARCH)/g;' >> $(RELATIVE_OUT)/install.sh.sed
  253. $(ECHO) 's/\[ARCHITECTURES\]/$(TARGET_ALL_ARCH) target_neutral/g;' >> $(RELATIVE_OUT)/install.sh.sed
  254. $(ECHO) 's/\[APP_DESTDIR\]/$(subst /,\/,$(APP_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  255. $(ECHO) 's/\[BIN_DESTDIR\]/$(subst /,\/,$(BIN_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  256. $(ECHO) 's/\[SHARE_DESTDIR\]/$(subst /,\/,$(SHARE_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  257. $(ECHO) 's/\[FW_DESTDIR\]/$(subst /,\/,$(FW_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  258. $(ECHO) 's/\[DTB_DESTDIR\]/$(subst /,\/,$(DTB_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  259. $(ECHO) 's/\[SHADER_DESTDIR\]/$(subst /,\/,$(SHADER_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  260. $(ECHO) 's/\[SHLIB_DESTDIR\]/$(subst /,\/,$(SHLIB_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  261. $(ECHO) 's/\[INCLUDE_DESTDIR\]/$(subst /,\/,$(INCLUDE_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  262. $(ECHO) 's/\[TEST_DESTDIR\]/$(subst /,\/,$(TEST_DESTDIR))/g;' >> $(RELATIVE_OUT)/install.sh.sed
  263. @sed -f $(RELATIVE_OUT)/install.sh.sed $< > $@
  264. $(CHMOD) +x $@
  265. $(RM) $(RELATIVE_OUT)/install.sh.sed
  266. install_script: $(RELATIVE_OUT)/install.sh
  267. install_script_fw: $(RELATIVE_OUT)/install.sh
  268. install_script_km: $(RELATIVE_OUT)/install.sh
  269. firmware_install: installfw
  270. components_install: installcomponents