+AS_CASE([$host_os], [linux*|darwin*|mingw*|cygwin*|freebsd*],, [
+ AC_DEFINE([NO_ENUMERATION], [1], [Enumeration is unsupported.])
+ AC_DEFINE([NO_PORT_METADATA], [1], [Port metadata is unavailable.])
+])
+
+AC_SYS_LARGEFILE
+
+# Define size_t if not defined as standard.
+AC_TYPE_SIZE_T
+
+# Check for specific termios structures.
+AC_CHECK_TYPES([struct termios2, struct termiox],,,
+ [[#include <linux/termios.h>]])
+AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed,
+ struct termios2.c_ispeed, struct termios2.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_CHECK_DECLS([BOTHER],,, [[#include <linux/termios.h>]])
+
+# Check for serial_struct.
+AC_CHECK_TYPES([struct serial_struct],,, [[#include <linux/serial.h>]])
+
+AC_CACHE_CHECK([for visibility control], [sp_cv_visibility_control], [
+ sp_saved_CFLAGS=$CFLAGS
+ CFLAGS="$CFLAGS -Werror"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+ [[__attribute__((visibility("hidden"))) void foo(void) {}]])],
+ [sp_cv_visibility_control=attribute],
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+ [[__declspec(dllexport) void foo(void) {}]])],
+ [sp_cv_visibility_control=declspec],
+ [sp_cv_visibility_control=none])])
+ CFLAGS=$sp_saved_CFLAGS
+])
+AS_CASE([$sp_cv_visibility_control],
+ [attribute], [SP_API='__attribute__((visibility("default")))'
+ SP_PRIV='__attribute__((visibility("hidden")))'],
+ [declspec], [SP_API='__declspec(dllexport)' SP_PRIV=],
+ [SP_API= SP_PRIV=])
+AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions])
+AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions])
+
+AC_CONFIG_FILES([Makefile libserialport.pc])