From b6d24bfa115b8ac9d4a16505c8eacacc2b195b15 Mon Sep 17 00:00:00 2001
From: Christian Beier <dontmind@freeshell.org>
Date: Sat, 23 Jul 2011 18:02:51 +0200
Subject: Adopt autotools build system to Android.

LibVNCServer/LibVNCClient now build for Android!
---
 configure.ac                 | 8 ++++++++
 examples/Makefile.am         | 4 ++++
 examples/android/Makefile.am | 6 ++++++
 rfb/rfb.h                    | 2 +-
 vncterm/Makefile.am          | 2 ++
 5 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 examples/android/Makefile.am

diff --git a/configure.ac b/configure.ac
index 3203d7a..c8aed19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -807,6 +807,13 @@ AM_CONDITIONAL(LINUX, test -c /dev/vcsa1)
 AC_CHECK_HEADER(ApplicationServices/ApplicationServices.h, HAVE_OSX="true")
 AM_CONDITIONAL(OSX, test "$HAVE_OSX" = "true")
 
+# Check for Android specific header
+AC_CHECK_HEADER(android/api-level.h, HAVE_ANDROID="true")
+AM_CONDITIONAL(ANDROID, test "$HAVE_ANDROID" = "true")
+if test "$HAVE_ANDROID" = "true"; then
+	AC_DEFINE(HAVE_ANDROID, 1, [Android host system detected])
+fi
+
 # On Solaris 2.7, write() returns ENOENT when it really means EAGAIN
 AH_TEMPLATE(ENOENT_WORKAROUND, [work around when write() returns ENOENT but does not mean it])
 case `(uname -sr) 2>/dev/null` in
@@ -833,6 +840,7 @@ AC_CONFIG_FILES([Makefile
 	libvncclient.pc
 	libvncserver/Makefile
 	examples/Makefile
+	examples/android/Makefile
 	vncterm/Makefile
 	classes/Makefile
 	classes/ssl/Makefile
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 92909bf..29d3774 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -6,6 +6,10 @@ MAC=mac
 mac_LDFLAGS=-framework ApplicationServices -framework Carbon -framework IOKit
 endif
 
+if ANDROID
+SUBDIRS=android
+endif
+
 if WITH_TIGHTVNC_FILETRANSFER
 FILETRANSFER=filetransfer
 endif
diff --git a/examples/android/Makefile.am b/examples/android/Makefile.am
new file mode 100644
index 0000000..23bfe8f
--- /dev/null
+++ b/examples/android/Makefile.am
@@ -0,0 +1,6 @@
+INCLUDES = -I$(top_srcdir)
+LDADD = $(top_srcdir)/libvncserver/libvncserver.la @WSOCKLIB@
+
+noinst_PROGRAMS=androidvncserver
+androidvncserver_SOURCES=jni/fbvncserver.c
+
diff --git a/rfb/rfb.h b/rfb/rfb.h
index abe1477..c6cf524 100644
--- a/rfb/rfb.h
+++ b/rfb/rfb.h
@@ -43,7 +43,7 @@ extern "C"
 #include <string.h>
 #include <rfb/rfbproto.h>
 
-#ifdef ANDROID
+#if defined(ANDROID) || defined(LIBVNCSERVER_HAVE_ANDROID)
 #include <arpa/inet.h>
 #include <sys/select.h>
 #endif
diff --git a/vncterm/Makefile.am b/vncterm/Makefile.am
index 3ad36a3..6ff0403 100644
--- a/vncterm/Makefile.am
+++ b/vncterm/Makefile.am
@@ -8,10 +8,12 @@ LDADD=../libvncserver/libvncserver.la @WSOCKLIB@
 
 if LINUX
 if ! MINGW
+if ! ANDROID
 bin_PROGRAMS=LinuxVNC
 LinuxVNC_SOURCES=LinuxVNC.c $(CONSOLE_SRCS)
 endif
 endif
+endif
 
 if ! MINGW
 VNCOMMAND=VNCommand
-- 
cgit v1.2.3

