]> sigrok.org Git - libserialport.git/blobdiff - configure.ac
Implement FreeBSD OS-specific serial port detection and query
[libserialport.git] / configure.ac
index 22c47ce4ebfe2d41f1109562f72ef4f331dd2391..4cd1278cd171ef430352d268a3568dfd7ec0c6d0 100644 (file)
@@ -23,7 +23,7 @@ AC_PREREQ([2.63])
 
 # libserialport package version number (NOT the same as shared lib version!).
 m4_define([sp_package_version_major], [0])
-m4_define([sp_package_version_minor], [1])
+m4_define([sp_package_version_minor], [2])
 m4_define([sp_package_version_micro], [0])
 m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro])
 
@@ -39,8 +39,8 @@ AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 
-# Enable more compiler warnings via -Wall and -Wextra.
-CFLAGS="$CFLAGS -Wall -Wextra"
+# Enable more compiler warnings.
+CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic"
 
 # Checks for programs.
 AC_PROG_CC
@@ -83,11 +83,13 @@ case $target_os in
        AM_CONDITIONAL([LINUX], true)
        AM_CONDITIONAL([WIN32], false)
        AM_CONDITIONAL([MACOSX], false)
+       AM_CONDITIONAL([FREEBSD], false)
        ;;
 *darwin*)
        AM_CONDITIONAL([LINUX], false)
        AM_CONDITIONAL([WIN32], false)
        AM_CONDITIONAL([MACOSX], true)
+       AM_CONDITIONAL([FREEBSD], false)
        LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
        AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
        ;;
@@ -95,12 +97,20 @@ mingw* | cygwin*)
        AM_CONDITIONAL([LINUX], false)
        AM_CONDITIONAL([WIN32], true)
        AM_CONDITIONAL([MACOSX], false)
+       AM_CONDITIONAL([FREEBSD], false)
        SP_LIBS="-lsetupapi -luuid"
        ;;
+*freebsd*)
+       AM_CONDITIONAL([LINUX], false)
+       AM_CONDITIONAL([WIN32], false)
+       AM_CONDITIONAL([MACOSX], false)
+       AM_CONDITIONAL([FREEBSD], true)
+       ;;
 *)
        AM_CONDITIONAL([LINUX], false)
        AM_CONDITIONAL([WIN32], false)
        AM_CONDITIONAL([MACOSX], false)
+       AM_CONDITIONAL([FREEBSD], false)
        AC_DEFINE(NO_ENUMERATION)
        AC_DEFINE(NO_PORT_METADATA)
 esac
@@ -119,8 +129,24 @@ AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
 AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
        [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]])
 
-# Check for readlinkat.
-AC_CHECK_FUNC([readlinkat], [AC_DEFINE(HAVE_READLINKAT, 1)], [])
+# Check for the BOTHER definition, needed for setting arbitrary baud rates.
+# We can't just #ifdef BOTHER in the code, because of the separation between
+# code using libc headers and code using kernel termios.h headers.
+AC_MSG_CHECKING(for BOTHER)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <linux/termios.h>
+]],
+[[
+#ifndef BOTHER
+#error BOTHER is not defined
+#endif
+]])],
+[AC_DEFINE(HAVE_BOTHER, 1)
+AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
+
+# Check for serial_struct.
+AC_CHECK_TYPE([struct serial_struct], [AC_DEFINE(HAVE_SERIAL_STRUCT, 1)],
+        [], [[#include <linux/serial.h>]])
 
 saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[