From 271f7e8e359e1679b0ef21cd55fce39ed637f5ae Mon Sep 17 00:00:00 2001 From: Alvaro Soliverez Date: Tue, 1 Nov 2011 16:20:01 -0300 Subject: [PATCH] Support building on Android --- Android.mk | 41 ++++++++++++++++++++++++++ autogen.sh | 71 ++++++++++++++++++++++++++++++-------------- configure.ac | 14 +++++++- extensions/Makefile.am | 12 +++++++ lib/gibber/Makefile.am | 10 ++++++ lib/loudmouth/Makefile.am | 11 +++++++ src/Makefile.am | 14 +++++++++ src/main.c | 7 ++++- 8 files changed, 154 insertions(+), 26 deletions(-) create mode 100644 Android.mk diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..08fa73d --- /dev/null +++ b/Android.mk @@ -0,0 +1,41 @@ +LOCAL_PATH:= $(call my-dir) + +include $(CLEAR_VARS) + +TELEPATHY_GABBLE_BUILT_SOURCES := \ + gabble/telepathy-gabble.pc \ + gabble/telepathy-gabble-uninstalled.pc \ + src/Android.mk \ + lib/gibber/Android.mk \ + lib/loudmouth/Android.mk \ + extensions/Android.mk + +telepathy-gabble-configure-real: + cd $(TELEPATHY_GABBLE_TOP) ; \ + CC="$(CONFIGURE_CC)" \ + CFLAGS="$(CONFIGURE_CFLAGS)" \ + LD=$(TARGET_LD) \ + LDFLAGS="$(CONFIGURE_LDFLAGS)" \ + CPP=$(CONFIGURE_CPP) \ + CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \ + PKG_CONFIG_LIBDIR=$(CONFIGURE_PKG_CONFIG_LIBDIR) \ + PKG_CONFIG_TOP_BUILD_DIR=$(PKG_CONFIG_TOP_BUILD_DIR) \ + $(TELEPATHY_GABBLE_TOP)/$(CONFIGURE) --host=arm-linux-androideabi \ + --enable-android \ + --disable-Werror --without-ca-certificates && \ + for file in $(TELEPATHY_GABBLE_BUILT_SOURCES); do \ + rm -f $$file && \ + make -C $$(dirname $$file) $$(basename $$file) ; \ + done + +telepathy-gabble-configure: telepathy-gabble-configure-real + +.PHONY: telepathy-gabble-configure + +CONFIGURE_TARGETS += telepathy-gabble-configure + +#include all the subdirs... +-include $(TELEPATHY_GABBLE_TOP)/src/Android.mk +-include $(TELEPATHY_GABBLE_TOP)/lib/gibber/Android.mk +-include $(TELEPATHY_GABBLE_TOP)/lib/loudmouth/Android.mk +-include $(TELEPATHY_GABBLE_TOP)/extensions/Android.mk diff --git a/autogen.sh b/autogen.sh index 1de8195..757e7a2 100755 --- a/autogen.sh +++ b/autogen.sh @@ -16,38 +16,63 @@ fi autoreconf -i -f -# Fetch submodules if needed -if test ! -f lib/ext/wocky/autogen.sh -o ! -f lib/ext/telepathy-yell/autogen.sh; -then - echo "+ Setting up submodules" - git submodule init -fi -git submodule update - -# launch Wocky's autogen.sh -cd lib/ext/wocky -sh autogen.sh --no-configure -cd ../../.. - -# launch tp-yell's autogen.sh -cd lib/ext/telepathy-yell -sh autogen.sh --no-configure -cd ../../.. +#Check if Android build +run_android_build=false +for arg in $*; do + case $arg in + --enable-android) + run_android_build=true + ;; + *) + ;; + esac +done -# Honor NOCONFIGURE for compatibility with gnome-autogen.sh -if test x"$NOCONFIGURE" = x; then +if test $run_android_build = true; then run_configure=true for arg in $*; do case $arg in --no-configure) - run_configure=false - ;; + run_configure=false + ;; *) - ;; + ;; esac done else - run_configure=false + # Fetch submodules if needed + if test ! -f lib/ext/wocky/autogen.sh -o ! -f lib/ext/telepathy-yell/autogen.sh; + then + echo "+ Setting up submodules" + git submodule init + fi + git submodule update + + # launch Wocky's autogen.sh + cd lib/ext/wocky + sh autogen.sh --no-configure + cd ../../.. + + # launch tp-yell's autogen.sh + cd lib/ext/telepathy-yell + sh autogen.sh --no-configure + cd ../../.. + + # Honor NOCONFIGURE for compatibility with gnome-autogen.sh + if test x"$NOCONFIGURE" = x; then + run_configure=true + for arg in $*; do + case $arg in + --no-configure) + run_configure=false + ;; + *) + ;; + esac + done + else + run_configure=false + fi fi if test $run_configure = true; then diff --git a/configure.ac b/configure.ac index 57d6f84..3981aaf 100644 --- a/configure.ac +++ b/configure.ac @@ -328,15 +328,25 @@ ac_top_build_prefix=$prev_top_build_prefix ac_configure_args=$prev_ac_configure_args +dnl Check if Android build +AC_ARG_ENABLE(android, + AC_HELP_STRING([--enable-android],[compile Android code]), + android_build=$enableval, android_build=no ) + dnl Check for Wocky # re-enable once Wocky has been released as a lib -export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$ac_top_build_prefix"lib/ext/wocky/wocky +if test x$android_build = xno; then + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$ac_top_build_prefix"lib/ext/wocky/wocky +fi + PKG_CHECK_MODULES(WOCKY, wocky >= 0.0.0) AC_SUBST(WOCKY_CFLAGS) AC_SUBST(WOCKY_LIBS) dnl Check for tp-yell -export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$ac_top_build_prefix"lib/ext/telepathy-yell/telepathy-yell +if test x$android_build = xno; then + export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:"$ac_top_build_prefix"lib/ext/telepathy-yell/telepathy-yell +fi PKG_CHECK_MODULES(TP_YELL, telepathy-yell) AC_SUBST(TP_YELL_CFLAGS) AC_SUBST(TP_YELL_LIBS) diff --git a/extensions/Makefile.am b/extensions/Makefile.am index 9595750..6ca5b83 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -91,3 +91,15 @@ _gen/gtypes.h _gen/gtypes-body.h: _gen/all.xml \ $(tools_dir)/glib-gtypes-generator.py Makefile.am $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-gtypes-generator.py \ $< _gen/gtypes Gabble + +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer -:PROJECT telepathy-gabble -:STATIC gabble-extensions -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libgabble_extensions_la_SOURCES) \ + $(nodist_libgabble_extensions_la_SOURCES) \ + -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ + -:LDFLAGS $(libgabble_extensions_la_LIBADD) \ + > $@ + \ No newline at end of file diff --git a/lib/gibber/Makefile.am b/lib/gibber/Makefile.am index d02cc5f..f50bfd0 100644 --- a/lib/gibber/Makefile.am +++ b/lib/gibber/Makefile.am @@ -64,3 +64,13 @@ gibber-signals-marshal.list: $(OUR_SOURCES) Makefile.am AM_CFLAGS = $(ERROR_CFLAGS) $(GCOV_CFLAGS) @GLIB_CFLAGS@ @GMODULE_CFLAGS@ -fno-strict-aliasing AM_LDFLAGS = $(GCOV_LIBS) @GLIB_LIBS@ + +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer -:PROJECT telepathy-gabble -:STATIC gibber -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libgibber_la_SOURCES) \ + -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ + -:LDFLAGS $(AM_LDFLAGS) \ + > $@ diff --git a/lib/loudmouth/Makefile.am b/lib/loudmouth/Makefile.am index 51c13aa..7d7c22f 100644 --- a/lib/loudmouth/Makefile.am +++ b/lib/loudmouth/Makefile.am @@ -63,3 +63,14 @@ loudmouth-signals-marshal.list: $(OUR_SOURCES) Makefile.am AM_CFLAGS = $(ERROR_CFLAGS) $(GCOV_CFLAGS) @GLIB_CFLAGS@ @WOCKY_CFLAGS@ AM_LDFLAGS = $(GCOV_LIBS) @GLIB_LIBS@ @WOCKY_LIBS@ + +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer -:PROJECT telepathy-gabble -:STATIC loudmouth -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libloudmouth_la_SOURCES) \ + -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CFLAGS) \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ + -:LDFLAGS $(libloudmouth_la_LIBADD) \ + > $@ + \ No newline at end of file diff --git a/src/Makefile.am b/src/Makefile.am index 9fb8f5cd..8e36f62 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -277,3 +277,17 @@ gabble-enumtypes.c: $(enumtype_sources) Makefile.in --vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \ --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \ $(enumtype_sources) > $@ + +Android.mk: Makefile.am $(BUILT_SOURCES) + androgenizer -:PROJECT telepathy-gabble -:SHARED telepathy-gabble -:TAGS eng debug \ + -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ + -:SOURCES $(libgabble_convenience_la_SOURCES) \ + $(nodist_libgabble_convenience_la_SOURCES) main.c \ + -:CFLAGS $(DEFS) $(CFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CFLAGS) -DBUILD_AS_ANDROID_SERVICE \ + -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) -I../lib \ + -:LDFLAGS $(libgabble_convenience_la_LIBADD) -lgio-2.0 -ldbus-1 \ + -lsoup -lgabble_ext -lnice -lgcrypt -lgnutls -lxml2 -lsqlite3 \ + -:LIBFILTER_STATIC gabble-extentions gibber loudmouth wocky \ + telepathy-yell \ + > $@ diff --git a/src/main.c b/src/main.c index e6fc228..154acb7 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,12 @@ #include "gabble.h" int -main (int argc, +#ifdef BUILD_AS_ANDROID_SERVICE +telepathy_gabble_main +#else +main +#endif + (int argc, char **argv) { gabble_init (); -- 1.7.7