Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Corrected build for android.
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
  • Loading branch information
OuNao authored and perexg committed Aug 16, 2014
1 parent f78ce0a commit d91375d
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions configure
Expand Up @@ -39,6 +39,7 @@ OPTIONS=(
"dvbcsa:no"
"kqueue:no"
"dbus_1:auto"
"android:no"
)

#
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/descrambler/capmt.c
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/htsp_server.c
Expand Up @@ -54,7 +54,13 @@
#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>
Expand Down
4 changes: 4 additions & 0 deletions src/httpc.c
Expand Up @@ -40,6 +40,10 @@
#define SSL_OP_NO_COMPRESSION 0
#endif

#if ENABLE_ANDROID
#include <sys/socket.h>
#endif

struct http_client_ssl {
int connected;
int shutdown;
Expand Down
4 changes: 4 additions & 0 deletions src/input/mpegts/satip/satip.c
Expand Up @@ -34,6 +34,10 @@
#include <sys/socket.h>
#endif

#if ENABLE_ANDROID
#include <sys/socket.h>
#endif

static void satip_device_discovery_start( void );

/*
Expand Down
4 changes: 4 additions & 0 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -29,6 +29,10 @@
#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 );
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/satip/satip_rtsp.c
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions src/main.c
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/muxer.c
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/spawn.c
Expand Up @@ -33,6 +33,10 @@
#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;
Expand Down
2 changes: 1 addition & 1 deletion src/timeshift/timeshift_reader.c
Expand Up @@ -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 */
Expand Down
19 changes: 18 additions & 1 deletion src/tvheadend.h
Expand Up @@ -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

Expand All @@ -46,6 +46,23 @@

#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;
Expand Down
5 changes: 5 additions & 0 deletions src/tvhlog.h
Expand Up @@ -19,7 +19,12 @@
#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>

Expand Down
9 changes: 8 additions & 1 deletion src/tvhtime.c
Expand Up @@ -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>
Expand All @@ -14,6 +13,10 @@
#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;
Expand All @@ -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
Expand Down Expand Up @@ -72,13 +76,15 @@ ntp_shm_init ( void )

return shmptr;
}
#endif

/*
* Update time
*/
void
tvhtime_update ( struct tm *tm )
{
#if !ENABLE_ANDROID
time_t now;
struct timeval tv;
ntp_shm_t *ntp_shm;
Expand Down Expand Up @@ -122,6 +128,7 @@ tvhtime_update ( struct tm *tm )
ntp_shm->count++;
ntp_shm->valid = 1;
}
#endif
}

/* Initialise */
Expand Down
4 changes: 4 additions & 0 deletions src/upnp.c
Expand Up @@ -39,6 +39,10 @@
#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;
Expand Down
4 changes: 4 additions & 0 deletions src/webui/webui.c
Expand Up @@ -55,6 +55,10 @@
#include <sys/uio.h>
#endif

#if ENABLE_ANDROID
#include <sys/socket.h>
#endif

static int webui_xspf;

/**
Expand Down

0 comments on commit d91375d

Please sign in to comment.