forked from Halium/halium-boot
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Android.mk
124 lines (104 loc) · 4.62 KB
/
Android.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#
# Copyright (C) 2014 Jolla Oy
# Copyright (C) 2017 Marius Gripsgard <marius@ubports.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH:= $(call my-dir)
HALIUM_PATH:=$(LOCAL_PATH)
# We use the commandline and kernel configuration varables from
# build/core/Makefile to be consistent. Support for boot/recovery
# image specific kernel COMMANDLINE vars is provided but whether it
# works or not is down to your bootloader.
HALIUM_BOOTIMG_COMMANDLINE :=
# Find any fstab files for required partition information.
# in AOSP we could use TARGET_VENDOR
# TARGET_VENDOR := $(shell echo $(PRODUCT_MANUFACTURER) | tr '[:upper:]' '[:lower:]')
# but Cyanogenmod seems to use device/*/$(TARGET_DEVICE) in config.mk so we will too.
HALIUM_FSTABS := $(shell find device/*/$(TARGET_DEVICE) -name *fstab* | grep -v goldfish)
# If fstab files were not found from primary device repo then they might be in
# some other device repo so try to search for them first in device/PRODUCT_MANUFACTURER.
# In many cases PRODUCT_MANUFACTURER is the short vendor name used in folder names.
ifeq "$(HALIUM_FSTABS)" ""
TARGET_VENDOR := "$(shell echo $(PRODUCT_MANUFACTURER) | tr '[:upper:]' '[:lower:]')"
HALIUM_FSTABS := $(shell find device/$(TARGET_VENDOR) -name *fstab* | grep -v goldfish)
endif
# Some devices devices have the short vendor name in PRODUCT_BRAND so try to
# search from device/PRODUCT_BRAND if fstab files are still not found.
ifeq "$(HALIUM_FSTABS)" ""
TARGET_VENDOR := "$(shell echo $(PRODUCT_BRAND) | tr '[:upper:]' '[:lower:]')"
HALIUM_FSTABS := $(shell find device/$(TARGET_VENDOR) -name *fstab* | grep -v goldfish)
endif
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
else
INSTALLED_KERNEL_TARGET :=
endif
HALIUM_BOOTIMAGE_ARGS := \
$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
--kernel $(INSTALLED_KERNEL_TARGET)
ifeq ($(BOARD_KERNEL_SEPARATED_DT),true)
INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img
HALIUM_BOOTIMAGE_ARGS += --dt $(INSTALLED_DTIMAGE_TARGET)
BOOTIMAGE_EXTRA_DEPS := $(INSTALLED_DTIMAGE_TARGET)
endif
ifdef BOARD_KERNEL_BASE
HALIUM_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
ifdef BOARD_KERNEL_PAGESIZE
HALIUM_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
# Strip lead/trail " from broken BOARD_KERNEL_CMDLINEs :(
HALIUM_BOARD_KERNEL_CMDLINE := $(shell echo '$(BOARD_KERNEL_CMDLINE)' | sed -e 's/^"//' -e 's/"$$//')
ifneq "" "$(strip $(HALIUM_BOARD_KERNEL_CMDLINE) $(HALIUM_BOOTIMG_COMMANDLINE))"
HALIUM_BOOTIMAGE_ARGS += --cmdline "$(strip $(HALIUM_BOARD_KERNEL_CMDLINE) $(HALIUM_BOOTIMG_COMMANDLINE))"
endif
HALIUM_BOOTIMAGE_ARGS += \
--os_version $(PLATFORM_VERSION) \
--os_patch_level $(PLATFORM_SECURITY_PATCH)
include $(CLEAR_VARS)
LOCAL_MODULE:= halium-boot
# Here we'd normally include $(BUILD_SHARED_LIBRARY) or something
# but nothing seems suitable for making an img like this
LOCAL_MODULE_CLASS := ROOT
LOCAL_MODULE_SUFFIX := .img
LOCAL_MODULE_PATH := $(PRODUCT_OUT)
include $(BUILD_SYSTEM)/base_rules.mk
HALIUM_BOOT_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
.PHONY: HALIUM_BOOT_RAMDISK
HALIUM_BOOT_RAMDISK := $(HALIUM_BOOT_INTERMEDIATE)/halium-initramfs.gz
GET_INITRD := $(LOCAL_PATH)/get-initrd.sh
$(LOCAL_BUILT_MODULE): $(INSTALLED_KERNEL_TARGET) $(HALIUM_BOOT_RAMDISK) $(BOOTIMAGE_EXTRA_DEPS)
@echo "Making halium-boot.img in $(dir $@) using $(INSTALLED_KERNEL_TARGET) $(HALIUM_BOOT_RAMDISK)"
@mkdir -p $(dir $@)
@rm -rf $@
ifeq ($(BOARD_CUSTOM_MKBOOTIMG),pack_intel)
$(MKBOOTIMG) $(DEVICE_BASE_BOOT_IMAGE) $(INSTALLED_KERNEL_TARGET) $(HALIUM_BOOT_RAMDISK) $(cmdline) $@
else
@mkbootimg --ramdisk $(HALIUM_BOOT_RAMDISK) $(HALIUM_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
endif
ifdef BOOT_RAMDISK_SEANDROIDENFORCE
@echo -n "SEANDROIDENFORCE" >> $@
endif
$(HALIUM_BOOT_RAMDISK):
@mkdir -p $(dir $@)
@echo "Downloading initramfs to : $@"
ifdef BOARD_USE_LOCAL_INITRD
@echo "Using local initramfs at device/*/$(TARGET_DEVICE)/initramfs.gz"
@cp device/*/$(TARGET_DEVICE)/initramfs.gz $@
else
@$(GET_INITRD) ${TARGET_ARCH} $@
endif
.PHONY: halium-common
halium-boot: mkbootimg
halium-common: bootimage halium-boot