OSDN Git Service

Merge remote-tracking branch 'x86/kitkat-x86' into lollipop-x86
[android-x86/bootable-newinstaller.git] / Android.mk
1 # Copyright 2009-2014, The Android-x86 Open Source Project
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 ifneq ($(filter x86%,$(TARGET_ARCH)),)
16 LOCAL_PATH := $(call my-dir)
17 include $(CLEAR_VARS)
18
19 VER ?= $(shell date +"%F")
20
21 LOCAL_MODULE := newinstaller
22 LOCAL_MODULE_TAGS := system_builder
23
24 # use squashfs for iso, unless explictly disabled
25 ifneq ($(USE_SQUASHFS),0)
26 MKSQUASHFS = $(shell which mksquashfs)
27
28 define build-squashfs-target
29         $(if $(shell $(MKSQUASHFS) -version | grep "version [0-3].[0-9]"),\
30                 $(error Your mksquashfs is too old to work with kernel 2.6.29. Please upgrade to squashfs-tools 4.0))
31         $(hide) $(MKSQUASHFS) $(1) $(2) -noappend
32 endef
33 endif
34
35 define check-density
36         eval d=$$(grep ^ro.sf.lcd_density $(INSTALLED_DEFAULT_PROP_TARGET) $(INSTALLED_BUILD_PROP_TARGET) | sed 's|\(.*\)=\(.*\)|\2|'); \
37         [ -z "$$d" ] || ( awk -v d=$$d ' BEGIN { \
38                 if (d <= 180) { \
39                         label="liveh"; dpi="HDPI"; \
40                 } else { \
41                         label="livem"; dpi="MDPI"; \
42                 } \
43         } { \
44                 if (match($$2, label)) \
45                         s=5; \
46                 else if (match($$0, dpi)) \
47                         s=4; \
48                 else \
49                         s=0; \
50                 for (i = 0; i < s; ++i) \
51                         getline; \
52                 gsub(" DPI=[0-9]*",""); print $$0; \
53         }' $(1) > $(1)_ && mv $(1)_ $(1) )
54 endef
55
56 initrd_dir := $(LOCAL_PATH)/initrd
57 initrd_bin := \
58         $(initrd_dir)/init \
59         $(wildcard $(initrd_dir)/*/*)
60
61 systemimg  := $(PRODUCT_OUT)/system.$(if $(MKSQUASHFS),sfs,img)
62
63 INITRD_RAMDISK := $(PRODUCT_OUT)/initrd.img
64 $(INITRD_RAMDISK): $(initrd_bin) $(systemimg) $(TARGET_INITRD_SCRIPTS) | $(ACP) $(MKBOOTFS)
65         rm -rf $(TARGET_INSTALLER_OUT)
66         $(ACP) -pr $(initrd_dir) $(TARGET_INSTALLER_OUT)
67         $(if $(TARGET_INITRD_SCRIPTS),$(ACP) -p $(TARGET_INITRD_SCRIPTS) $(TARGET_INSTALLER_OUT)/scripts)
68         ln -s /bin/ld-linux.so.2 $(TARGET_INSTALLER_OUT)/lib
69         mkdir -p $(addprefix $(TARGET_INSTALLER_OUT)/,android mnt proc sys tmp sfs hd)
70         echo "VER=$(VER)" > $(TARGET_INSTALLER_OUT)/scripts/00-ver
71         $(MKBOOTFS) $(TARGET_INSTALLER_OUT) | gzip -9 > $@
72
73 INSTALL_RAMDISK := $(PRODUCT_OUT)/install.img
74 $(INSTALL_RAMDISK): $(wildcard $(LOCAL_PATH)/install/*/*) | $(MKBOOTFS) $(TARGET_OUT_OPTIONAL_EXECUTABLES)/busybox
75         $(if $(TARGET_INSTALL_SCRIPTS),$(ACP) -p $(TARGET_INSTALL_SCRIPTS) $(TARGET_INSTALLER_OUT)/scripts)
76         $(MKBOOTFS) $(dir $(dir $(<D))) | gzip -9 > $@
77
78 boot_dir := $(PRODUCT_OUT)/boot
79 $(boot_dir): $(wildcard $(LOCAL_PATH)/boot/isolinux/*) $(systemimg) $(GENERIC_X86_CONFIG_MK) | $(ACP)
80         rm -rf $@
81         $(ACP) -pr $(dir $(<D)) $@
82
83 BUILT_IMG := $(addprefix $(PRODUCT_OUT)/,ramdisk.img initrd.img install.img) $(systemimg)
84 BUILT_IMG += $(if $(TARGET_PREBUILT_KERNEL),$(TARGET_PREBUILT_KERNEL),$(PRODUCT_OUT)/kernel)
85
86 ISO_IMAGE := $(PRODUCT_OUT)/$(TARGET_PRODUCT).iso
87 $(ISO_IMAGE): $(boot_dir) $(BUILT_IMG)
88         @echo ----- Making iso image ------
89         $(hide) $(call check-density,$</isolinux/isolinux.cfg)
90         $(hide) sed -i "s|\(Installation CD\)\(.*\)|\1 $(VER)|; s|CMDLINE|$(BOARD_KERNEL_CMDLINE)|" $</isolinux/isolinux.cfg
91         genisoimage -vJURT -b isolinux/isolinux.bin -c isolinux/boot.cat \
92                 -no-emul-boot -boot-load-size 4 -boot-info-table \
93                 -input-charset utf-8 -V "Android-x86 LiveCD" -o $@ $^
94         $(hide) isohybrid $@ || echo -e "isohybrid not found.\nInstall syslinux 4.0 or higher if you want to build a usb bootable iso."
95         @echo -e "\n\n$@ is built successfully.\n\n"
96
97 .PHONY: iso_img usb_img
98 iso_img: $(ISO_IMAGE)
99 usb_img: $(ISO_IMAGE)
100
101 endif