diff --git a/configure.ac b/configure.ac index 63630ca1..6103353a 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ AC_PROG_CC # Checks for libraries. AC_DEFINE(_GNU_SOURCE) -#AC_CHECK_LIB(ssl, RC4) +PKG_CHECK_MODULES(DEPS, openssl) # 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]) @@ -38,6 +38,9 @@ AC_FUNC_MALLOC AC_FUNC_REALLOC 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 AC_SUBST([global_CFLAGS], [-funsigned-char]) diff --git a/lib/Makefile.am b/lib/Makefile.am index 4daf7ce7..c93d31c3 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,8 +2,9 @@ AM_CPPFLAGS = $(global_CFLAGS) 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_LIBADD=-lssl -lcrypto -lrt 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 pkgconfig_DATA = mist-1.0.pc diff --git a/lib/config.cpp b/lib/config.cpp index 9a771823..0bfafb79 100644 --- a/lib/config.cpp +++ b/lib/config.cpp @@ -5,7 +5,7 @@ #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) #include #else #include diff --git a/lib/procs.cpp b/lib/procs.cpp index ab1bbbf1..64022133 100644 --- a/lib/procs.cpp +++ b/lib/procs.cpp @@ -6,7 +6,7 @@ #include #include -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__MACH__) #include #else #include diff --git a/lib/timing.cpp b/lib/timing.cpp index f89523fa..3f9841c2 100644 --- a/lib/timing.cpp +++ b/lib/timing.cpp @@ -4,6 +4,23 @@ #include "timing.h" #include //for gettimeofday #include //for time and nanosleep + +//emulate clock_gettime() for OSX compatibility +#if defined(__APPLE__) || defined(__MACH__) +#include +#include +#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. void Util::sleep(int ms){ if (ms < 0){