Fixed compiling on OSX, also fixes DDVTECH/mistlib#1

This commit is contained in:
Thulinma 2013-03-14 00:13:07 +01:00
parent cc8dfb5257
commit aa5056ee3d
5 changed files with 25 additions and 4 deletions

View file

@ -16,7 +16,7 @@ AC_PROG_CC
# Checks for libraries. # Checks for libraries.
AC_DEFINE(_GNU_SOURCE) AC_DEFINE(_GNU_SOURCE)
#AC_CHECK_LIB(ssl, RC4) PKG_CHECK_MODULES(DEPS, openssl)
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
@ -38,6 +38,9 @@ AC_FUNC_MALLOC
AC_FUNC_REALLOC AC_FUNC_REALLOC
AC_CHECK_FUNCS([dup2 gettimeofday memset mkdir socket strerror]) AC_CHECK_FUNCS([dup2 gettimeofday memset mkdir socket strerror])
AC_CHECK_FUNCS([clock_gettime], [CLOCK_LIB=], [AC_CHECK_LIB([rt], [clock_gettime], [CLOCK_LIB=-lrt], [CLOCK_LIB=])])
AC_SUBST([CLOCK_LIB])
# Fix chars to unsigned # Fix chars to unsigned
AC_SUBST([global_CFLAGS], [-funsigned-char]) AC_SUBST([global_CFLAGS], [-funsigned-char])

View file

@ -2,8 +2,9 @@ AM_CPPFLAGS = $(global_CFLAGS)
lib_LTLIBRARIES=libmist-1.0.la lib_LTLIBRARIES=libmist-1.0.la
libmist_1_0_la_SOURCES=amf.h amf.cpp auth.h auth.cpp base64.h base64.cpp config.h config.cpp dtsc.h dtsc.cpp flv_tag.h flv_tag.cpp http_parser.h http_parser.cpp json.h json.cpp procs.h procs.cpp rtmpchunks.h rtmpchunks.cpp socket.h socket.cpp mp4.h mp4.cpp ftp.h ftp.cpp filesystem.h filesystem.cpp stream.h stream.cpp timing.h timing.cpp ts_packet.cpp ts_packet.h libmist_1_0_la_SOURCES=amf.h amf.cpp auth.h auth.cpp base64.h base64.cpp config.h config.cpp dtsc.h dtsc.cpp flv_tag.h flv_tag.cpp http_parser.h http_parser.cpp json.h json.cpp procs.h procs.cpp rtmpchunks.h rtmpchunks.cpp socket.h socket.cpp mp4.h mp4.cpp ftp.h ftp.cpp filesystem.h filesystem.cpp stream.h stream.cpp timing.h timing.cpp ts_packet.cpp ts_packet.h
libmist_1_0_la_LIBADD=-lssl -lcrypto -lrt
libmist_1_0_la_LDFLAGS = -version-info 4:0:1 libmist_1_0_la_LDFLAGS = -version-info 4:0:1
libmist_1_0_la_CPPFLAGS=$(DEPS_CFLAGS)
libmist_1_0_la_LIBADD=$(DEPS_LIBS) $(CLOCK_LIB)
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = mist-1.0.pc pkgconfig_DATA = mist-1.0.pc

View file

@ -5,7 +5,7 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__)
#include <sys/wait.h> #include <sys/wait.h>
#else #else
#include <wait.h> #include <wait.h>

View file

@ -6,7 +6,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__)
#include <sys/wait.h> #include <sys/wait.h>
#else #else
#include <wait.h> #include <wait.h>

View file

@ -4,6 +4,23 @@
#include "timing.h" #include "timing.h"
#include <sys/time.h>//for gettimeofday #include <sys/time.h>//for gettimeofday
#include <time.h>//for time and nanosleep #include <time.h>//for time and nanosleep
//emulate clock_gettime() for OSX compatibility
#if defined(__APPLE__) || defined(__MACH__)
#include <mach/clock.h>
#include <mach/mach.h>
#define CLOCK_REALTIME 0
void clock_gettime(int ign, struct timespec * ts){
clock_serv_t cclock;
mach_timespec_t mts;
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
ts->tv_sec = mts.tv_sec;
ts->tv_nsec = mts.tv_nsec;
}
#endif
/// Sleeps for the indicated amount of milliseconds or longer. /// Sleeps for the indicated amount of milliseconds or longer.
void Util::sleep(int ms){ void Util::sleep(int ms){
if (ms < 0){ if (ms < 0){