]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Corrected build for android.
authorSergio Costa Fortier <sergiofortier@yahoo.com.br>
Sat, 2 Aug 2014 01:17:51 +0000 (22:17 -0300)
committerJaroslav Kysela <perex@perex.cz>
Sat, 16 Aug 2014 13:54:08 +0000 (15:54 +0200)
Included --enable-android on configure script.
Build with that sample script:
#!/bin/sh
# Make sure you have TOOLCHAIN defined in .bashrc or .bash_profile and have linux/dvb headers in include dir.
SRC_DIR="`pwd`/tvheadend"
INCLUDE_DIR="`pwd`/out/include"
cd $SRC_DIR
export SYS_ROOT="$TOOLCHAIN/sysroot"
export CC="arm-linux-androideabi-gcc --sysroot=$SYS_ROOT -I$INCLUDE_DIR"
export CXX="arm-linux-androideabi-g++ --sysroot=$SYS_ROOT -I$INCLUDE_DIR"
export CPP="arm-linux-androideabi-cpp"
export LD="arm-linux-androideabi-ld"
export AR="arm-linux-androideabi-ar"
export RANLIB="arm-linux-androideabi-ranlib"
export STRIP="arm-linux-androideabi-strip"
export CROSSCOMPILE="arm-linux-androideabi-"
export CFLAGS="--sysroot=$SYS_ROOT -I$INCLUDE_DIR"
export CXXFLAGS="--sysroot=$SYS_ROOT -I$INCLUDE_DIR"
export LIBS="-lc -lgcc"
./configure --prefix=$SYS_ROOT/usr --arch=armv7  --platform=linux --disable-avahi --enable-bundle --python=/usr/bin/python --enable-android
make
TODO: change shm code to ashmem on tvhtime.c

17 files changed:
Makefile
configure
src/descrambler/capmt.c
src/htsp_server.c
src/httpc.c
src/input/mpegts/satip/satip.c
src/input/mpegts/satip/satip_frontend.c
src/input/mpegts/satip/satip_rtsp.c
src/main.c
src/muxer.c
src/spawn.c
src/timeshift/timeshift_reader.c
src/tvheadend.h
src/tvhlog.h
src/tvhtime.c
src/upnp.c
src/webui/webui.c

index 3ed7cb3f9cc8e6a891efa4505a0e282be4737738..9aa4c94604965323932251d0bd38e6e70674c1fe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,15 +33,21 @@ CFLAGS  += -Wmissing-prototypes
 CFLAGS  += -fms-extensions -funsigned-char -fno-strict-aliasing
 CFLAGS  += -D_FILE_OFFSET_BITS=64
 CFLAGS  += -I${BUILDDIR} -I${ROOTDIR}/src -I${ROOTDIR}
+ifeq ($(CONFIG_ANDROID),yes)
+LDFLAGS += -ldl -lm
+else
 LDFLAGS += -ldl -lpthread -lm
+endif
 ifeq ($(CONFIG_LIBICONV),yes)
 LDFLAGS += -liconv
 endif
 ifeq ($(PLATFORM), darwin)
 LDFLAGS += -framework CoreServices
 else
+ifeq ($(CONFIG_ANDROID),no)
 LDFLAGS += -lrt
 endif
+endif
 
 ifeq ($(COMPILER), clang)
 CFLAGS  += -Wno-microsoft -Qunused-arguments -Wno-unused-function
index 2256629993319825bb9dcbf817745a7bc93af169..96839f6e71997c1febf651657d77992ae44e79ab 100755 (executable)
--- a/configure
+++ b/configure
@@ -39,6 +39,7 @@ OPTIONS=(
   "dvbcsa:no"
   "kqueue:no"
   "dbus_1:auto"
+  "android:no"
 )
 
 #
@@ -166,6 +167,8 @@ if [ ${PLATFORM} = "freebsd" ]; then
   enable ssl
 elif check_pkg openssl || check_pkg libssl; then
   enable ssl
+elif check_cc_header 'openssl/ssl' ssl; then
+  enable ssl
 else
   die "SSL development support not found"
 fi
index 40a21c9a825e255132d5fb194ae3606b1f374de1..e9a62acedd5bcfbaa77fcfedfc3ec4ca6f1b6cb8 100644 (file)
@@ -627,7 +627,7 @@ capmt_write_msg(capmt_t *capmt, int adapter, int sid, const uint8_t *buf, size_t
 
   res = send(fd, buf, len, MSG_DONTWAIT);
   if (res < len) {
-    tvhlog(LOG_DEBUG, "capmt", "Message send failed to socket %i (%zi)", fd, res);
+    tvhlog(LOG_DEBUG, "capmt", "Message send failed to socket %i (%li)", fd, res);
     if (capmt->capmt_oscam != CAPMT_OSCAM_SO_WRAPPER) {
       capmt_socket_close_lock(capmt, i);
       return -1;
index 94e91e16a1df145247e1c1a9c51ecf1ac56ec11f..e84c22b88fbc7d525e2c9ba3bd122486daa4d466 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#if ENABLE_ANDROID
+#include <sys/vfs.h>
+#define statvfs statfs
+#define fstatvfs fstatfs
+#else
 #include <sys/statvfs.h>
+#endif
 #include "settings.h"
 #include <sys/time.h>
 #include <limits.h>
index ac88ba3c48ec35cafce4e3c87193efdfeacb3a35..8f64ef74346c239b69f5bea8d5681fe300984f4b 100644 (file)
 #define SSL_OP_NO_COMPRESSION 0
 #endif
 
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
+
 struct http_client_ssl {
   int      connected;
   int      shutdown;
index 333244750b0ee493fc5e830941d3acef748c1dca..901a00923eba38354e71d52089147c78e116a139 100644 (file)
 #include <sys/socket.h>
 #endif
 
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
+
 static void satip_device_discovery_start( void );
 
 /*
index a0c7eb2502476e4b692ed5a84a257841a98075b0..a735e504eb012a019e68b235eced8fb58d022d53 100644 (file)
 #include <sys/socket.h>
 #endif
 
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
+
 static int
 satip_frontend_tune1
   ( satip_frontend_t *lfe, mpegts_mux_instance_t *mmi );
index cf6ed2a223fee3a7166e96e1687dde7779d87d49..ae0b265cd262a3223d37f2735688fc6dca0a3e33 100644 (file)
@@ -226,7 +226,7 @@ satip_rtsp_pids_strip( const char *s, int maxlen )
   while (*s == ',')
     s++;
   while (strlen(s) > maxlen) {
-    ptr = rindex(s, ',');
+    ptr = strrchr(s, ',');
     if (ptr == NULL)
       abort();
     *ptr = '\0';
index 16fb19ebdb7854500f7b55a978bd3ea02e7e0e2a..3628ec8dfacdf5e69cc622f7eb0814b96c253e64 100644 (file)
@@ -196,6 +196,7 @@ static int
 get_user_groups (const struct passwd *pw, gid_t* glist, size_t gmax)
 {
   int num = 0;
+#if !ENABLE_ANDROID
   struct group *gr;
   char **mem;
   glist[num++] = pw->pw_gid;
@@ -205,6 +206,7 @@ get_user_groups (const struct passwd *pw, gid_t* glist, size_t gmax)
       if(!strcmp(*mem, pw->pw_name)) glist[num++] = gr->gr_gid;
     }
   }
+#endif
   return num;
 }
 
index a359c748409b1c0efca037f72af925d752a65eeb..bf78b1e85ad1f036c08285d39cb2daa1d2a986b0 100644 (file)
@@ -460,7 +460,7 @@ muxer_cache_update(muxer_t *m, int fd, off_t pos, size_t size)
   case MC_CACHE_DONTKEEP:
 #if defined(PLATFORM_DARWIN)
     fcntl(fd, F_NOCACHE, 1);
-#else
+#elseif !ENABLE_ANDROID
     posix_fadvise(fd, pos, size, POSIX_FADV_DONTNEED);
 #endif
     break;
index 534e5af7e4a6e1cb49555520ee0361120977eb69..b1bdacbf8f8b05807a0971a882413435ed1bd226 100644 (file)
 #include "file.h"
 #include "spawn.h"
 
+#if ENABLE_ANDROID
+#define WIFCONTINUED(s) ((s) == 0xffff)
+#endif
+
 extern char **environ;
 
 pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER;
index a73d2df7195095c0f82729d3e00749befeefed15..fb94957dbb1bab9ecd7f1d3fa5bad13a409f7ae0 100644 (file)
@@ -336,7 +336,7 @@ static int _timeshift_read
       tvhlog(LOG_ERR, "timeshift", "ts %d could not read buffer", ts->id);
       return -1;
     }
-    tvhtrace("timeshift", "ts %d read msg %p (%zd)",
+    tvhtrace("timeshift", "ts %d read msg %p (%ld)",
              ts->id, *sm, r);
 
     /* Incomplete */
index 020812b7447a578cab37a9050822f1fd9eb3ba46..81c92c4073ea71b47383f9f90cb33ac0a4c64ec1 100644 (file)
@@ -32,7 +32,7 @@
 #include <assert.h>
 #include <unistd.h>
 #include <limits.h>
-#if ENABLE_LOCKOWNER
+#if ENABLE_LOCKOWNER || ENABLE_ANDROID
 #include <sys/syscall.h>
 #endif
 
 
 #define ERRNO_AGAIN(e) ((e) == EAGAIN || (e) == EINTR || (e) == EWOULDBLOCK)
 
+#if ENABLE_ANDROID
+#define S_IEXEC S_IXUSR
+#include <time64.h>
+// 32-bit Android has only timegm64() and not timegm().
+// We replicate the behaviour of timegm() when the result overflows time_t.
+static inline time_t timegm(struct tm* const t);
+time_t timegm(struct tm* const t) {
+  // time_t is signed on Android.
+  static const time_t kTimeMax = ~(1L << (sizeof(time_t) * CHAR_BIT - 1));
+  static const time_t kTimeMin = (1L << (sizeof(time_t) * CHAR_BIT - 1));
+  time64_t result = timegm64(t);
+  if (result < kTimeMin || result > kTimeMax)
+    return -1;
+  return result;
+}
+#endif
+
 typedef struct {
   const char     *name;
   const uint32_t *enabled;
index 06bb47326be199f6d3b4d60ad8222ba1d85005f4..f9c2d3256800f79620d1316fed5251033ba5ba99 100644 (file)
 #define __TVH_LOGGING_H__
 
 #include <sys/types.h>
+#include "build.h"
+#if ENABLE_ANDROID
+#include <syslog.h>
+#else
 #include <sys/syslog.h>
+#endif
 #include <pthread.h>
 #include <stdarg.h>
 
index 589840af59e35431e35d18f077fbe9e437d3af4e..9bee7609fd3630eaa1b3aaf78772338d663e5e6d 100644 (file)
@@ -2,7 +2,6 @@
 
 #include <time.h>
 #include <sys/ipc.h>
-#include <sys/shm.h>
 #include <sys/time.h>
 #include <stdio.h>
 #include <string.h>
 #include "tvheadend.h"
 #include "settings.h"
 
+#if !ENABLE_ANDROID
+#include <sys/shm.h>
+#endif
+
 uint32_t tvhtime_update_enabled;
 uint32_t tvhtime_ntp_enabled;
 uint32_t tvhtime_tolerance;
@@ -24,6 +27,7 @@ uint32_t tvhtime_tolerance;
 #define NTPD_BASE      0x4e545030      /* "NTP0" */
 #define NTPD_UNIT      2
 
+#if !ENABLE_ANDROID
 typedef struct
 {
   int    mode; /* 0 - if valid set
@@ -72,6 +76,7 @@ ntp_shm_init ( void )
 
   return shmptr;
 }
+#endif
 
 /*
  * Update time
@@ -79,6 +84,7 @@ ntp_shm_init ( void )
 void
 tvhtime_update ( struct tm *tm )
 {
+#if !ENABLE_ANDROID
   time_t now;
   struct timeval tv;
   ntp_shm_t *ntp_shm;
@@ -122,6 +128,7 @@ tvhtime_update ( struct tm *tm )
     ntp_shm->count++;
     ntp_shm->valid = 1;
   }
+#endif
 }
 
 /* Initialise */
index cdbf3533c72b0b82c746b500b32f01229de3a848..25713d09966c8d1e6fd2420725b57c3303df5dd5 100644 (file)
 #include <sys/socket.h>
 #endif
 
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
+
 int              upnp_running;
 static pthread_t upnp_tid;
 pthread_mutex_t  upnp_lock;
index 7e57ba4732485591ef56623f01e6d946d35a6641..071ac7504f01edcf1ce1b1083f5c8c21ed82f8ee 100644 (file)
 #include <sys/uio.h>
 #endif
 
+#if ENABLE_ANDROID
+#include <sys/socket.h>
+#endif
+
 static int webui_xspf;
 
 /**