时间有限,格式未调整,见谅。
编译的问题主要参考
谢谢原作者。
展开源码,用AOSP的bionic目录替换(gingerbread)的bionic
删除bootable/diskinstaller,拷贝froyo-x86的newinstaller到bootable目录下;拷贝gingerbread的bootable/diskinstaller/libdiskconfig目录到bootable/newinstaller目录下
修改build/core/Makefile,注释掉bootable/diskinstaller/config.mk的引用
链接froyo-x86的kernel;cd /work/gb; ln -sf /work/x86/kernel/ .
将x86/build/core/kernel.mk拷贝过来,并include在build/core/Makefile中
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot p_w_picpath: $@")
$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
$(hide) $(call assert-max-p_w_picpath-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
endif # TARGET_BOOTIMAGE_USE_EXT2
include $(BUILD_SYSTEM)/kernel.mk
else # TARGET_NO_KERNEL
# HACK: The top-level targets depend on the bootp_w_picpath. Not all targets
# can produce a bootp_w_picpath, though, and emulator targets need the ramdisk
# instead. Fake it out by calling the ramdisk the bootp_w_picpath.
# TODO: make the emulator use bootp_w_picpaths, and make mkbootimg accept
# kernel-less inputs.
INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
endif
将froyo_x86的device/vm拷贝到device目录下,在AndroidBoard.mk中注释掉TARGET_PREBUILT_APPS
将build/core/target/board/generic_x86下面的buildspec*拷贝到根目录的buildspec.mk并修改BUILD_ENV_SEQUENCE_NUMBER为10
编译环境设置(每次编译前不要忘记lunch vm-eng以防止编译错误目标)
carl@carl-amd64:/work/gb$ . build/envsetup.sh
including device/htc/passion/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
including device/vm/vm/vendorsetup.sh
carl@carl-amd64:/work/gb$ lunch vm-eng
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.1
TARGET_PRODUCT=vm
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================
将下面两行加入build/target/product/generic_x86.mk末尾
GENERIC_X86_CONFIG_MK := $(SRC_TARGET_DIR)/board/generic_x86/BoardConfig.mk
GENERIC_X86_ANDROID_MK := $(SRC_TARGET_DIR)/board/generic_x86/AndroidBoard.mk
开始编译内核
carl@carl-amd64:/work/gb$ m -j3 kernel
消除LOCAL_MODULE_TAGS的问题(external/grub),设置LOCAL_MODULE_TAGS := optional
build/core/base_rules.mk:74: *** Module name: grub_stage1
build/core/base_rules.mk:75: *** Makefile location: external/grub
build/core/base_rules.mk:76: *
build/core/base_rules.mk:77: * Each module must use a LOCAL_MODULE_TAGS in its
build/core/base_rules.mk:78: * Android.mk. Possible tags declared by a module:
build/core/base_rules.mk:79: *
build/core/base_rules.mk:80: * optional, debug, eng, tests, samples
build/core/base_rules.mk:81: *
build/core/base_rules.mk:82: * If the module is expected to be in all builds
build/core/base_rules.mk:83: * of a product, then it should use the
build/core/base_rules.mk:84: * "optional" tag:
build/core/base_rules.mk:85: *
build/core/base_rules.mk:86: * Add "LOCAL_MODULE_TAGS := optional" in the
build/core/base_rules.mk:87: * Android.mk for the affected module, and add
build/core/base_rules.mk:88: * the LOCAL_MODULE value for that component
build/core/base_rules.mk:89: * into the PRODUCT_PACKAGES section of product
build/core/base_rules.mk:90: * makefile(s) where it's necessary, if
build/core/base_rules.mk:91: * appropriate.
build/core/base_rules.mk:92: *
build/core/base_rules.mk:93: * If the component should be in EVERY build of ALL
build/core/base_rules.mk:94: * products, then add its LOCAL_MODULE value to the
build/core/base_rules.mk:95: * PRODUCT_PACKAGES section of
build/core/base_rules.mk:96: * build/target/product/core.mk
build/core/base_rules.mk:97: *
build/core/base_rules.mk:98: *** user tag detected on new module - user tags are only supported on legacy modules. Stop.
make: Leaving directory `/work/gb'
去掉多余的libdiskconfig目标
build/core/base_rules.mk:158: *** bootable/newinstaller/libdiskconfig: MODULE.TARGET.SHARED_LIBRARIES.libdiskconfig already defined by system/core/libdiskconfig. Stop.
注释掉bootable/newinstaller/libdiskconfig/Android.mk中libdiskconfig相关代码
###########################
# shared library for target
#include $(CLEAR_VARS)
#LOCAL_SRC_FILES := $(commonSources)
#LOCAL_CFLAGS := -O2 -g -W -Wall -Werror
#LOCAL_MODULE := libdiskconfig
#LOCAL_MODULE_TAGS := system_builder
#LOCAL_SYSTEM_SHARED_LIBRARIES := libcutils liblog libc
#include $(BUILD_SHARED_LIBRARY)
将编译好的kernel拷贝到prebuilt下相应目录
carl@carl-amd64:/work/gb$ cp device/vm/vm/vm_defconfig prebuilt/android-x86/kernel/kernel_config_VirtualBox
carl@carl-amd64:/work/gb$ cp out/target/product/vm/kernel /work/gb/prebuilt/android-x86/kernel/kernel
开始全编译
carl@carl-amd64:/work/gb$ m -j3
stlport的问题解决
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_nan_or_inf(double)':
external/stlport/src/num_put_float.cpp:143: error: 'IsNANorINF' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_inf(double)':
external/stlport/src/num_put_float.cpp:144: error: 'IsNANorINF' was not declared in this scope
external/stlport/src/num_put_float.cpp:144: error: 'IsINF' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_neg_inf(double)':
external/stlport/src/num_put_float.cpp:145: error: 'IsINF' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_neg_nan(double)':
external/stlport/src/num_put_float.cpp:146: error: 'IsNegNAN' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_ecvtR(double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:280: error: 'ecvt_r' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_fcvtR(double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:282: error: 'fcvt_r' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_ecvtR(long double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:285: error: 'qecvt_r' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_fcvtR(long double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:287: error: 'qfcvt_r' was not declared in this scope
target thumb C++: libstlport <= external/stlport/src/time_facets.cpp
make: *** [out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/num_put_float.o] Error 1
编辑external/stlport/Android.mk修改libstlport_cflags := -D_GNU_SOURCE -DUSE_SPRINTF_INSTEAD
bitwise.c的问题解决
In file included from external/tremolo/Tremolo/bitwise.c:43:
external/tremolo/Tremolo/misc.h:82: error: redefinition of 'union magic'
In file included from external/tremolo/Tremolo/codebook.c:45:
external/tremolo/Tremolo/misc.h:82: error: redefinition of 'union magic'
make: *** [out/target/product/vm/obj/SHARED_LIBRARIES/libvorbisidec_intermediates/Tremolo/bitwise.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from external/tremolo/Tremolo/mdct.h:42,
from external/tremolo/Tremolo/dsp.c:40:
external/tremolo/Tremolo/misc.h:82: error: redefinition of 'union magic'
external/tremolo/Tremolo/codebook.c: In function 'decode_map':
external/tremolo/Tremolo/codebook.c:763: warning: pointer of type 'void *' used in arithmetic
make: *** [out/target/product/vm/obj/SHARED_LIBRARIES/libvorbisidec_intermediates/Tremolo/codebook.o] Error 1
在external/tremolo/Tremolo/misc.h中加入
#include <endian.h>
__dso_handle的问题解决
external/stlport/src/monetary.cpp:39: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale.o: In function `__static_initialization_and_destruction_0':
external/stlport/src/locale.cpp:29: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function `__static_initialization_and_destruction_0':
external/stlport/src/locale_impl.cpp:31: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function `std::_Locale_impl::make_classic_locale()':
external/stlport/src/locale_impl.cpp:670: undefined reference to `__dso_handle'
external/stlport/src/locale_impl.cpp:667: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o:external/stlport/src/locale_impl.cpp:604: more undefined references to `__dso_handle' follow
collect2: ld returned 1 exit status
修改external/stlport/dll_main.cpp加入
extern "C" {
void * __dso_handle = 0;
}
dnsmasq的dbus引用问题解决
external/dnsmasq/src/dbus.c:21:23: error: dbus/dbus.h: No such file or directory
external/dnsmasq/src/dbus.c:60: error: expected specifier-qualifier-list before 'DBusWatch'
external/dnsmasq/src/dbus.c:65: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'add_watch'
external/dnsmasq/src/dbus.c:84: error: expected ')' before '*' token
external/dnsmasq/src/dbus.c:100: error: expected ')' before '*' token
external/dnsmasq/src/dbus.c:261: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'message_handler'
修改external/dnsmasq/src/config.h
/* #define HAVE_DBUS */
#ifdef __ANDROID__
#undef HAVE_DBUS
#endif
libnfc-nxp的问题解决
target arm C: libnfc <= external/libnfc-nxp/src/phLibNfc.c
cc1: error: unrecognized command line option "-mapcs"
cc1: error: unrecognized command line option "-mno-sched-prolog"
cc1: error: unrecognized command line option "-mabi=aapcs-linux"
cc1: error: unrecognized command line option "-mno-thumb-interwork"
修改external/libnfc-nxp/Android.mk将
LOCAL_CFLAGS += -DNXP_MESSAGING -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common –fpic
改为
LOCAL_CFLAGS += -DNXP_MESSAGING -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration -fno-strict-aliasing -msoft-float -Uarm -fno-common -fpic
in mkuserimg.sh PATH=out/host/linux-x86/bin/:/boot/jdk/bin:/home/carl/bin:/opt/android/tools:/opt/android/platform-tools:/opt/depot_tools:/boot/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/gb/out/host/linux-x86/bin:/work/gb/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:/work/gb/development/emulator/qtools:/work/gb/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:/work/gb/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
Only ext4 is supported!
修改各个p_w_picpath的文件系统支持
直接修改build/target/board/generic_x86/BoardConfig.mk
TARGET_USERIMAGES_USE_EXT4 := true
TARGET_BOOTIMAGE_USE_EXT2 := true
TARGET_SYSTEMIMAGES_USE_EXT2 := true
修改build/core/Makefile
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
## generate an ext2 p_w_picpath
# $(1): output file
define build-systemp_w_picpath-target
@echo "Target system fs p_w_picpath: $(1)"
$(call build-userp_w_picpath-ext-target, $(TARGET_OUT), $(1), system, $(INTERNAL_USERIMAGES_EXT_VARIANT), $(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
endef
改为
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
ifeq ($(TARGET_SYSTEMIMAGES_USE_EXT2),true)
-include external/genext2fs/Config.mk
## generate an ext2 p_w_picpath
# $(1): output file
define build-systemp_w_picpath-target
@echo "Target system fs p_w_picpath: $(1)"
$(call build-userp_w_picpath-ext2-target,$(TARGET_OUT),$(1),system,)
endef
else
define build-systemp_w_picpath-target
@echo "Target system fs p_w_picpath: $(1)"
$(call build-userp_w_picpath-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
endef
endif
完成后,可以直接
carl@carl-amd64:/work/gb$ export USE_SQUASHFS=0
carl@carl-amd64:/work/gb$ m -j3 iso_img
IAudioEffect.c的问题解决
out/target/product/vm/obj/SHARED_LIBRARIES/libOpenSLES_intermediates/IAndroidEffect.o:(.data.rel.ro._ZTIN7android12SortedVectorINS_16key_value_pair_tImPNS_11AudioEffectEEEEE[typeinfo for android::SortedVector<android::key_value_pair_t<unsigned long, android::AudioEffect*> >]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
out/target/product/vm/obj/SHARED_LIBRARIES/libOpenSLES_intermediates/IAndroidEffect.o:(.data.rel.ro._ZTIN7android12SortedVectorINS_16key_value_pair_tImPNS_11AudioEffectEEEEE[typeinfo for android::SortedVector<android::key_value_pair_t<unsigned long, android::AudioEffect*> >]+0x10): undefined reference to `typeinfo for android::SortedVectorImpl'
collect2: ld returned 1 exit status
将system/media/opensles/libopensles/IAndroidEffect.c换名IAndroidEffect.cpp并更新Android.mk文件
init.rc不执行拷贝的问题
在build/target/board/generic_x86/AndroidBoard.mk中指定的init.rc模块,无论如何设置都不会执行拷贝,这是由于新版本的build system脚本调整导致的麻烦,需要强制在definitions.mk中指定安装init.rc模块。
ifeq ($(TARGET_PROVIDES_INIT_RC), true)
ALL_DEFAULT_INSTALLED_MODULES:=init.rc
else
ALL_DEFAULT_INSTALLED_MODULES:=
endif
SQUASHFS生成目标的支持问题
froyo-x86默认是生成SQUASHFS,如下修改bootable/newinstaller/Android.mk为默认不生成SQUASHFS;如果需要设置生成SQUASHFS,只需要在make前export USE_SQUASHFS=1
# use squashfs for iso, unless explictly disabled
ifeq ($(USE_SQUASHFS),1)
MKSQUASHFS = $(shell which mksquashfs)
在Makefile中集成system.sfs目标
$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
@echo "Install system fs p_w_picpath: $@"
$(copy-file-to-target)
$(hide) $(call assert-max-p_w_picpath-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
ifneq ($(MKSQUASHFS),)
$(PRODUCT_OUT)/system.sfs: $(BUILT_SYSTEMIMAGE)
$(call build-squashfs-target,$^,$@)
endif
systemp_w_picpath: $(INSTALLED_SYSTEMIMAGE)
init.rc的定制问题
Gingerbread修改了system/core/init模块的代码,init.rc的支持也变得更加强大。
init.rc需要根据不同平台来进行定制,否则在chroot到android后会出现严重问题。
基本思路是基于Android原生的init.rc修改,添加文件系统mount的指令,添加eth0启动时支持。
BOARD_KERNEL_CMDLINE的问题
由于没有使用diskinstaller,所以build/target/board/generic-x86/BoardConfig.mk中KERNEL_CMDLINE如下修改
# For VirtualBox and likely other emulators
#BOARD_INSTALLER_CMDLINE := init=/init console=ttyS0 console=tty0 androidboot.hardware=generic_x86 vga=788 verbose
#BOARD_KERNEL_CMDLINE := init=/init console=tty0 console=ttyS0 androidboot.hardware=generic_x86 vga=788
BOARD_KERNEL_CMDLINE := init=/init console=tty0 androidboot.hardware=$(TARGET_PRODUCT) acpi_sleep=s3_bios,s3_mode vga=788