Simplify building with the Android NDK.
authorJonathan Pryor <jonpryor@vt.edu>
Fri, 3 Jun 2011 20:42:38 +0000 (16:42 -0400)
committerJonathan Pryor <jonpryor@vt.edu>
Fri, 3 Jun 2011 20:42:38 +0000 (16:42 -0400)
Check --host against *-*-linux-android* for Android-specific configure fixes,
and improve **/Makefile.am to simplify Android support:

./configure \
--build=`./config.guess` \
--host=armv5-linux-androideabi \
--target=armv5-linux-androideabi \
--enable-nls=no --with-mcs-docs=no --enable-mcs-build=no \
CC="/path/to/ndk/arm-linux-androideabi-gcc --sysroot=/path/to/sysroot" \
AR="..." AS="..." CPP="..." CXX="..." LD="..." RANLIB="..." STRIP="..."
CFLAGS="-DARM_FPU_NONE=1" CXXFLAGS="-DARM_FPU_NONE=1"

See also Android NDK docs/STANDALONE-TOOLCHAIN.html.

The Android NDK/bionic is "interesting", in that it's lacking header files and
macros normally present on Linux which otherwise break the build (e.g. no
<link.h> which breaks Boehm support).  Using --host with an android target
works around the known issues, simplifying the building of libmonosgen-2.0.so
with the Android NDK toolchain.

configure.in
eglib/configure.ac
eglib/src/Makefile.am
mono/dis/Makefile.am
mono/metadata/Makefile.am
mono/mini/Makefile.am

index 661e55b584cb0cc6eb350f760cde480923bcbfba..01c5af77177c387f17b7dd2bc4ac78fd24668dcb 100644 (file)
@@ -86,6 +86,7 @@ esac
 
 host_win32=no
 target_win32=no
+platform_android=no
 case "$host" in
        *-mingw*|*-*-cygwin*)
                AC_DEFINE(HOST_WIN32,1,[Host Platform is Win32])
@@ -180,6 +181,40 @@ case "$host" in
                with_sigaltstack=no
                use_sigposix=yes
                ;;
+       *-*-linux-android*)
+               host_win32=no
+               platform_android=yes
+               AC_DEFINE(PLATFORM_ANDROID,1,[Targeting the Android platform])
+
+               CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
+               if test "x$disable_munmap" != "xyes"; then
+                       CPPFLAGS="$CPPFLAGS -DUSE_MUNMAP"
+               fi
+               libmono_cflags="-D_REENTRANT"
+               libdl="-ldl"
+               libgc_threads=pthreads
+               use_sigposix=yes
+
+               with_tls=pthread
+               with_sigaltstack=no
+               with_static_mono=no
+
+               # Android doesn't support boehm, as it's missing <link.h>
+               support_boehm=no
+               with_gc=sgen
+
+               # isinf(3) requires -lm; see isinf check below
+               LDFLAGS="$LDFLAGS -lm"
+
+               # Bionic's <pthread.h> sets PTHREAD_STACK_MIN=2*PAGE_SIZE; doesn't define
+               # PAGE_SIZE; breaks mono/io-layer/collection.c
+               # Bionic doesn't provide S_IWRITE; breaks io-layer/io.c
+               CFLAGS="$CFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
+               CXXFLAGS="$CXXFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
+
+               # to bypass the underscore linker check, can't work when cross-compiling
+               mono_cv_uscore=yes
+               ;;
        *-*-linux*)
                host_win32=no
                CPPFLAGS="$CPPFLAGS -DGC_LINUX_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP"
@@ -302,6 +337,7 @@ AM_CONDITIONAL(TARGET_WIN32, test x$target_win32 = xyes)
 AM_CONDITIONAL(PLATFORM_LINUX, echo x$target_os | grep -q linux)
 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
 AM_CONDITIONAL(PLATFORM_SIGPOSIX, test x$use_sigposix = xyes)
+AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
 
 AC_CHECK_TOOL(CC, gcc, gcc)
 AC_PROG_CC
@@ -828,6 +864,9 @@ if test x$enable_parallel_mark = xyes; then
        libgc_configure_args="$libgc_configure_args --enable-parallel-mark"
 fi
 
+AC_ARG_ENABLE(boehm, [  --disable-boehm            Disable the Boehm GC.], support_boehm=$enableval,support_boehm=yes)
+AM_CONDITIONAL(SUPPORT_BOEHM, test x$support_boehm = xyes)
+
 dnl
 dnl Boehm GC configuration
 dnl
index 1e20bef6e2e40628eacdaf360da8c236f7c2bf8a..791a9f760b7e3eb6edb2847439146499a70f7718 100644 (file)
@@ -44,6 +44,7 @@ AM_CONDITIONAL(CROSS_COMPILING, [test x$cross_compiling = xyes])
 AC_C_BIGENDIAN([ORDER=G_BIG_ENDIAN],[ORDER=G_LITTLE_ENDIAN])
 
 platform_darwin=no
