AndroidDependencies

From Gnash Project Wiki

Jump to: navigation, search

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 -fexceptions -frtti. the older -mandroid option is enabled in GCC by default now when you configure using arm-linux-androideabi as the host. The full set of standard options I use for all applications are:

--host=arm-linux-androideabi --build=`config.guess` --prefix=/usr/local/android-toolchain/sysroot/usr

--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 can 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.

At one time I had to do more ugly hacking to get everything to build. The newer toolchain is greatly improved over the older one, so most things build without problem. Since this page has gotten upated (--Rob 14:55, 22 June 2012 (MDT)), I've used newer versions of many of the packages, which have often cross configured and compiled better than the older versions.

I did have to copy a more recent config,sub file into each project. The advantages of this was it enabled the config string of arm-linux-androideabi to work, and all binutils are found. This is way easier than dealing with multiple versions of what config.sub would recognize.

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.

Toolchain GCC 4.8 with Binutils 2.20.1

/home/rob/projects/gnu/gcc/configure -target=arm-linux-androideabi --host=i386-linux-gnu --build=i386-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --without-ppl --without-cloog --disable-libssp --enable-threads --disable-nls --disable-libmudflap --disable-libgomp --disable-shared --disable-tls --disable-libitm --with-float=soft --with-fpu=vfp --enable-target-optspace --enable-initfini-array --disable-nls --prefix=/usr/local/android-toolchain --with-sysroot=/usr/local/android-toolchain/sysroot --enable-gold --with-pkgversion=`whoami` --disable-libquadmath --disable-plugin --enable-gold=default target_configargs=lt_cv_shlibpath_overrides_runpath=yes --enable-cxx-flags=-fexceptions -frtti


freetype 2.3.7

./configure --build=i686-pc-linux-gnu --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --build=i686-pc-linux-gnu

libiconv

./configure --prefix=/usr/local/android-arm/sysroot/usr --build=i686-pc-linux-gnu --host=arm-linux-eabi CFLAGS="-mandroid"

libxml2 2.8.0

/configure --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --build=i686-pc-linux-gnu

gettext 0.17

./configure --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --build=i686-pc-linux-gnu --disable-nls

  • edit ./gettext-tools/gnulib-lib/fnmatch_loop.c:
  1. 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 2.6.0

./configure --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --build=i686-pc-linux-gnu CFLAGS=-mandroid --with-arch=arm

SDL 1.2.13

./configure --build=i686-pc-linux-gnu --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --enable-video-fbcon --disable-video-x11 --disable-dga --disable-esd --disable-joystick --enable-static --disable-cdrom --disable-video-directfb

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 8c

./configure --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --build=i686-pc-linux-gnu

libpng 1.4

./configure --build=i686-pc-linux-gnu --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi

giflib 4.1.6

./configure --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi --build=i686-pc-linux-gnu

agg 2.5

./configure --build=i686-pc-linux-gnu --prefix=/usr/local/android-toolchain/sysroot/usr --host=arm-linux-androideabi

./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.
  • edit Makefile.am and remove examples from 'SUBDIRS.
run autoreconf

boost 1.48

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-androideabi-gcc ; 

Change the list of libraries to:

libraries = thread,date_time,iostreams,program_options,serialization ;

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-toolchain/sysroot/usr ;
option.set exec-prefix : /usr/local/android-toolchain ;
option.set libdir : /usr/local/android-toolchain/sysroot/usr/lib ;
option.set includedir : /usr/local/android-toolchain/sysroot/usr/include ;

./bjam --prefix=/usr/local/android-arm/sysroot/usr -d+2 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"