1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

Fix building on OSX and Linux.

This commit is contained in:
Martin Ling 2013-11-02 19:14:36 +00:00 committed by Uwe Hermann
parent bdfb5b8c08
commit 1ebf4347e0
2 changed files with 18 additions and 3 deletions

View File

@ -31,6 +31,8 @@ AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li],
AC_CONFIG_MACRO_DIR([autostuff]) AC_CONFIG_MACRO_DIR([autostuff])
AC_CONFIG_AUX_DIR([autostuff]) AC_CONFIG_AUX_DIR([autostuff])
AC_CANONICAL_TARGET
# We require at least automake 1.11 (needed for 'silent rules'). # We require at least automake 1.11 (needed for 'silent rules').
AM_INIT_AUTOMAKE([1.11 -Wall -Werror]) AM_INIT_AUTOMAKE([1.11 -Wall -Werror])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@ -77,6 +79,18 @@ AC_SUBST(SP_LIB_LDFLAGS)
# These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h. # These are already checked: inttypes.h stdint.h stdlib.h string.h unistd.h.
AC_CHECK_HEADERS([sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h errno.h]) AC_CHECK_HEADERS([sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h errno.h])
case $target_os in
*linux*)
PKG_CHECK_MODULES([libudev], [libudev >= 0],
[CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS"],
[AC_MSG_ERROR([libudev.h not found])])
;;
*darwin*)
LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
;;
esac
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE AC_C_INLINE
AC_TYPE_SIZE_T AC_TYPE_SIZE_T

View File

@ -34,8 +34,9 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
#include <IOKitLib.h> #include <IOKit/IOKitLib.h>
#include <serial/IOSerialKeys.h> #include <IOKit/serial/IOSerialKeys.h>
#include <sys/syslimits.h>
#endif #endif
#ifdef __linux__ #ifdef __linux__
#include "libudev.h" #include "libudev.h"
@ -148,7 +149,7 @@ out_close:
if (!(list = sp_list_new())) if (!(list = sp_list_new()))
goto out; goto out;
while (port = IOIteratorNext(iter)) { while ((port = IOIteratorNext(iter))) {
cf_path = IORegistryEntryCreateCFProperty(port, cf_path = IORegistryEntryCreateCFProperty(port,
CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0); CFSTR(kIOCalloutDeviceKey), kCFAllocatorDefault, 0);
if (cf_path) { if (cf_path) {