2 ## This file is part of the libserialport project.
4 ## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
5 ## Copyright (C) 2013 Martin Ling <martin-libserialport@earth.li>
7 ## This program is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU Lesser General Public License as
9 ## published by the Free Software Foundation, either version 3 of the
10 ## License, or (at your option) any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU Lesser General Public License
18 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # We require at least autoconf 2.63 (AC_INIT format changed there).
24 # libserialport package version number (NOT the same as shared lib version!).
25 m4_define([sp_package_version_major], [0])
26 m4_define([sp_package_version_minor], [1])
27 m4_define([sp_package_version_micro], [1])
28 m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro])
30 AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li],
31 [libserialport], [http://sigrok.org/wiki/Libserialport])
32 AC_CONFIG_HEADERS([config.h libserialport.h])
33 AC_CONFIG_MACRO_DIR([autostuff])
34 AC_CONFIG_AUX_DIR([autostuff])
36 AH_BOTTOM([#if HAVE_STRUCT_TERMIOS_C_ISPEED && HAVE_STRUCT_TERMIOS_C_OSPEED
37 # define HAVE_TERMIOS_SPEED 1
39 #if HAVE_STRUCT_TERMIOS2_C_ISPEED && HAVE_STRUCT_TERMIOS2_C_OSPEED
40 # define HAVE_TERMIOS2_SPEED 1
43 # We require at least automake 1.11 (needed for 'silent rules').
44 AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define check-news])
45 AM_SILENT_RULES([yes])
46 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
48 # Checks for programs.
56 AC_DEFINE([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major], [.])
57 AC_DEFINE([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor], [.])
58 AC_DEFINE([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.])
59 AC_DEFINE([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.])
60 AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version])
62 # Library version for libserialport (NOT the same as the package version).
63 # Carefully read the libtool docs before updating these numbers!
64 # The algorithm for determining which number to change (and how) is nontrivial!
65 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
66 SP_LIB_VERSION_CURRENT=1
67 SP_LIB_VERSION_REVISION=0
69 AC_SUBST([SP_LIB_VERSION],
70 ["$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"])
72 AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [$SP_LIB_VERSION_CURRENT], [.])
73 AC_DEFINE_UNQUOTED([SP_LIB_VERSION_REVISION], [$SP_LIB_VERSION_REVISION], [.])
74 AC_DEFINE_UNQUOTED([SP_LIB_VERSION_AGE], [$SP_LIB_VERSION_AGE], [.])
75 AC_DEFINE_UNQUOTED([SP_LIB_VERSION_STRING], ["$SP_LIB_VERSION"], [.])
77 AM_CONDITIONAL([LINUX], [test -z "${host_os##linux*}" || test -z "${host_os##uclinux*}"])
78 AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"])
79 AM_CONDITIONAL([MACOSX], [test -z "${host_os##darwin*}"])
80 AM_CONDITIONAL([FREEBSD], [test -z "${host_os##freebsd*}"])
82 AM_COND_IF([WIN32], [SP_LIBS='-lsetupapi'], [SP_LIBS=])
85 AM_COND_IF([MACOSX], [AC_CHECK_HEADER([IOKit/IOKitLib.h], [],
86 [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])])
88 AS_CASE([$host_os], [linux*|darwin*|mingw*|cygwin*|freebsd*],, [
89 AC_DEFINE([NO_ENUMERATION], [1], [Enumeration is unsupported.])
90 AC_DEFINE([NO_PORT_METADATA], [1], [Port metadata is unavailable.])
95 # Define size_t if not defined as standard.
98 # Check for specific termios structures.
99 AC_CHECK_TYPES([struct termios2, struct termiox],,,
100 [[#include <linux/termios.h>]])
101 AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed,
102 struct termios2.c_ispeed, struct termios2.c_ospeed],,,
103 [[#include <linux/termios.h>]])
105 # Check for the BOTHER definition, needed for setting arbitrary baud rates.
106 # We can't just #ifdef BOTHER in the code, because of the separation between
107 # code using libc headers and code using kernel termios.h headers.
108 AC_CHECK_DECLS([BOTHER],,, [[#include <linux/termios.h>]])
110 # Check for serial_struct.
111 AC_CHECK_TYPES([struct serial_struct],,, [[#include <linux/serial.h>]])
113 AC_CACHE_CHECK([for visibility control], [sp_cv_visibility_control], [
114 sp_saved_CFLAGS=$CFLAGS
115 CFLAGS="$CFLAGS -Werror"
116 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
117 [[__attribute__((visibility("hidden"))) void foo(void) {}]])],
118 [sp_cv_visibility_control=attribute],
119 [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
120 [[__declspec(dllexport) void foo(void) {}]])],
121 [sp_cv_visibility_control=declspec],
122 [sp_cv_visibility_control=none])])
123 CFLAGS=$sp_saved_CFLAGS
125 AS_CASE([$sp_cv_visibility_control],
126 [attribute], [SP_API='__attribute__((visibility("default")))'
127 SP_PRIV='__attribute__((visibility("hidden")))'],
128 [declspec], [SP_API='__declspec(dllexport)' SP_PRIV=],
130 AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions])
131 AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions])
133 AC_CONFIG_FILES([Makefile libserialport.pc])
137 cat >&AS_MESSAGE_FD <<_EOF
139 libserialport configuration summary:
141 - Package version................. $SP_PACKAGE_VERSION
142 - Library ABI version............. $SP_LIB_VERSION
143 - Prefix.......................... $prefix
144 - Building on..................... $build
145 - Building for.................... $host