+# Check for specific termios structures.
+AC_CHECK_TYPE([struct termios2],
+ [AC_DEFINE(HAVE_TERMIOS2, 1,
+ [struct termios2 is available.])],
+ [], [[#include <linux/termios.h>]])
+AC_CHECK_TYPE([struct termiox],
+ [AC_DEFINE(HAVE_TERMIOX, 1,
+ [struct termiox is available.])],
+ [], [[#include <linux/termios.h>]])
+AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
+ [AC_DEFINE(HAVE_TERMIOS_SPEED, 1,
+ [struct termios has c_ispeed/c_ospeed.])],
+ [], [[#include <linux/termios.h>]])
+AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
+ [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1,
+ [struct termios2 has c_ispeed/c_ospeed.])],
+ [], [[#include <linux/termios.h>]])
+
+# 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, [BOTHER macro is available])
+AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
+
+# Check for serial_struct.
+AC_CHECK_TYPE([struct serial_struct],
+ [AC_DEFINE(HAVE_SERIAL_STRUCT, 1,
+ [struct serial is available.])],
+ [], [[#include <linux/serial.h>]])
+
+saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
+AC_DEFINE(SP_API,,[Macro preceding public API functions])
+AC_DEFINE(SP_PRIV,,[Macro preceding private functions])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ __attribute__((visibility("hidden"))) void foo(void) { }
+ ]])],
+ [AC_DEFINE(SP_API , __attribute__((visibility("default"))))]
+ [AC_DEFINE(SP_PRIV, __attribute__((visibility("hidden"))))],
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ __declspec(dllexport) void foo(void) { }
+ ]])],
+ [AC_DEFINE(SP_API , __declspec(dllexport))]
+ [AC_DEFINE(SP_PRIV,)],
+ [AC_DEFINE(SP_API,)]
+ [AC_DEFINE(SP_PRIV,)]))
+CFLAGS="$saved"