Last active
August 29, 2015 14:03
-
-
Save pawitp/f2f57e26387a6f6769e9 to your computer and use it in GitHub Desktop.
Patch to build the CLI version of IBR-DTN 0.12.1 on Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/android/ibrdtn/jni/Android.mk b/android/ibrdtn/jni/Android.mk | |
index d68a1eb..fcb8a75 100644 | |
--- a/android/ibrdtn/jni/Android.mk | |
+++ b/android/ibrdtn/jni/Android.mk | |
@@ -11,6 +11,7 @@ include $(JNI_PATH)/nl-3/android_toolchain/jni/Android_static.mk | |
include $(JNI_PATH)/ibrcommon/Android.mk | |
include $(JNI_PATH)/ibrdtn/Android.mk | |
include $(JNI_PATH)/dtnd/Android.mk | |
+include $(JNI_PATH)/tools/Android.mk | |
# include android glue code | |
-include $(JNI_PATH)/android-glue/Android.mk | |
+#include $(JNI_PATH)/android-glue/Android.mk | |
diff --git a/android/ibrdtn/jni/Application.mk b/android/ibrdtn/jni/Application.mk | |
index 4dfdb3b..1bc8211 100644 | |
--- a/android/ibrdtn/jni/Application.mk | |
+++ b/android/ibrdtn/jni/Application.mk | |
@@ -4,6 +4,7 @@ LOCAL_PATH:=$(call my-dir) | |
ibrcommon_TOP:=$(abspath $(LOCAL_PATH))/ibrcommon | |
ibrdtn_TOP:=$(abspath $(LOCAL_PATH))/ibrdtn | |
dtnd_TOP:=$(abspath $(LOCAL_PATH))/dtnd | |
+tools_TOP:=$(abspath $(LOCAL_PATH))/tools | |
# Optimizations | |
#APP_OPTIM:=release | |
@@ -48,6 +49,6 @@ APP_CPPFLAGS+=-I$(abspath $(LOCAL_PATH))/ibrcommon | |
APP_CPPFLAGS+=-I$(abspath $(LOCAL_PATH))/ibrdtn | |
# If APP_MODULES is not set, all modules are compiled! | |
-APP_MODULES:=crypto ssl ibrcommon ibrdtn dtnd android-glue | |
+APP_MODULES:=crypto ssl ibrcommon ibrdtn dtnd dtnping dtnrecv dtnsend dtntracepath dtnstream dtntrigger dtnconvert | |
#APP_MODULES:=all | |
diff --git a/android/ibrdtn/jni/build.sh b/android/ibrdtn/jni/build.sh | |
index 0be5f14..a7c3a5b 100755 | |
--- a/android/ibrdtn/jni/build.sh | |
+++ b/android/ibrdtn/jni/build.sh | |
@@ -8,6 +8,7 @@ echo "-----------------------------------------" | |
[ ! -e ibrcommon ] && ln -s ../../../ibrcommon/ ibrcommon | |
[ ! -e ibrdtn ] && ln -s ../../../ibrdtn/ibrdtn/ ibrdtn | |
[ ! -e dtnd ] && ln -s ../../../ibrdtn/daemon/ dtnd | |
+[ ! -e tools ] && ln -s ../../../ibrdtn/tools/ tools | |
echo "" | |
echo "Cloning external git sources used in IBR-DTN (libnl and openssl)..." | |
@@ -42,7 +43,7 @@ cd .. | |
echo "" | |
echo "Generating Android.mk files using Autotools and Androgenizer..." | |
echo "---------------------------------------------------------------" | |
-for SOURCE in "ibrcommon" "ibrdtn" "dtnd" | |
+for SOURCE in "ibrcommon" "ibrdtn" "dtnd" "tools" | |
do | |
echo "" | |
echo "Generating Android.mk files for $SOURCE" | |
diff --git a/ibrcommon/ibrcommon/Makefile.am b/ibrcommon/ibrcommon/Makefile.am | |
index 9311d7e..babd00b 100644 | |
--- a/ibrcommon/ibrcommon/Makefile.am | |
+++ b/ibrcommon/ibrcommon/Makefile.am | |
@@ -80,4 +80,5 @@ Android.mk: Makefile.am | |
-:LIBFILTER_WHOLE ibrcommon_data ibrcommon_link ibrcommon_net ibrcommon_thread ibrcommon_ssl ibrcommon_gcm ibrcommon_xml \ | |
nl-3 nl-genl-3 nl-route-3 \ | |
-:SUBDIR $(patsubst %,ibrcommon/%, $(SUBDIRS)) \ | |
+ -:PASSTHROUGH LOCAL_LDLIBS+=-llog \ | |
> $@ | |
diff --git a/ibrdtn/daemon/src/Makefile.am b/ibrdtn/daemon/src/Makefile.am | |
index 159a1fe..726fd33 100644 | |
--- a/ibrdtn/daemon/src/Makefile.am | |
+++ b/ibrdtn/daemon/src/Makefile.am | |
@@ -70,8 +70,8 @@ endif | |
Android.mk: Makefile.am | |
$(ANDROGENIZER) -:PROJECT dtnd \ | |
-:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ | |
- -:SHARED dtnd \ | |
- -:SOURCES $(dtnd_sources) \ | |
+ -:EXECUTABLE dtnd \ | |
+ -:SOURCES $(dtnd_sources) Main.cpp \ | |
-:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
-:LDFLAGS $(AM_LDFLAGS) \ | |
$(subst lib,libdtnd_, $(dtnd_libs)) \ | |
diff --git a/ibrdtn/daemon/src/NativeDaemon.cpp b/ibrdtn/daemon/src/NativeDaemon.cpp | |
index 09cf899..15415b7 100644 | |
--- a/ibrdtn/daemon/src/NativeDaemon.cpp | |
+++ b/ibrdtn/daemon/src/NativeDaemon.cpp | |
@@ -1105,7 +1105,6 @@ namespace dtn | |
_components[RUNLEVEL_API].push_back( new dtn::core::FragmentManager() ); | |
} | |
-#ifndef ANDROID | |
if (conf.doAPI()) | |
{ | |
try { | |
@@ -1136,7 +1135,6 @@ namespace dtn | |
{ | |
IBRCOMMON_LOGGER_TAG(NativeDaemon::TAG, info) << "API disabled" << IBRCOMMON_LOGGER_ENDL; | |
} | |
-#endif | |
} | |
void NativeDaemon::shutdown_api() throw (NativeDaemonException) | |
diff --git a/ibrdtn/ibrdtn/ibrdtn/Makefile.am b/ibrdtn/ibrdtn/ibrdtn/Makefile.am | |
index 8ad7dba..762679e 100644 | |
--- a/ibrdtn/ibrdtn/ibrdtn/Makefile.am | |
+++ b/ibrdtn/ibrdtn/ibrdtn/Makefile.am | |
@@ -48,4 +48,5 @@ Android.mk: Makefile.am | |
-lgnustl_shared \ | |
-:LIBFILTER_WHOLE ibrdtn_api ibrdtn_data ibrdtn_streams ibrdtn_utils ibrdtn_security \ | |
-:SUBDIR $(patsubst %,ibrdtn/%, $(SUBDIRS)) \ | |
+ -:PASSTHROUGH LOCAL_LDLIBS+=-lz \ | |
> $@ | |
diff --git a/ibrdtn/tools/Makefile.am b/ibrdtn/tools/Makefile.am | |
index 5db2d2d..0c712ff 100644 | |
--- a/ibrdtn/tools/Makefile.am | |
+++ b/ibrdtn/tools/Makefile.am | |
@@ -1,5 +1,13 @@ | |
AUTOMAKE_OPTIONS = foreign | |
-SUBDIRS = src doc man | |
+SUBDIRS = src | |
+ | |
+if ANDROID | |
+noinst_DATA = Android.mk | |
+CLEANFILES = Android.mk | |
+else | |
+SUBDIRS += doc man | |
+endif | |
+ | |
ACLOCAL_AMFLAGS = -I m4 | |
# debian files for package building | |
@@ -14,3 +22,8 @@ EXTRA_DIST= \ | |
debian/source \ | |
debian/source/format | |
+Android.mk: Makefile.am | |
+ $(ANDROGENIZER) -:PROJECT tools \ | |
+ -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ | |
+ -:SUBDIR $(SUBDIRS) \ | |
+ > $@ | |
diff --git a/ibrdtn/tools/configure.ac b/ibrdtn/tools/configure.ac | |
index 6b52fe2..db72b85 100644 | |
--- a/ibrdtn/tools/configure.ac | |
+++ b/ibrdtn/tools/configure.ac | |
@@ -32,97 +32,128 @@ AC_PROG_LIBTOOL | |
AC_LANG_CPLUSPLUS | |
-# Checks for libraries. | |
-AC_CHECK_LIB([rt], [clock_gettime], []) | |
-AC_CHECK_LIB([m], [pow], []) | |
- | |
-# check for ibrcommon library | |
-LOCAL_IBRCOMMON_VERSION=0.10 | |
-LOCAL_CHECK_IBRCOMMON | |
-AC_SUBST(ibrcommon_CFLAGS) | |
-AC_SUBST(ibrcommon_LIBS) | |
- | |
-# check for ibrdtn library | |
-LOCAL_IBRDTN_VERSION=0.10 | |
-LOCAL_CHECK_IBRDTN | |
-AC_SUBST(ibrdtn_CFLAGS) | |
-AC_SUBST(ibrdtn_LIBS) | |
- | |
-# Checks for header files required by dtntunnel | |
-AC_CHECK_HEADERS([arpa/inet.h fcntl.h sys/ioctl.h sys/socket.h]) | |
-AC_CHECK_HEADER([linux/if_tun.h], [ | |
- has_tun="yes" | |
-]) | |
- | |
-# Checks for typedefs, structures, and compiler characteristics. | |
-AC_HEADER_STDBOOL | |
-AC_TYPE_INT16_T | |
-AC_TYPE_SIZE_T | |
-AC_TYPE_SSIZE_T | |
-AC_TYPE_UINT16_T | |
-AC_TYPE_UINT32_T | |
-AC_TYPE_UINT8_T | |
- | |
-# Checks for library functions. | |
-AC_FUNC_MALLOC | |
-AC_CHECK_FUNCS([memset]) | |
- | |
-PKG_CHECK_MODULES(DAEMON, libdaemon >= 0.12, [ | |
- AC_SUBST(DAEMON_CFLAGS) | |
- AC_SUBST(DAEMON_LIBS) | |
- AC_DEFINE(HAVE_LIBDAEMON, [1], ["daemon library is available"]) | |
- AC_CHECK_LIB(daemon, daemon_reset_sigs, [ | |
- AC_DEFINE(HAVE_DAEMON_RESET_SIGS, [1], ["daemon library has daemon_reset_sigs() and daemon_unblock_sigs() functions"]) | |
+# ANDROID configuration | |
+# We generate a mostly static configuration for Android as PKG_CHECK_MODULES obviously does not work with the Android NDK | |
+AC_ARG_ENABLE([android], | |
+ AS_HELP_STRING([--enable-android], [Enable compile switches for Android])) | |
+ | |
+AS_IF([test "x$enable_android" = "xyes"], [ | |
+ AC_MSG_WARN([Compiling for Android! Overriding other parameters!]) | |
+ | |
+ # Check for presence of androgenizer | |
+ AC_CHECK_PROG(ANDROGENIZER, androgenizer, androgenizer) | |
+ AS_IF([test -z "$ANDROGENIZER"], [ | |
+ AC_MSG_ERROR("Unable to find androgenizer in your PATH.") | |
]) | |
-], [ | |
- AC_MSG_WARN([daemon library not found, daemonize features disabled]) | |
-]) | |
- | |
-PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.0, [ | |
- AC_SUBST(ARCHIVE_CFLAGS) | |
- AC_SUBST(ARCHIVE_LIBS) | |
- AC_DEFINE(HAVE_LIBARCHIVE, [1], ["libarchive is available"]) | |
- has_libarchive="yes" | |
-], [ | |
- AC_MSG_WARN([libarchive not found, dtninbox and dtnoutbox will not be compiled]) | |
-]) | |
-PKG_CHECK_MODULES(OPENSSL, openssl, [ | |
- AC_SUBST(OPENSSL_CFLAGS) | |
- AC_SUBST(OPENSSL_LIBS) | |
- AC_DEFINE(HAVE_OPENSSL, [1], ["openssl available"]) | |
- has_openssl="yes" | |
-], [ | |
- AC_MSG_WARN([openssl not found, dtninbox and dtnoutbox will not be compiled]) | |
-]) | |
+ # Basic | |
+ AC_DEFINE(ANDROID, [1], [Compiling for Android!]) | |
-AC_ARG_WITH([tffs], | |
-AS_HELP_STRING([--with-tffs=PATH], [set the tffs path for fat-image support in dtnoutbox]), [ | |
- tffs_path=${withval} | |
- ] | |
-) | |
+ ibrdtn_LIBS="-librdtn" | |
+ AC_SUBST(ibrdtn_LIBS) | |
-AS_IF([test -z "${tffs_path}"], [ | |
- AC_MSG_WARN([tffs library path not defined. tffs support is disabled. use --with-tffs= to set path]) | |
+ # triggers other conditionals at the end | |
+ has_tun="no" | |
+ has_libarchive="no" | |
+ has_openssl="no" | |
+ has_tffs="no" | |
],[ | |
- AC_MSG_CHECKING([for LIBTFFS]) | |
- AS_IF([test -f "${tffs_path}/include/tffs.h"], [ | |
- AC_DEFINE(HAVE_LIBTFFS, [1], ["tffs found"]) | |
- tffs_LIBS="-L${tffs_path} -ltffs" | |
- tffs_CFLAGS="-I${tffs_path}/include" | |
- AC_SUBST(tffs_LIBS) | |
- AC_SUBST(tffs_CFLAGS) | |
- AC_MSG_RESULT([yes]) | |
- has_tffs="yes" | |
- ],[ | |
- AC_MSG_RESULT([no]) | |
+#ANDROID else begin | |
+ # Checks for libraries. | |
+ AC_CHECK_LIB([rt], [clock_gettime], []) | |
+ AC_CHECK_LIB([m], [pow], []) | |
+ | |
+ # check for ibrcommon library | |
+ LOCAL_IBRCOMMON_VERSION=0.10 | |
+ LOCAL_CHECK_IBRCOMMON | |
+ AC_SUBST(ibrcommon_CFLAGS) | |
+ AC_SUBST(ibrcommon_LIBS) | |
+ | |
+ # check for ibrdtn library | |
+ LOCAL_IBRDTN_VERSION=0.10 | |
+ LOCAL_CHECK_IBRDTN | |
+ AC_SUBST(ibrdtn_CFLAGS) | |
+ AC_SUBST(ibrdtn_LIBS) | |
+ | |
+ # Checks for header files required by dtntunnel | |
+ AC_CHECK_HEADERS([arpa/inet.h fcntl.h sys/ioctl.h sys/socket.h]) | |
+ AC_CHECK_HEADER([linux/if_tun.h], [ | |
+ has_tun="yes" | |
+ ]) | |
+ | |
+ # Checks for typedefs, structures, and compiler characteristics. | |
+ AC_HEADER_STDBOOL | |
+ AC_TYPE_INT16_T | |
+ AC_TYPE_SIZE_T | |
+ AC_TYPE_SSIZE_T | |
+ AC_TYPE_UINT16_T | |
+ AC_TYPE_UINT32_T | |
+ AC_TYPE_UINT8_T | |
+ | |
+ # Checks for library functions. | |
+ AC_FUNC_MALLOC | |
+ AC_CHECK_FUNCS([memset]) | |
+ | |
+ PKG_CHECK_MODULES(DAEMON, libdaemon >= 0.12, [ | |
+ AC_SUBST(DAEMON_CFLAGS) | |
+ AC_SUBST(DAEMON_LIBS) | |
+ AC_DEFINE(HAVE_LIBDAEMON, [1], ["daemon library is available"]) | |
+ AC_CHECK_LIB(daemon, daemon_reset_sigs, [ | |
+ AC_DEFINE(HAVE_DAEMON_RESET_SIGS, [1], ["daemon library has daemon_reset_sigs() and daemon_unblock_sigs() functions"]) | |
]) | |
+ ], [ | |
+ AC_MSG_WARN([daemon library not found, daemonize features disabled]) | |
+ ]) | |
+ | |
+ PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.0, [ | |
+ AC_SUBST(ARCHIVE_CFLAGS) | |
+ AC_SUBST(ARCHIVE_LIBS) | |
+ AC_DEFINE(HAVE_LIBARCHIVE, [1], ["libarchive is available"]) | |
+ has_libarchive="yes" | |
+ ], [ | |
+ AC_MSG_WARN([libarchive not found, dtninbox and dtnoutbox will not be compiled]) | |
+ ]) | |
+ | |
+ PKG_CHECK_MODULES(OPENSSL, openssl, [ | |
+ AC_SUBST(OPENSSL_CFLAGS) | |
+ AC_SUBST(OPENSSL_LIBS) | |
+ AC_DEFINE(HAVE_OPENSSL, [1], ["openssl available"]) | |
+ has_openssl="yes" | |
+ ], [ | |
+ AC_MSG_WARN([openssl not found, dtninbox and dtnoutbox will not be compiled]) | |
+ ]) | |
+ | |
+ AC_ARG_WITH([tffs], | |
+ AS_HELP_STRING([--with-tffs=PATH], [set the tffs path for fat-image support in dtnoutbox]), [ | |
+ tffs_path=${withval} | |
+ ] | |
+ ) | |
+ | |
+ AS_IF([test -z "${tffs_path}"], [ | |
+ AC_MSG_WARN([tffs library path not defined. tffs support is disabled. use --with-tffs= to set path]) | |
+ ],[ | |
+ AC_MSG_CHECKING([for LIBTFFS]) | |
+ AS_IF([test -f "${tffs_path}/include/tffs.h"], [ | |
+ AC_DEFINE(HAVE_LIBTFFS, [1], ["tffs found"]) | |
+ tffs_LIBS="-L${tffs_path} -ltffs" | |
+ tffs_CFLAGS="-I${tffs_path}/include" | |
+ AC_SUBST(tffs_LIBS) | |
+ AC_SUBST(tffs_CFLAGS) | |
+ AC_MSG_RESULT([yes]) | |
+ has_tffs="yes" | |
+ ],[ | |
+ AC_MSG_RESULT([no]) | |
+ ]) | |
+ ]) | |
+ | |
+#ANDROID else end | |
]) | |
AM_CONDITIONAL([TUNNEL], [test x$has_tun = xyes]) | |
AM_CONDITIONAL([LIBARCHIVE], [test x$has_libarchive = xyes]) | |
AM_CONDITIONAL([OPENSSL], [test x$has_openssl = xyes]) | |
AM_CONDITIONAL([TFFS], [test x$has_tffs = xyes]) | |
+AM_CONDITIONAL([ANDROID], [test x$enable_android = xyes]) | |
dnl ----------------------------------------------- | |
dnl Generates Makefiles, configuration files and scripts | |
diff --git a/ibrdtn/tools/src/Makefile.am b/ibrdtn/tools/src/Makefile.am | |
index 94522a9..16d0853 100644 | |
--- a/ibrdtn/tools/src/Makefile.am | |
+++ b/ibrdtn/tools/src/Makefile.am | |
@@ -4,6 +4,10 @@ AUTOMAKE_OPTIONS = foreign | |
AM_CPPFLAGS = -I@top_srcdir@/src @ibrdtn_CFLAGS@ @DAEMON_CFLAGS@ @ARCHIVE_CFLAGS@ @tffs_CFLAGS@ | |
AM_LDFLAGS = @ibrdtn_LIBS@ @DAEMON_LIBS@ @ARCHIVE_LIBS@ @tffs_LIBS@ | |
+if ANDROID | |
+noinst_DATA = Android.mk | |
+CLEANFILES = Android.mk | |
+else | |
# this lists the binaries to produce, the (non-PHONY, binary) targets in | |
# the previous manual Makefile | |
bin_PROGRAMS = dtnping dtnrecv dtnsend dtntracepath dtntrigger dtnconvert dtnstream | |
@@ -18,6 +22,7 @@ endif | |
if TUNNEL | |
sbin_PROGRAMS = dtntunnel | |
endif | |
+endif | |
if LIBARCHIVE | |
if OPENSSL | |
@@ -58,3 +63,51 @@ dtnstream_SOURCES = \ | |
streaming/BundleStreamBuf.h \ | |
streaming/StreamBundle.cpp \ | |
streaming/StreamBundle.h | |
+ | |
+ | |
+Android.mk: Makefile.am | |
+ $(ANDROGENIZER) -:PROJECT tools \ | |
+ -:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \ | |
+ -:EXECUTABLE dtnping \ | |
+ -:SOURCES $(dtnping_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ -:EXECUTABLE dtnrecv \ | |
+ -:SOURCES $(dtnrecv_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ -:EXECUTABLE dtnsend \ | |
+ -:SOURCES $(dtnsend_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ -:EXECUTABLE dtntracepath \ | |
+ -:SOURCES $(dtntracepath_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ -:EXECUTABLE dtnstream \ | |
+ -:SOURCES $(dtnstream_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ -:EXECUTABLE dtntrigger \ | |
+ -:SOURCES $(dtntrigger_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ -:EXECUTABLE dtnconvert \ | |
+ -:SOURCES $(dtnconvert_SOURCES) \ | |
+ -:CPPFLAGS $(CPPFLAGS) $(AM_CPPFLAGS) \ | |
+ -:LDFLAGS $(AM_LDFLAGS) \ | |
+ -lgnustl_shared \ | |
+ -librcommon \ | |
+ > $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment