Guest User

Untitled

a guest
Sep 2nd, 2015
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. # Copyright (C) 2014 Jolla Oy
  3. # Contact: <david.greaves@jolla.com>
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17.  
  18. LOCAL_PATH:= $(call my-dir)
  19. HYBRIS_PATH:=$(LOCAL_PATH)
  20.  
  21. # We use the commandline and kernel configuration varables from
  22. # build/core/Makefile to be consistent. Support for boot/recovery
  23. # image specific kernel COMMANDLINE vars is provided but whether it
  24. # works or not is down to your bootloader.
  25.  
  26. HYBRIS_BOOTIMG_COMMANDLINE :=
  27. HYBRIS_RECOVERYIMG_COMMANDLINE := bootmode=debug
  28. HYBRIS_BOOTLOGO :=
  29. # BOOT
  30. HYBRIS_B_DEFAULT_OS := sailfishos
  31. HYBRIS_B_ALWAYSDEBUG :=
  32. # RECOVERY
  33. HYBRIS_R_DEFAULT_OS := sailfishos
  34. HYBRIS_R_ALWAYSDEBUG := 1
  35.  
  36. ## All manual "config" should be done above this line
  37.  
  38. # Force deferred assignment
  39.  
  40. HYBRIS_FIXUP_MOUNTS := $(LOCAL_PATH)/fixup-mountpoints
  41.  
  42.  
  43. # Find any fstab files for required partition information.
  44. # in AOSP we could use TARGET_VENDOR
  45. # TARGET_VENDOR := $(shell echo $(PRODUCT_MANUFACTURER) | tr '[:upper:]' '[:lower:]')
  46. # but Cyanogenmod seems to use device/*/$(TARGET_DEVICE) in config.mk so we will too.
  47. HYBRIS_FSTABS := $(shell find device/*/$(TARGET_DEVICE) -name *fstab* | grep -v goldfish)
  48. # If fstab files were not found from primary device repo then they might be in
  49. # some other device repo so try to search for them first in device/PRODUCT_MANUFACTURER.
  50. # In many cases PRODUCT_MANUFACTURER is the short vendor name used in folder names.
  51. ifeq "$(HYBRIS_FSTABS)" ""
  52. TARGET_VENDOR := "$(shell echo $(PRODUCT_MANUFACTURER) | tr '[:upper:]' '[:lower:]')"
  53. HYBRIS_FSTABS := $(shell find device/$(TARGET_VENDOR) -name *fstab* | grep -v goldfish)
  54. endif
  55. # Some devices devices have the short vendor name in PRODUCT_BRAND so try to
  56. # search from device/PRODUCT_BRAND if fstab files are still not found.
  57. ifeq "$(HYBRIS_FSTABS)" ""
  58. TARGET_VENDOR := "$(shell echo $(PRODUCT_BRAND) | tr '[:upper:]' '[:lower:]')"
  59. HYBRIS_FSTABS := $(shell find device/$(TARGET_VENDOR) -name *fstab* | grep -v goldfish)
  60. endif
  61.  
  62. # Get the unique /dev field(s) from the line(s) containing the fs mount point
  63. # Note the perl one-liner uses double-$ as per Makefile syntax
  64. HYBRIS_BOOT_PART := $(shell /usr/bin/perl -w -e '$$fs=shift; if ($$ARGV[0]) { while (<>) { next unless /^$$fs\s|\s$$fs\s/;for (split) {next unless m(^/dev); print "$$_\n"; }}} else { print "ERROR: *fstab* not found\n";}' /boot $(HYBRIS_FSTABS) | sort -u)
  65. HYBRIS_DATA_PART := $(shell /usr/bin/perl -w -e '$$fs=shift; if ($$ARGV[0]) { while (<>) { next unless /^$$fs\s|\s$$fs\s/;for (split) {next unless m(^/dev); print "$$_\n"; }}} else { print "ERROR: *fstab* not found\n";}' /data $(HYBRIS_FSTABS) | sort -u)
  66.  
  67. $(warning ********************* /boot appears to live on $(HYBRIS_BOOT_PART))
  68. $(warning ********************* /data appears to live on $(HYBRIS_DATA_PART))
  69.  
  70. ifneq ($(words $(HYBRIS_BOOT_PART))$(words $(HYBRIS_DATA_PART)),11)
  71. $(error There should be a one and only one device entry for HYBRIS_BOOT_PART and HYBRIS_DATA_PART)
  72. endif
  73.  
  74. # Command used to make the image
  75. MKBOOTIMG := mkbootimg
  76. BB_STATIC := $(PRODUCT_OUT)/utilities/busybox
  77.  
  78. ifneq ($(strip $(TARGET_NO_KERNEL)),true)
  79. INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
  80. else
  81. INSTALLED_KERNEL_TARGET :=
  82. endif
  83.  
  84. HYBRIS_BOOTIMAGE_ARGS := \
  85. $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
  86. --kernel $(INSTALLED_KERNEL_TARGET)
  87.  
  88. ifdef BOARD_KERNEL_SEPARATED_DT
  89. HYBRIS_BOOTIMAGE_ARGS += --dt $(INSTALLED_DTIMAGE_TARGET)
  90. endif
  91.  
  92. ifdef BOARD_KERNEL_BASE
  93. HYBRIS_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
  94. endif
  95.  
  96. ifdef BOARD_KERNEL_PAGESIZE
  97. HYBRIS_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
  98. endif
  99.  
  100. # Specify the BOOT/RECOVERY vars here as they're not impacted by
  101. # CLEAR_VARS and it makes it easier to keep them consistent.
  102.  
  103. HYBRIS_RECOVERYIMAGE_ARGS := $(HYBRIS_BOOTIMAGE_ARGS)
  104.  
  105. # Strip lead/trail " from broken BOARD_KERNEL_CMDLINEs :(
  106. HYBRIS_BOARD_KERNEL_CMDLINE := $(shell echo '$(BOARD_KERNEL_CMDLINE)' | sed -e 's/^"//' -e 's/"$$//')
  107.  
  108. ifneq "" "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_BOOTIMG_COMMANDLINE))"
  109. HYBRIS_BOOTIMAGE_ARGS += --cmdline "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_BOOTIMG_COMMANDLINE))"
  110. endif
  111.  
  112. ifneq "" "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_RECOVERYIMG_COMMANDLINE))"
  113. HYBRIS_RECOVERYIMAGE_ARGS += --cmdline "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_RECOVERYIMG_COMMANDLINE))"
  114. endif
  115.  
  116.  
  117. include $(CLEAR_VARS)
  118. LOCAL_MODULE:= hybris-boot
  119. # Here we'd normally include $(BUILD_SHARED_LIBRARY) or something
  120. # but nothing seems suitable for making an img like this
  121. LOCAL_MODULE_CLASS := ROOT
  122. LOCAL_MODULE_SUFFIX := .img
  123. LOCAL_MODULE_PATH := $(PRODUCT_OUT)
  124.  
  125. include $(BUILD_SYSTEM)/base_rules.mk
  126. BOOT_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
  127.  
  128. BOOT_RAMDISK := $(BOOT_INTERMEDIATE)/boot-initramfs.gz
  129. BOOT_RAMDISK_SRC := $(LOCAL_PATH)/initramfs
  130. BOOT_RAMDISK_INIT_SRC := $(LOCAL_PATH)/init-script
  131. BOOT_RAMDISK_INIT := $(BOOT_INTERMEDIATE)/init
  132. BOOT_RAMDISK_FILES := $(shell find $(BOOT_RAMDISK_SRC) -type f) $(BOOT_RAMDISK_INIT)
  133.  
  134. $(LOCAL_BUILT_MODULE): $(INSTALLED_KERNEL_TARGET) $(BOOT_RAMDISK) $(MKBOOTIMG)
  135. @echo "Making hybris-boot.img in $(dir $@) using $(INSTALLED_KERNEL_TARGET) $(BOOT_RAMDISK)"
  136. @mkdir -p $(dir $@)
  137. @rm -rf $@
  138. $(hide)$(MKBOOTIMG) --ramdisk $(BOOT_RAMDISK) $(HYBRIS_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
  139.  
  140. $(BOOT_RAMDISK): $(BOOT_RAMDISK_FILES) $(BB_STATIC)
  141. @echo "Making initramfs : $@"
  142. @rm -rf $(BOOT_INTERMEDIATE)/initramfs
  143. @mkdir -p $(BOOT_INTERMEDIATE)/initramfs
  144. @cp -a $(BOOT_RAMDISK_SRC)/* $(BOOT_INTERMEDIATE)/initramfs
  145. # Deliberately do an mv to force rebuild of init every time since it's
  146. # really hard to depend on things which may affect init.
  147. @mv $(BOOT_RAMDISK_INIT) $(BOOT_INTERMEDIATE)/initramfs/init
  148. @cp $(BB_STATIC) $(BOOT_INTERMEDIATE)/initramfs/bin/
  149. @(cd $(BOOT_INTERMEDIATE)/initramfs && find . | cpio -H newc -o ) | gzip -9 > $@
  150.  
  151. $(BOOT_RAMDISK_INIT): $(BOOT_RAMDISK_INIT_SRC) $(ALL_PREBUILT)
  152. @mkdir -p $(dir $@)
  153. @sed -e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
  154. -e 's %BOOTLOGO% $(HYBRIS_BOOTLOGO) g' \
  155. -e 's %DEFAULT_OS% $(HYBRIS_B_DEFAULT_OS) g' \
  156. -e 's %ALWAYSDEBUG% $(HYBRIS_B_ALWAYSDEBUG) g' $(BOOT_RAMDISK_INIT_SRC) > $@
  157. $(HYBRIS_FIXUP_MOUNTS) "$(TARGET_DEVICE)" "$@"
  158. @chmod +x $@
  159.  
  160. ################################################################
  161.  
  162. include $(CLEAR_VARS)
  163. LOCAL_MODULE:= hybris-recovery
  164. LOCAL_MODULE_CLASS := ROOT
  165. LOCAL_MODULE_SUFFIX := .img
  166. LOCAL_MODULE_PATH := $(PRODUCT_OUT)
  167.  
  168. include $(BUILD_SYSTEM)/base_rules.mk
  169. RECOVERY_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
  170.  
  171. RECOVERY_RAMDISK := $(RECOVERY_INTERMEDIATE)/recovery-initramfs.gz
  172. RECOVERY_RAMDISK_SRC := $(LOCAL_PATH)/initramfs
  173. RECOVERY_RAMDISK_INIT_SRC := $(LOCAL_PATH)/init-script
  174. RECOVERY_RAMDISK_INIT := $(RECOVERY_INTERMEDIATE)/init
  175. RECOVERY_RAMDISK_FILES := $(shell find $(RECOVERY_RAMDISK_SRC) -type f) $(RECOVERY_RAMDISK_INIT)
  176.  
  177. $(LOCAL_BUILT_MODULE): $(INSTALLED_KERNEL_TARGET) $(RECOVERY_RAMDISK) $(MKBOOTIMG)
  178. @echo "Making hybris-recovery.img in $(dir $@) using $(INSTALLED_KERNEL_TARGET) $(RECOVERY_RAMDISK)"
  179. @mkdir -p $(dir $@)
  180. @rm -rf $@
  181. $(hide)$(MKBOOTIMG) --ramdisk $(RECOVERY_RAMDISK) $(HYBRIS_RECOVERYIMAGE_ARGS) $(BOARD_MKRECOVERYIMG_ARGS) --output $@
  182.  
  183. $(RECOVERY_RAMDISK): $(RECOVERY_RAMDISK_FILES) $(BB_STATIC)
  184. @echo "Making initramfs : $@"
  185. @rm -rf $(RECOVERY_INTERMEDIATE)/initramfs
  186. @mkdir -p $(RECOVERY_INTERMEDIATE)/initramfs
  187. @cp -a $(RECOVERY_RAMDISK_SRC)/* $(RECOVERY_INTERMEDIATE)/initramfs
  188. @mv $(RECOVERY_RAMDISK_INIT) $(RECOVERY_INTERMEDIATE)/initramfs/init
  189. @cp $(BB_STATIC) $(RECOVERY_INTERMEDIATE)/initramfs/bin/
  190. @(cd $(RECOVERY_INTERMEDIATE)/initramfs && find . | cpio -H newc -o ) | gzip -9 > $@
  191.  
  192. $(RECOVERY_RAMDISK_INIT): $(RECOVERY_RAMDISK_INIT_SRC) $(ALL_PREBUILT)
  193. @mkdir -p $(dir $@)
  194. @sed -e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
  195. -e 's %BOOTLOGO% $(HYBRIS_BOOTLOGO) g' \
  196. -e 's %DEFAULT_OS% $(HYBRIS_R_DEFAULT_OS) g' \
  197. -e 's %ALWAYSDEBUG% $(HYBRIS_R_ALWAYSDEBUG) g' $(RECOVERY_RAMDISK_INIT_SRC) > $@
  198. $(HYBRIS_FIXUP_MOUNTS) "$(TARGET_DEVICE)" "$@"
  199. @chmod +x $@
  200.  
  201.  
  202. ################################################################
  203. include $(CLEAR_VARS)
  204. LOCAL_MODULE := hybris-updater-script
  205. LOCAL_MODULE_CLASS := ROOT
  206. LOCAL_MODULE_PATH := $(PRODUCT_OUT)
  207.  
  208. include $(BUILD_SYSTEM)/base_rules.mk
  209. UPDATER_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
  210.  
  211. UPDATER_SCRIPT_SRC := $(LOCAL_PATH)/updater-script
  212.  
  213. ANDROID_VERSION_MAJOR := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
  214. ANDROID_VERSION_MINOR := $(word 2, $(subst ., , $(PLATFORM_VERSION)))
  215.  
  216. USE_SET_METADATA := $(shell test $(ANDROID_VERSION_MAJOR) -eq 4 -a $(ANDROID_VERSION_MINOR) -ge 4 -o $(ANDROID_VERSION_MAJOR) -ge 5 && echo true)
  217.  
  218. ifeq ($(USE_SET_METADATA),true)
  219. SET_PERMISSIONS := set_metadata("/tmp/updater-unpack.sh", "uid", 0, "gid", 0, "mode", 0755);
  220. else
  221. SET_PERMISSIONS := set_perm(0, 0, 755, "/tmp/updater-unpack.sh");
  222. endif
  223.  
  224. $(LOCAL_BUILT_MODULE): $(UPDATER_SCRIPT_SRC)
  225. @echo "Installing updater .zip script resources."
  226. mkdir -p $(dir $@)
  227. rm -rf $@
  228. @sed -e 's %DEVICE% $(TARGET_DEVICE) g' \
  229. -e 's %BOOT_PART% $(HYBRIS_BOOT_PART) g' \
  230. -e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
  231. -e 's|%SET_PERMISSIONS%|$(SET_PERMISSIONS)|' \
  232. $(UPDATER_SCRIPT_SRC) > $@
  233.  
  234. HYBRIS_UPDATER_SCRIPT := $(LOCAL_BUILD_MODULE)
  235.  
  236. #---------------------------------------------------------------
  237. include $(CLEAR_VARS)
  238. LOCAL_MODULE := hybris-updater-unpack
  239. LOCAL_MODULE_CLASS := ROOT
  240. LOCAL_MODULE_SUFFIX := .sh
  241. LOCAL_MODULE_PATH := $(PRODUCT_OUT)
  242.  
  243. include $(BUILD_SYSTEM)/base_rules.mk
  244. UPDATER_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
  245.  
  246. UPDATER_UNPACK_SRC := $(LOCAL_PATH)/updater-unpack.sh
  247.  
  248. $(LOCAL_BUILT_MODULE): $(UPDATER_UNPACK_SRC)
  249. @echo "Installing updater .zip script resources."
  250. mkdir -p $(dir $@)
  251. rm -rf $@
  252. @sed -e 's %DEVICE% $(TARGET_DEVICET) g' \
  253. $(UPDATER_UNPACK_SRC) > $@
  254.  
  255. HYBRIS_UPDATER_UNPACK := $(LOCAL_BUILD_MODULE)
  256.  
  257.  
  258. .PHONY: hybris-hal
  259. hybris-hal: bootimage hybris-updater-unpack hybris-updater-script hybris-recovery hybris-boot linker init libc adb adbd libEGL libGLESv1_CM libGLESv2 servicemanager logcat updater
RAW Paste Data