+platform_android=no
 
 case $host in
 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
@@ -59,6 +60,13 @@ case $host in
     OS="UNIX"
     PIDTYPE='int'
     ;;
+*-*-linux-android*)
+    platform_android=yes
+    PATHSEP='/'
+    SEARCHSEP=':'
+    OS="UNIX"
+    PIDTYPE='int'
+    ;;
 *)
     PATHSEP='/'
     SEARCHSEP=':'
@@ -95,6 +103,7 @@ AC_SUBST(PIDTYPE)
 AM_CONDITIONAL(HOST_WIN32, test x$OS = xWIN32)
 AM_CONDITIONAL(TARGET_WIN32, test x$OS = xWIN32)
 AM_CONDITIONAL(PLATFORM_DARWIN, test x$platform_darwin = xyes)
+AM_CONDITIONAL(PLATFORM_ANDROID, test x$platform_android = xyes)
 
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(void *)
index 00b797fc4ae74829bbc9ec2072a593792c2e9f5a..94bee684e0470a9c4ec5ea2b52da462e19a53e6e 100644 (file)
@@ -63,6 +63,10 @@ INCLUDES = -I$(srcdir)
 
 if HOST_WIN32
 libeglib_la_LIBADD = -lm $(LIBICONV) -lpsapi
+else
+if PLATFORM_ANDROID
+libeglib_la_LIBADD = -llog
+endif
 endif
 
 libeglib_static_la_LIBADD = $(libeglib_la_LIBADD) $(LIBICONV)
index 284bdbdc71c71be1ba825ed8c39d144550c745d3..78539b7b1bc926459b928ca04539188a9bf23393 100644 (file)
@@ -10,7 +10,9 @@ else
 runtime_lib=../interpreter/libmint.la
 endif
 
+if SUPPORT_BOEHM
 bin_PROGRAMS = monodis
+endif
 
 noinst_LIBRARIES = libmonodis.a
 
index 57eefe7ad1cd94c02759d61441e2ad144d6c6b8d..c6fc91e5ce382001deea64d177f9096086a3406d 100644 (file)
@@ -29,8 +29,10 @@ platform_sources = $(unix_sources)
 endif
 
 if SHARED_MONO
+if SUPPORT_BOEHM
 bin_PROGRAMS = pedump
 endif
+endif
 
 #
 # libtool is not capable of creating static/shared versions of the same
@@ -52,8 +54,10 @@ moon-do-clean:
 endif
 
 if SHARED_MONO
+if SUPPORT_BOEHM
 shared_libraries = libmonoruntime.la
 endif
+endif
 noinst_LTLIBRARIES =  $(shared_libraries) libmonoruntime-static.la $(sgen_libraries) $(moonlight_libraries)
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/mono $(LIBGC_CFLAGS) $(GLIB_CFLAGS) -DMONO_BINDIR=\"$(bindir)/\" -DMONO_ASSEMBLIES=\"$(assembliesdir)\" -DMONO_CFG_DIR=\"$(confdir)\"
@@ -282,6 +286,7 @@ PEDUMP_DTRACE_OBJECT =
 endif
 
 if SHARED_MONO
+if SUPPORT_BOEHM
 pedump_SOURCES =               \
        pedump.c
 
@@ -292,6 +297,7 @@ if PLATFORM_DARWIN
 pedump_LDFLAGS=-framework CoreFoundation
 endif
 endif
+endif
 
 EXTRA_DIST = make-bundle.pl sample-bundle $(win32_sources) $(unix_sources) $(null_sources) $(sgen_sources) runtime.h \
                tpool-poll.c tpool-epoll.c tpool-kqueue.c
index a271376e387025ca3a62d8d0674e448463bd2a4d..d0ecfa5caac4a216d0d6ea5b17ab96763b2529e9 100644 (file)
@@ -95,16 +95,21 @@ sgen_libraries = libmonosgen-2.0.la
 sgen_static_libraries = libmonosgen-static.la
 endif
 
+if SUPPORT_BOEHM
+boehm_libraries = libmono-2.0.la
+boehm_binaries  = mono
+endif
+
 if HOST_WIN32
 bin_PROGRAMS = mono monow
 else
-bin_PROGRAMS = mono $(sgen_binaries)
+bin_PROGRAMS = $(boehm_binaries) $(sgen_binaries)
 endif
 
 noinst_PROGRAMS = genmdesc
 
 if SHARED_MONO
-shared_libraries = libmono-2.0.la $(sgen_libraries)
+shared_libraries = $(boehm_libraries) $(sgen_libraries)
 endif
 
 lib_LTLIBRARIES = $(shared_libraries)