Port to Android
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..c3c0990
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,20 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := lrz.c timing.c zperr.c zreadline.c crctab.c rbsb.c zm.c protname.c tcp.c lsyslog.c canit.c long-options.c xstrtol.c xstrtoul.c error.c
+LOCAL_MODULE_TAGS :=
+LOCAL_MODULE := rz
+LOCAL_CFLAGS := -DNFGVMIN -DHAVE_CONFIG_H=1
+LOCAL_SHARED_LIBRARIES := libc
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := lsz.c timing.c zperr.c zreadline.c crctab.c rbsb.c zm.c protname.c tcp.c lsyslog.c canit.c long-options.c xstrtol.c xstrtoul.c error.c
+LOCAL_MODULE_TAGS :=
+LOCAL_MODULE := sz
+LOCAL_CFLAGS := -DNFGVMIN -DHAVE_CONFIG_H=1
+LOCAL_SHARED_LIBRARIES := libc
+
+include $(BUILD_EXECUTABLE)
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..a363951
--- /dev/null
+++ b/config.h
@@ -0,0 +1,79 @@
+#define HAVE_ALLOCA 1
+#define HAVE_ALLOCA_H 1
+#define HAVE_MMAP 1
+#define HAVE_ST_RDEV 1
+#define RETSIGTYPE void
+#define STDC_HEADERS 1
+#define TIME_WITH_SYS_TIME 1
+#define HAVE_FTIME 1
+#define HAVE_TIMEZONE_VAR 1
+#define HAVE_GETTEXT 1
+#define HAVE_LC_MESSAGES 1
+#define PACKAGE "lrzsz"
+#define PACKAGE_VERSION "lrzsz-0.12.21rc"
+#define VERSION "0.12.21rc"
+#define HAVE_STPCPY 1
+#define HAVE_STRUCT_UTIMBUF 1
+#define ENABLE_SYSLOG LOG_UUCP
+#define ENABLE_SYSLOG_DEFAULT 1
+#define ENABLE_MKDIR 1
+#define ENABLE_TIMESYNC 1
+#define HAVE_STRERROR 1
+#define HAVE_ERRNO_DECLARATION 1
+#define HAVE___ARGZ_COUNT 1
+#define HAVE___ARGZ_NEXT 1
+#define HAVE___ARGZ_STRINGIFY 1
+#define HAVE_DCGETTEXT 1
+#define HAVE_GETCWD 1
+#define HAVE_GETPAGESIZE 1
+#define HAVE_GETTIMEOFDAY 1
+#define HAVE_MEMCPY 1
+#define HAVE_MKDIR 1
+#define HAVE_MKTIME 1
+#define HAVE_MUNMAP 1
+#define HAVE_PUTENV 1
+#define HAVE_SELECT 1
+#define HAVE_SETENV 1
+#define HAVE_SETLOCALE 1
+#define HAVE_SETTIMEOFDAY 1
+#define HAVE_SIGINTERRUPT 1
+#define HAVE_STPCPY 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRCHR 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRPBRK 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_SYSLOG 1
+#define HAVE_TIMES 1
+#define HAVE_UTIME 1
+#define HAVE_VASPRINTF 1
+#define HAVE_VPRINTF 1
+#define HAVE_ARGZ_H 1
+#define HAVE_ARPA_INET_H 1
+#define HAVE_FCNTL_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_LOCALE_H 1
+#define HAVE_NL_TYPES_H 1
+#define HAVE_SGTTY_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_MMAN_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_SYSLOG_H 1
+#define HAVE_SYS_TERMIOS_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TIMES_H 1
+#define HAVE_SYSLOG_H 1
+#define HAVE_TERMIOS_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_UTIME_H 1
+#define HAVE_LIBNSL 1
+#define PACKAGE "lrzsz"
+#define VERSION "0.12.21rc"
+#define PROTOTYPES 1
diff --git a/error.c b/error.c
index 8b96b91..b1b197b 100644
--- a/error.c
+++ b/error.c
@@ -36,7 +36,7 @@
 # define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
 #endif
 
-#if STDC_HEADERS || _LIBC
+#if 1//STDC_HEADERS || _LIBC
 # include <stdlib.h>
 # include <string.h>
 #else
diff --git a/long-options.c b/long-options.c
index fe069fd..5df1d92 100644
--- a/long-options.c
+++ b/long-options.c
@@ -22,6 +22,7 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <getopt.h>
 #include "long-options.h"
 
diff --git a/lrz.c b/lrz.c
index 9202f59..d98f401 100644
--- a/lrz.c
+++ b/lrz.c
@@ -44,6 +44,7 @@
 #ifndef STRICT_PROTOTYPES
 extern time_t time();
 extern char *strerror();
+extern char *strstr();
 #endif
 
 #ifndef HAVE_ERRNO_DECLARATION
@@ -2295,7 +2296,7 @@
 	if (*s == '!')
 		++s;
 	io_mode(0,0);
-	execl("/bin/sh", "sh", "-c", s);
+	execl("/bin/sh", "sh", "-c", s, NULL);
 	zpfatal("execl");
 	exit(1);
 }
diff --git a/rbsb.c b/rbsb.c
index 88b977c..be9a54f 100644
--- a/rbsb.c
+++ b/rbsb.c
@@ -54,6 +54,15 @@
 # endif
 #endif
 
+/* Android lacks tcdrain() */
+#ifdef ANDROID
+#include <sys/ioctl.h>
+static inline int tcdrain(int fd)
+{
+	return ioctl(fd, TCSBRK, 1);
+}
+#endif
+
 #if defined(HOWMANY) && HOWMANY  > 255
 #ifndef NFGVMIN
 Howmany must be 255 or less
diff --git a/zglobal.h b/zglobal.h
index 0f59dba..e5f657a 100644
--- a/zglobal.h
+++ b/zglobal.h
@@ -27,8 +27,10 @@
 #include <sys/types.h>
 
 #ifdef __GNUC__
+#ifndef HAVE_ALLOCA
 # define alloca __builtin_alloca
 # define HAVE_ALLOCA 1
+#endif
 #else
 # if defined HAVE_ALLOCA_H || defined _LIBC
 #  include <alloca.h>