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], [2])
27 m4_define([sp_package_version_micro], [0])
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])
33 AC_CONFIG_MACRO_DIR([autostuff])
34 AC_CONFIG_AUX_DIR([autostuff])
38 # We require at least automake 1.11 (needed for 'silent rules').
39 AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news])
40 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
41 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
43 # Enable more compiler warnings.
44 CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic"
46 # Checks for programs.
55 # Initialize pkg-config.
56 # We require at least 0.22, as "Requires.private" behaviour changed there.
57 PKG_PROG_PKG_CONFIG([0.22])
59 # Library version for libserialport (NOT the same as the package version).
60 # Carefully read the libtool docs before updating these numbers!
61 # The algorithm for determining which number to change (and how) is nontrivial!
62 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
63 SP_LIB_VERSION_CURRENT=0
64 SP_LIB_VERSION_REVISION=0
66 SP_LIB_VERSION="$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"
67 SP_LIB_LDFLAGS="-version-info $SP_LIB_VERSION"
68 AC_SUBST(SP_LIB_VERSION_CURRENT)
69 AC_SUBST(SP_LIB_VERSION_REVISION)
70 AC_SUBST(SP_LIB_VERSION_AGE)
71 AC_SUBST(SP_LIB_VERSION)
72 AC_SUBST(SP_LIB_LDFLAGS)
74 # Checks for libraries.
76 # This variable collects the pkg-config names of all detected libs.
77 # It is then used to construct the "Requires.private:" field in the
78 # libserialport.pc file.
84 AM_CONDITIONAL([LINUX], true)
85 AM_CONDITIONAL([WIN32], false)
86 AM_CONDITIONAL([MACOSX], false)
87 AM_CONDITIONAL([FREEBSD], false)
90 AM_CONDITIONAL([LINUX], false)
91 AM_CONDITIONAL([WIN32], false)
92 AM_CONDITIONAL([MACOSX], true)
93 AM_CONDITIONAL([FREEBSD], false)
94 LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
95 AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
98 AM_CONDITIONAL([LINUX], false)
99 AM_CONDITIONAL([WIN32], true)
100 AM_CONDITIONAL([MACOSX], false)
101 AM_CONDITIONAL([FREEBSD], false)
102 SP_LIBS="-lsetupapi -luuid"
105 AM_CONDITIONAL([LINUX], false)
106 AM_CONDITIONAL([WIN32], false)
107 AM_CONDITIONAL([MACOSX], false)
108 AM_CONDITIONAL([FREEBSD], true)
111 AM_CONDITIONAL([LINUX], false)
112 AM_CONDITIONAL([WIN32], false)
113 AM_CONDITIONAL([MACOSX], false)
114 AM_CONDITIONAL([FREEBSD], false)
115 AC_DEFINE(NO_ENUMERATION,,[Enumeration is unsupported])
116 AC_DEFINE(NO_PORT_METADATA,,[Port metadata is unavailable])
122 # Define size_t if not defined as standard.
125 # Check for specific termios structures.
126 AC_CHECK_TYPE([struct termios2],
127 [AC_DEFINE(HAVE_TERMIOS2, 1,
128 [struct termios2 is available.])],
129 [], [[#include <linux/termios.h>]])
130 AC_CHECK_TYPE([struct termiox],
131 [AC_DEFINE(HAVE_TERMIOX, 1,
132 [struct termiox is available.])],
133 [], [[#include <linux/termios.h>]])
134 AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
135 [AC_DEFINE(HAVE_TERMIOS_SPEED, 1,
136 [struct termios has c_ispeed/c_ospeed.])],
137 [], [[#include <linux/termios.h>]])
138 AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
139 [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1,
140 [struct termios2 has c_ispeed/c_ospeed.])],
141 [], [[#include <linux/termios.h>]])
143 # Check for the BOTHER definition, needed for setting arbitrary baud rates.
144 # We can't just #ifdef BOTHER in the code, because of the separation between
145 # code using libc headers and code using kernel termios.h headers.
146 AC_MSG_CHECKING(for BOTHER)
147 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
148 #include <linux/termios.h>
152 #error BOTHER is not defined
155 [AC_DEFINE(HAVE_BOTHER, 1, [BOTHER macro is available])
156 AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
158 # Check for serial_struct.
159 AC_CHECK_TYPE([struct serial_struct],
160 [AC_DEFINE(HAVE_SERIAL_STRUCT, 1,
161 [struct serial is available.])],
162 [], [[#include <linux/serial.h>]])
164 saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
165 AC_DEFINE(SP_API,,[Macro preceding public API functions])
166 AC_DEFINE(SP_PRIV,,[Macro preceding private functions])
167 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
168 __attribute__((visibility("hidden"))) void foo(void) { }
170 [AC_DEFINE(SP_API , __attribute__((visibility("default"))))]
171 [AC_DEFINE(SP_PRIV, __attribute__((visibility("hidden"))))],
172 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
173 __declspec(dllexport) void foo(void) { }
175 [AC_DEFINE(SP_API , __declspec(dllexport))]
176 [AC_DEFINE(SP_PRIV,)],
178 [AC_DEFINE(SP_PRIV,)]))
181 AC_SUBST(MAKEFLAGS, '--no-print-directory')
182 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
184 SP_PACKAGE_VERSION_MAJOR=sp_package_version_major
185 SP_PACKAGE_VERSION_MINOR=sp_package_version_minor
186 SP_PACKAGE_VERSION_MICRO=sp_package_version_micro
187 SP_PACKAGE_VERSION=sp_package_version
189 AC_SUBST(SP_PACKAGE_VERSION_MAJOR)
190 AC_SUBST(SP_PACKAGE_VERSION_MINOR)
191 AC_SUBST(SP_PACKAGE_VERSION_MICRO)
192 AC_SUBST(SP_PACKAGE_VERSION)
194 AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc])
199 echo "libserialport configuration summary:"
201 echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION"
202 echo " - Library version (current:revision:age): $SP_LIB_VERSION"
203 echo " - Prefix: $prefix"
204 echo " - Building on: $build"
205 echo " - Building for: $host"