2011年1月21日 星期五

在 32 位元的 Ubuntu 編譯 Android 2.3 (Gingerbread)

前陣子 Google 公佈了 Android 2.3 (Gingerbread) 的原始碼後,相信也有不少人開始試著將它移植到自己手邊的一些板子上。

這幾天下載了 Gingerbread 的原始碼,也試著先在 Ubuntu 9.04 上編譯看看,但卻得到以下這個訊息:

Only 64-bit build environments are supported beyond froyo/2.2

呀!於是我裝了個 64 位元的 Ubuntu 10.10,並試著編譯確認下載的原始碼可以成功被編譯。這兩天試著翻找了一下,稍微修改了幾個地方,並且確認在 32 位元的 Ubuntu 10.04 可以編譯成功。

所以,如果要在 32 位元的 Ubuntu 編譯 Gingerbread,大概要修改的地方如下:

diff -Nur old/build/core/main.mk new/build/core/main.mk --- old/build/core/main.mk 2011-01-21 01:56:42.336200023 +0800
+++ new/build/core/main.mk 2011-01-21 02:00:23.515155033 +0800
@@ -72,10 +72,11 @@

ifeq ($(BUILD_OS),linux)
build_arch := $(shell uname -m)
-ifneq (64,$(findstring 64,$(build_arch)))
+ifneq (i686,$(findstring i686,$(build_arch)))
$(warning ************************************************************)
-$(warning You are attempting to build on a 32-bit system.)
+$(warning You are attempting to build on a 64-bit system.)
$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
+$(warning But I still try to build on a 32-bit system.)
$(warning ************************************************************)
$(error stop)
endif
diff -Nur old/external/wpa_supplicant_6/wpa_supplicant/Android.mk new/external/wpa_supplicant_6/wpa_supplicant/Android.mk
--- old/external/wpa_supplicant_6/wpa_supplicant/Android.mk 2011-01-21 10:42:27.403764488 +0800
+++ new/external/wpa_supplicant_6/wpa_supplicant/Android.mk 2011-01-21 10:42:59.167242863 +0800
@@ -249,9 +249,9 @@
endif

ifdef CONFIG_DRIVER_PS3
-L_CFLAGS += -DCONFIG_DRIVER_PS3 -m64
+L_CFLAGS += -DCONFIG_DRIVER_PS3 -m32
OBJS_d += src/drivers/driver_ps3.c
-LDFLAGS += -m64
+LDFLAGS += -m32
endif

ifdef CONFIG_DRIVER_IPHONE
diff -Nur old/external/clearsilver/java-jni/Android.mk new/external/clearsilver/java-jni/Android.mk
--- old/external/clearsilver/java-jni/Android.mk 2011-01-21 10:43:06.469155531 +0800
+++ new/external/clearsilver/java-jni/Android.mk 2011-01-21 10:45:43.911803822 +0800
@@ -33,9 +33,9 @@

LOCAL_CFLAGS += -fPIC

-# This forces a 64-bit build for Java6
-LOCAL_CFLAGS += -m64
-LOCAL_LDFLAGS += -m64
+# This forces a 32-bit build for Java6
+LOCAL_CFLAGS += -m32
+LOCAL_LDFLAGS += -m32

LOCAL_NO_DEFAULT_COMPILER_FLAGS := true

diff -Nur old/external/clearsilver/cs/Android.mk new/external/clearsilver/cs/Android.mk
--- old/external/clearsilver/cs/Android.mk 2011-01-21 10:43:39.529054212 +0800
+++ new/external/clearsilver/cs/Android.mk 2011-01-21 10:45:55.135643624 +0800
@@ -8,9 +8,9 @@

LOCAL_CFLAGS := -fPIC

-# This forces a 64-bit build for Java6
-LOCAL_CFLAGS += -m64
-LOCAL_LDFLAGS += -m64
+# This forces a 32-bit build for Java6
+LOCAL_CFLAGS += -m32
+LOCAL_LDFLAGS += -m32

LOCAL_NO_DEFAULT_COMPILER_FLAGS := true

diff -Nur old/external/clearsilver/cgi/Android.mk new/external/clearsilver/cgi/Android.mk
--- old/external/clearsilver/cgi/Android.mk 2011-01-21 10:44:21.118879155 +0800
+++ new/external/clearsilver/cgi/Android.mk 2011-01-21 10:46:16.683115540 +0800
@@ -12,9 +12,9 @@

LOCAL_CFLAGS := -fPIC

-# This forces a 64-bit build for Java6
-LOCAL_CFLAGS += -m64
-LOCAL_LDFLAGS += -m64
+# This forces a 32-bit build for Java6
+LOCAL_CFLAGS += -m32
+LOCAL_LDFLAGS += -m32

LOCAL_NO_DEFAULT_COMPILER_FLAGS := true

diff -Nur old/external/clearsilver/util/Android.mk new/external/clearsilver/util/Android.mk
--- old/external/clearsilver/util/Android.mk 2011-01-21 10:44:55.704170280 +0800
+++ new/external/clearsilver/util/Android.mk 2011-01-21 10:46:28.487643813 +0800
@@ -17,9 +17,9 @@
LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
LOCAL_CFLAGS := -fPIC

-# This forces a 64-bit build for Java6
-LOCAL_CFLAGS += -m64
-LOCAL_LDFLAGS += -m64
+# This forces a 32-bit build for Java6
+LOCAL_CFLAGS += -m32
+LOCAL_LDFLAGS += -m32

LOCAL_NO_DEFAULT_COMPILER_FLAGS := true

張貼留言