From 2f8283c602e2b8823f3d91f9663b57d7f7933566 Mon Sep 17 00:00:00 2001 From: Alvaro Soliverez Date: Mon, 14 Nov 2011 17:10:34 -0300 Subject: [PATCH] Support building on Android, modified from an original patch --- .gitignore | 1 + Android.mk | 41 +++++++++++++++++++++++++++++++++++++++++ autogen.sh | 43 ++++++++++++++++++++++++++++--------------- configure.ac | 20 ++++++++++++++++++-- extensions/Makefile.am | 11 +++++++++++ lib/gibber/Makefile.am | 10 ++++++++++ lib/loudmouth/Makefile.am | 10 ++++++++++ src/Makefile.am | 15 +++++++++++++-- src/main.c | 7 ++++++- 9 files changed, 138 insertions(+), 20 deletions(-) create mode 100644 Android.mk diff --git a/.gitignore b/.gitignore index c9ffc6f..2ede58e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ .deps .libs .svn +Android.mk FIXME.out /INSTALL Makefile diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..7e65332 --- /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 \ + --disable-submodules \ + --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..27fa050 100755 --- a/autogen.sh +++ b/autogen.sh @@ -16,23 +16,36 @@ 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 +#Check if submodules should be enabled +enable_submodules=true +for arg in $*; do + case $arg in + --disable-submodules) + enable_submodules=false + ;; + *) + ;; + esac +done + +if test $enable_submodules = true; then + # 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 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 ../../.. + # launch tp-yell's autogen.sh + cd lib/ext/telepathy-yell + sh autogen.sh --no-configure + cd ../../.. +fi # Honor NOCONFIGURE for compatibility with gnome-autogen.sh if test x"$NOCONFIGURE" = x; then diff --git a/configure.ac b/configure.ac index 57d6f84..4285e17 100644 --- a/configure.ac +++ b/configure.ac @@ -214,6 +214,12 @@ AC_ARG_ENABLE(gtk-doc, enable_gtk_doc=yes, enable_gtk_doc=no) AM_CONDITIONAL([ENABLE_GTK_DOC], [test "x$enable_gtk_doc" = xyes]) +dnl Check for Gio +PKG_CHECK_MODULES(GIO, [gio-2.0]) + +AC_SUBST(GIO_CFLAGS) +AC_SUBST(GIO_LIBS) + dnl Check for Glib PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.24, gobject-2.0 >= 2.24, gthread-2.0 >= 2.24]) PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.24]) @@ -328,15 +334,25 @@ ac_top_build_prefix=$prev_top_build_prefix ac_configure_args=$prev_ac_configure_args +dnl Check if Android build +AC_ARG_ENABLE(submodules, + AS_HELP_STRING([--disable-submodules],[Use system versions of Wocky and Telepathy-Yell, rather than submodules]), + build_submodules=$enableval, build_submodules=yes ) + 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$build_submodules = xyes; 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$build_submodules = xyes; 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..d6c4338 100644 --- a/extensions/Makefile.am +++ b/extensions/Makefile.am @@ -91,3 +91,14 @@ _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) \ + > $@ 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..63aed69 100644 --- a/lib/loudmouth/Makefile.am +++ b/lib/loudmouth/Makefile.am @@ -63,3 +63,13 @@ 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) \ + > $@ diff --git a/src/Makefile.am b/src/Makefile.am index 9fb8f5cd..4ecba90 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -227,13 +227,13 @@ AM_CFLAGS = $(ERROR_CFLAGS) -I$(top_srcdir) -I$(top_builddir) \ @TP_YELL_CFLAGS@ \ @DBUS_CFLAGS@ @GLIB_CFLAGS@ @WOCKY_CFLAGS@ \ @HANDLE_LEAK_DEBUG_CFLAGS@ @TP_GLIB_CFLAGS@ \ - @SOUP_CFLAGS@ @NICE_CFLAGS@ @GMODULE_CFLAGS@ \ + @SOUP_CFLAGS@ @NICE_CFLAGS@ @GMODULE_CFLAGS@ @GIO_CFLAGS@ \ -I $(top_srcdir)/lib -I $(top_builddir)/lib \ -DG_LOG_DOMAIN=\"gabble\" \ -DPLUGIN_DIR=\"$(libdir)/telepathy/gabble-0\" ALL_LIBS = @DBUS_LIBS@ @GLIB_LIBS@ @WOCKY_LIBS@ @TP_GLIB_LIBS@ \ - @SOUP_LIBS@ @NICE_LIBS@ @GMODULE_LIBS@ + @SOUP_LIBS@ @NICE_LIBS@ @GMODULE_LIBS@ @GIO_LIBS@ # build gibber first all: gibber @@ -277,3 +277,14 @@ 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) $(telepathy_gabble_LDFLAGS) \ + -:LDFLAGS $(telepathy_gabble_LDADD) $(libgabble_convenience_la_LIBADD) \ + > $@ diff --git a/src/main.c b/src/main.c index e6fc228..462183c 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.3