OSDN Git Service

Merge remote-tracking branch 'x86/nougat-x86' into oreo-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
18 include $(CLEAR_VARS)
19 LOCAL_IS_HOST_MODULE := true
20 LOCAL_SRC_FILES := rpm/qemu-android
21 LOCAL_MODULE := $(notdir $(LOCAL_SRC_FILES))
22 LOCAL_MODULE_TAGS := debug
23 LOCAL_MODULE_CLASS := EXECUTABLES
24 LOCAL_POST_INSTALL_CMD := $(hide) sed -i "s|CMDLINE|$(BOARD_KERNEL_CMDLINE)|" $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)
25 include $(BUILD_PREBUILT)
26
27 VER ?= $$(date +"%F")
28
29 # use squashfs for iso, unless explictly disabled
30 ifneq ($(USE_SQUASHFS),0)
31 MKSQUASHFS := $(MAKE_SQUASHFS)
32
33 define build-squashfs-target
34         $(hide) $(MKSQUASHFS) $(1) $(2) -noappend -comp gzip
35 endef
36 endif
37
38 initrd_dir := $(LOCAL_PATH)/initrd
39 initrd_bin := \
40         $(initrd_dir)/init \
41         $(wildcard $(initrd_dir)/*/*)
42
43 systemimg  := $(PRODUCT_OUT)/system.$(if $(MKSQUASHFS),sfs,img)
44
45 TARGET_INITRD_OUT := $(PRODUCT_OUT)/initrd
46 INITRD_RAMDISK := $(TARGET_INITRD_OUT).img
47 $(INITRD_RAMDISK): $(initrd_bin) $(systemimg) $(TARGET_INITRD_SCRIPTS) | $(ACP) $(MKBOOTFS)
48         $(hide) rm -rf $(TARGET_INITRD_OUT)
49         mkdir -p $(addprefix $(TARGET_INITRD_OUT)/,android hd iso lib mnt proc scripts sfs sys tmp)
50         $(if $(TARGET_INITRD_SCRIPTS),$(ACP) -p $(TARGET_INITRD_SCRIPTS) $(TARGET_INITRD_OUT)/scripts)
51         ln -s /bin/ld-linux.so.2 $(TARGET_INITRD_OUT)/lib
52         echo "VER=$(VER)" > $(TARGET_INITRD_OUT)/scripts/00-ver
53         $(if $(RELEASE_OS_TITLE),echo "OS_TITLE=$(RELEASE_OS_TITLE)" >> $(TARGET_INITRD_OUT)/scripts/00-ver)
54         $(if $(INSTALL_PREFIX),echo "INSTALL_PREFIX=$(INSTALL_PREFIX)" >> $(TARGET_INITRD_OUT)/scripts/00-ver)
55         $(MKBOOTFS) $(<D) $(TARGET_INITRD_OUT) | gzip -9 > $@
56
57 INSTALL_RAMDISK := $(PRODUCT_OUT)/install.img
58 INSTALLER_BIN := $(TARGET_INSTALLER_OUT)/sbin/efibootmgr
59 $(INSTALL_RAMDISK): $(wildcard $(LOCAL_PATH)/install/*/* $(LOCAL_PATH)/install/*/*/*/*) $(INSTALLER_BIN) | $(MKBOOTFS)
60         $(if $(TARGET_INSTALL_SCRIPTS),mkdir -p $(TARGET_INSTALLER_OUT)/scripts; $(ACP) -p $(TARGET_INSTALL_SCRIPTS) $(TARGET_INSTALLER_OUT)/scripts)
61         $(MKBOOTFS) $(dir $(dir $(<D))) $(TARGET_INSTALLER_OUT) | gzip -9 > $@
62
63 isolinux_files := $(addprefix external/syslinux/bios/com32/, \
64         ../core/isolinux.bin \
65         chain/chain.c32 \
66         elflink/ldlinux/ldlinux.c32 \
67         lib/libcom32.c32 \
68         libutil/libutil.c32 \
69         menu/vesamenu.c32)
70
71 boot_dir := $(PRODUCT_OUT)/boot
72 $(boot_dir): $(shell find $(LOCAL_PATH)/boot -type f | sort -r) $(isolinux_files) $(systemimg) $(INSTALL_RAMDISK) $(GENERIC_X86_CONFIG_MK) | $(ACP)
73         $(hide) rm -rf $@
74         $(ACP) -pr $(dir $(<D)) $@
75         $(ACP) -pr $(dir $(<D))../install/grub2/efi $@
76         $(ACP) $(isolinux_files) $@/isolinux
77         img=$@/boot/grub/efi.img; dd if=/dev/zero of=$$img bs=1M count=4; \
78         mkdosfs -n EFI $$img; mmd -i $$img ::boot; \
79         mcopy -si $$img $@/efi ::; mdel -i $$img ::efi/boot/*.cfg
80
81 BUILT_IMG := $(addprefix $(PRODUCT_OUT)/,ramdisk.img initrd.img install.img) $(systemimg)
82 BUILT_IMG += $(if $(TARGET_PREBUILT_KERNEL),$(TARGET_PREBUILT_KERNEL),$(PRODUCT_OUT)/kernel)
83
84 GENISOIMG := $(if $(shell which xorriso 2> /dev/null),xorriso -as mkisofs,genisoimage)
85 ISO_IMAGE := $(PRODUCT_OUT)/$(TARGET_PRODUCT).iso
86 ISOHYBRID := LD_LIBRARY_PATH=$(LOCAL_PATH)/install/lib external/syslinux/bios/utils/isohybrid
87 $(ISO_IMAGE): $(boot_dir) $(BUILT_IMG)
88         @echo ----- Making iso image ------
89         $(hide) sed -i "s|\(Installation CD\)\(.*\)|\1 $(VER)|; s|CMDLINE|$(BOARD_KERNEL_CMDLINE)|" $</isolinux/isolinux.cfg
90         $(hide) sed -i "s|VER|$(VER)|; s|CMDLINE|$(BOARD_KERNEL_CMDLINE)|" $</efi/boot/android.cfg
91         sed -i "s|OS_TITLE|$(if $(RELEASE_OS_TITLE),$(RELEASE_OS_TITLE),Android-x86)|" $</isolinux/isolinux.cfg $</efi/boot/android.cfg
92         $(GENISOIMG) -vJURT -b isolinux/isolinux.bin -c isolinux/boot.cat \
93                 -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot \
94                 -input-charset utf-8 -V "$(if $(RELEASE_OS_TITLE),$(RELEASE_OS_TITLE),Android-x86) $(VER) ($(TARGET_ARCH))" -o $@ $^
95         $(hide) $(ISOHYBRID) --uefi $@
96         @echo -e "\n\n$@ is built successfully.\n\n"
97
98 rpm: $(wildcard $(LOCAL_PATH)/rpm/*) $(BUILT_IMG)
99         @echo ----- Making an rpm ------
100         OUT=$(abspath $(PRODUCT_OUT)); mkdir -p $$OUT/rpm/BUILD; rm -rf $$OUT/rpm/RPMS/*; $(ACP) $< $$OUT; \
101         echo $(VER) | grep -vq rc; EPOCH=$$((-$$? + `echo $(VER) | cut -d. -f1`)); \
102         rpmbuild -bb --target=$(if $(filter x86,$(TARGET_ARCH)),i686,x86_64) -D"cmdline $(BOARD_KERNEL_CMDLINE)" \
103                 -D"_topdir $$OUT/rpm" -D"_sourcedir $$OUT" -D"systemimg $(notdir $(systemimg))" -D"ver $(VER)" -D"epoch $$EPOCH" \
104                 $(if $(BUILD_NAME_VARIANT),-D"name $(BUILD_NAME_VARIANT)") \
105                 -D"install_prefix $(if $(INSTALL_PREFIX),$(INSTALL_PREFIX),android-$(VER))" $(filter %.spec,$^); \
106         mv $$OUT/rpm/RPMS/*/*.rpm $$OUT
107
108 .PHONY: iso_img usb_img efi_img rpm
109 iso_img: $(ISO_IMAGE)
110 usb_img: $(ISO_IMAGE)
111 efi_img: $(ISO_IMAGE)
112
113 endif