AndroidDependencies
From Gnash Project Wiki
Contents |
Build Dependencies for Android
Gnash unfortunately has many dependencies, most of which aren't 100% setup for cross compiling. These build notes depend on the most recent version of my Android C++ toolchain. I've got a lot of experience at cross configuring and cross compiling, so unfortunately, I did this the brute force way, rather than fix all the bugs in all the packages. There is also an order one needs to follow when building up all the dependencies from scratch.These package notes are in the proper order.
The standard set of build options for everything is -mandroid -fexceptions . the -mandroid option mostly just adjusts the linker line to work with the Android startup code. -fexceptions is needed because for some reason they aren't enabled in this toolchain. The full set of standard options are:
-mandroid --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi
--prefix of course being where this gets installed after building. The other two options specify the build type, which is our workstation, and the host type, which is our target. These two are standard GNU autotools options. Some packages don't pick up the name of the cross compiler correctly, so we force that be setting CC (or CXX) to our cross compiler. Since we need the two primary default flags, we just append them to the value of CC, as for some packages redefining CFLAGS breaks the build. They also often miss the NDK or our toolchain directory, so sometimes we have to set that too.
It's also very common to redefine the variables make uses at either configure or build time. This overrides what configure thinks with what you want. Some of these hacks are pretty ugly, and may cause problems, but I'll find out as I get to test Gnash running with these hacked libraries.
Android
While you don't need to build Android from source, I figured I'd add a few notes about that, as I had to hack things a bit to get Android itself to build. The host tools, used as utilities during the build process don't all build themselves. This was do to a missing library at link time. To fix this, you have to add -lpthread to LOCAL_LDLIBS in these two files: frameworks/base/tools/aapt/Android.mk, and frameworks/base/tools/localize/Android.mk. I also noticed Android seems to have problems with parallel builds, at least for me, anything over -j4 breaks something. So I just do standard builds.
freetype
./configure --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi CFLAGS="-mandroid"
libiconv
./configure --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi CFLAGS="-mandroid"
libxml2
./configure CC="arm-linux-eabi-gcc $default_flags -I/opt/android-ndk-r3/build/platforms/android-3/arch-arm/usr/include" --without-threads --without-python --enable-shared
- hand edit the Makefile and remove runtest$(EXEEXT) from the noinst_PROGRAMS variable
gettext
./configure --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi CFLAGS="-mandroid" --with-arch=arm5te LIBXML2_CFLAGS="-I/usr/local/android-arm/sysroot/usr/include" LIBXML2_LIBS="-L/usr/local/android-arm/sysroot/usr/lib" --disable-java --disable-openmp --without-libiconv-prefix --without-libintl-prefix --without-libglib-2.0-prefix --without-libcroco-0.6-prefix --with-included-libxml --without-libncurses-prefix --without-libtermcap-prefix --without-libcurses-prefix --without-libexpat-prefix --without-emacs
- edit ./gettext-tools/gnulib-lib/fnmatch_loop.c:
- define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
edit ./gettext-runtime/gnulib-lib/mbuiter.h ./gettext-tools/gnulib-lib/mbuiter.h ./gettext-tools/libgrep/dfa.c
- #if 0
- typedef struct
- {
- wchar_t __mask;
- wchar_t __wc;
- } mbstate_t;
- #endif
fontconfig
./configure --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi --with-arch=arm5te --disable-docs LDFLAGS=-mandroid LIBXML2_CFLAGS="-I/usr/local/android-arm/sysroot/usr/include/libxml2" LIBXML2_LIBS="-L/usr/local/android-arm/sysroot/usr/lib -lxml2"
- make CFLAGS=-I/usr/local/android-arm/sysroot/usr/include/libxml2 install
pts/11$ ./configure --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi --with-arch=arm5te --disable-java --disable-openmp --with-included-libxml --without-emacs --disable-docs LDFLAGS=-mandroid
locale_data->decimal_point[0] doesn't exist
SDL
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid" --enable-video-fbcon --disable-video-x11 --disable-dga --disable-esd REETYPE_CFLAGS="-I/usr/local/android-arm/sysroot/usr/include/freetype2" FREETYPE_LIBS="-L/usr/local/android-arm/sysroot/usr/lib -lfreetype2"
libcurl
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid" --without-ssl
- edit and add #include <sys/select.h> to include/curl/multi.h
- add typedef uint32_t in_addr; to lib/hostip.h
- make CPPFLAGS=-DHAVE_POSIX_STRERROR_R
jpeg
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid" LDFLAGS="-mandroid" CC=arm-linux-eabi-gcc
libpng
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid"
giflib
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid"
agg
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid" FREETYPE_CFLAGS="-I/usr/local/android-arm/sysroot/usr/include/freetype2 -I/usr/local/android-arm/sysroot/usr/include" FREETYPE_LIBS="-L/usr/local/android-arm/sysroot/usr/lib -lfreetype" --disable-examples
- edit configure.in and right after AC_PATH_X, add no_x=yes.
- run autoreconf
boost
Boost can often be a real pain in the neck to cross compile, as it uses both a weird (in my opinion) configuration and build system. I've managed to go from really ugly hacks to make boost build, to ones I'm willing to talk about in public. It still requires some editing, and as of yet, I haven't gotten all of the libraries built. Just the ones Gnash needs.
- edit project-config.jam
Change the line that starts with using gcc and make replace that line with this one:
using gcc : : arm-linux-eabi-gcc -mandroid ;
Change the list of libraries to:
libraries = thread,date_time ;
Then append on the end so we don't have to specify them on the command line all the time:
# These settings are equivalent to corresponding command-line # options. option.set prefix : /usr/local/android-arm/sysroot/usr ; option.set exec-prefix : /usr/local/android-arm ; option.set libdir : /usr/local/android-arm/usr/lib ; option.set includedir : /usr/local/android-arm/usr/include ;
- edit boost/config.hpp
There is probably a better way to do this, but to work around the pthread issues with bionic, I cheat and just override the options used for pthread support. So down near the bottom of this file add:
#undef BOOST_DISABLE_THREADS #define BOOST_HAS_THREADS 1 #define BOOST_HAS_GETTIMEOFDAY #define BOOST_THREAD_POSIX 1
- edit tools/build/v2/tools/gcc.jam - remove default case that sets -pthread and -lrt, both of which cause errors with building boost.
./bjam --prefix=/usr/local/android-arm/sysroot/usr -d+2 --with-thread --with-date_time install
atk
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS="-mandroid"
rename static guint index = 0; in ./atk/atkutil.c
ffmpeg
./configure --prefix=/usr/local/android-arm/sysroot/usr --cc="arm-linux-eabi-gcc -mandroid" --enable-cross-compile --target-os=linux --arch=arm5te --ld=arm-linux-eabi-ld --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver
- edit /opt/android-ndk-r3/build/platforms/android-5/arch-arm/usr/include/asm/byteorde and wrap the #ifndef __thumb__ part with an #if 0/#endif
- add #define O_BINARY 0 /* for open() */ to libavcodec/utils.h
- make HAVE_STRUCT_IPV6_MREQ_XX in libavformat/udp.c be something else, it's bogus for Android so we just want to get rid of it.
pango
/configure CC="arm-linux-eabi-gcc $default_flags -I/usr/local/android-arm/sysroot/usr/include" FREETYPE_CFLAGS="-I/usr/local/android-arm/sysroot/usr/include/freetype2 -I/usr/local/android-arm/sysroot/usr/include" FREETYPE_LIBS="-L/usr/local/android-arm/sysroot/usr/lib" --without-x
glib
./configure --build=i686-pc-linux-gnu --host=arm-linux-eabi --prefix=/usr/local/android-arm/sysroot/usr CFLAGS=-mandroid --with-threads=none --with-libiconv=no CPPFLAGS="-I/usr/local/android-arm/sysroot/usr/include" LDFLAGS="-L/usr/local/android-arm/sysroot/usr/lib"

