]> sigrok.org Git - libserialport.git/blame_incremental - configure.ac
Constify the sp_get_port_transport() parameter.
[libserialport.git] / configure.ac
... / ...
CommitLineData
1##
2## This file is part of the libserialport project.
3##
4## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
5## Copyright (C) 2013 Martin Ling <martin-libserialport@earth.li>
6##
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.
11##
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.
16##
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/>.
19##
20
21# We require at least autoconf 2.63 (AC_INIT format changed there).
22AC_PREREQ([2.63])
23
24# libserialport package version number (NOT the same as shared lib version!).
25m4_define([sp_package_version_major], [0])
26m4_define([sp_package_version_minor], [1])
27m4_define([sp_package_version_micro], [1])
28m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro])
29
30AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li],
31 [libserialport], [http://sigrok.org/wiki/Libserialport])
32AC_CONFIG_HEADERS([config.h])
33AC_CONFIG_MACRO_DIR([autostuff])
34AC_CONFIG_AUX_DIR([autostuff])
35
36AH_TOP([#ifndef SP_CONFIG_H
37#define SP_CONFIG_H])
38AH_BOTTOM([#endif])
39
40# We require at least automake 1.11 (needed for 'silent rules').
41AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news])
42m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
43m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
44
45# Enable more compiler warnings.
46CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic -Wmissing-prototypes -Wshadow"
47
48# Checks for programs.
49AC_PROG_CC
50AC_PROG_CPP
51AC_PROG_INSTALL
52AC_PROG_LN_S
53
54# Initialize libtool.
55LT_INIT
56
57# Initialize pkg-config.
58# We require at least 0.22, as "Requires.private" behaviour changed there.
59PKG_PROG_PKG_CONFIG([0.22])
60
61# Library version for libserialport (NOT the same as the package version).
62# Carefully read the libtool docs before updating these numbers!
63# The algorithm for determining which number to change (and how) is nontrivial!
64# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
65SP_LIB_VERSION_CURRENT=0
66SP_LIB_VERSION_REVISION=0
67SP_LIB_VERSION_AGE=0
68SP_LIB_VERSION="$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"
69SP_LIB_LDFLAGS="-version-info $SP_LIB_VERSION"
70AC_SUBST(SP_LIB_VERSION_CURRENT)
71AC_SUBST(SP_LIB_VERSION_REVISION)
72AC_SUBST(SP_LIB_VERSION_AGE)
73AC_SUBST(SP_LIB_VERSION)
74AC_SUBST(SP_LIB_LDFLAGS)
75
76# Checks for libraries.
77
78SP_LIBS=""
79
80case $host_os in
81*linux*)
82 AM_CONDITIONAL([LINUX], true)
83 AM_CONDITIONAL([WIN32], false)
84 AM_CONDITIONAL([MACOSX], false)
85 AM_CONDITIONAL([FREEBSD], false)
86 ;;
87*darwin*)
88 AM_CONDITIONAL([LINUX], false)
89 AM_CONDITIONAL([WIN32], false)
90 AM_CONDITIONAL([MACOSX], true)
91 AM_CONDITIONAL([FREEBSD], false)
92 LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
93 AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
94 ;;
95mingw* | cygwin*)
96 AM_CONDITIONAL([LINUX], false)
97 AM_CONDITIONAL([WIN32], true)
98 AM_CONDITIONAL([MACOSX], false)
99 AM_CONDITIONAL([FREEBSD], false)
100 SP_LIBS="-lsetupapi"
101 ;;
102*freebsd*)
103 AM_CONDITIONAL([LINUX], false)
104 AM_CONDITIONAL([WIN32], false)
105 AM_CONDITIONAL([MACOSX], false)
106 AM_CONDITIONAL([FREEBSD], true)
107 ;;
108*)
109 AM_CONDITIONAL([LINUX], false)
110 AM_CONDITIONAL([WIN32], false)
111 AM_CONDITIONAL([MACOSX], false)
112 AM_CONDITIONAL([FREEBSD], false)
113 AC_DEFINE(NO_ENUMERATION,,[Enumeration is unsupported])
114 AC_DEFINE(NO_PORT_METADATA,,[Port metadata is unavailable])
115esac
116
117AC_SUBST(SP_LIBS)
118
119# Define size_t if not defined as standard.
120AC_TYPE_SIZE_T
121
122# Check for specific termios structures.
123AC_CHECK_TYPE([struct termios2],
124 [AC_DEFINE(HAVE_TERMIOS2, 1,
125 [struct termios2 is available.])],
126 [], [[#include <linux/termios.h>]])
127AC_CHECK_TYPE([struct termiox],
128 [AC_DEFINE(HAVE_TERMIOX, 1,
129 [struct termiox is available.])],
130 [], [[#include <linux/termios.h>]])
131AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
132 [AC_DEFINE(HAVE_TERMIOS_SPEED, 1,
133 [struct termios has c_ispeed/c_ospeed.])],
134 [], [[#include <linux/termios.h>]])
135AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
136 [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1,
137 [struct termios2 has c_ispeed/c_ospeed.])],
138 [], [[#include <linux/termios.h>]])
139
140# Check for the BOTHER definition, needed for setting arbitrary baud rates.
141# We can't just #ifdef BOTHER in the code, because of the separation between
142# code using libc headers and code using kernel termios.h headers.
143AC_MSG_CHECKING(for BOTHER)
144AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
145#include <linux/termios.h>
146]],
147[[
148#ifndef BOTHER
149#error BOTHER is not defined
150#endif
151]])],
152[AC_DEFINE(HAVE_BOTHER, 1, [BOTHER macro is available])
153AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
154
155# Check for serial_struct.
156AC_CHECK_TYPE([struct serial_struct],
157 [AC_DEFINE(HAVE_SERIAL_STRUCT, 1,
158 [struct serial is available.])],
159 [], [[#include <linux/serial.h>]])
160
161saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
162AC_DEFINE(SP_API,,[Macro preceding public API functions])
163AC_DEFINE(SP_PRIV,,[Macro preceding private functions])
164AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
165 __attribute__((visibility("hidden"))) void foo(void) { }
166 ]])],
167 [AC_DEFINE(SP_API, __attribute__((visibility("default"))))]
168 [AC_DEFINE(SP_PRIV, __attribute__((visibility("hidden"))))],
169AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
170 __declspec(dllexport) void foo(void) { }
171 ]])],
172 [AC_DEFINE(SP_API, __declspec(dllexport))]
173 [AC_DEFINE(SP_PRIV,)],
174 [AC_DEFINE(SP_API,)]
175 [AC_DEFINE(SP_PRIV,)]))
176CFLAGS="$saved"
177
178AC_SUBST(MAKEFLAGS, '--no-print-directory')
179AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
180
181SP_PACKAGE_VERSION_MAJOR=sp_package_version_major
182SP_PACKAGE_VERSION_MINOR=sp_package_version_minor
183SP_PACKAGE_VERSION_MICRO=sp_package_version_micro
184SP_PACKAGE_VERSION=sp_package_version
185
186AC_SUBST(SP_PACKAGE_VERSION_MAJOR)
187AC_SUBST(SP_PACKAGE_VERSION_MINOR)
188AC_SUBST(SP_PACKAGE_VERSION_MICRO)
189AC_SUBST(SP_PACKAGE_VERSION)
190
191AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc])
192
193AC_OUTPUT
194
195echo
196echo "libserialport configuration summary:"
197echo
198echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION"
199echo " - Library version (current:revision:age): $SP_LIB_VERSION"
200echo " - Prefix: $prefix"
201echo " - Building on: $build"
202echo " - Building for: $host"
203echo