1 # Copyright 2009-2014, The Android-x86 Open Source Project
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 ifneq ($(filter x86%,$(TARGET_ARCH)),)
16 LOCAL_PATH := $(call my-dir)
19 VER ?= $(shell date +"%F")
21 LOCAL_MODULE := newinstaller
22 LOCAL_MODULE_TAGS := system_builder
24 # use squashfs for iso, unless explictly disabled
25 ifneq ($(USE_SQUASHFS),0)
26 MKSQUASHFS = $(shell which mksquashfs)
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
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 { \
39 label="liveh"; dpi="HDPI"; \
41 label="livem"; dpi="MDPI"; \
44 if (match($$2, label)) \
46 else if (match($$0, dpi)) \
50 for (i = 0; i < s; ++i) \
52 gsub(" DPI=[0-9]*",""); print $$0; \
53 }' $(1) > $(1)_ && mv $(1)_ $(1) )
56 initrd_dir := $(LOCAL_PATH)/initrd
59 $(wildcard $(initrd_dir)/*/*)
61 systemimg := $(PRODUCT_OUT)/system.$(if $(MKSQUASHFS),sfs,img)
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 > $@
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 > $@
78 boot_dir := $(PRODUCT_OUT)/boot
79 $(boot_dir): $(wildcard $(LOCAL_PATH)/boot/isolinux/*) $(systemimg) $(GENERIC_X86_CONFIG_MK) | $(ACP)
81 $(ACP) -pr $(dir $(<D)) $@
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)
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"
97 .PHONY: iso_img usb_img