]> sigrok.org Git - libserialport.git/blame - configure.ac
Various Doxygen comment updates and fixes.
[libserialport.git] / configure.ac
CommitLineData
0662f2bb
ML
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])
3f2f48fc
UH
26m4_define([sp_package_version_minor], [1])
27m4_define([sp_package_version_micro], [1])
7de20e39 28m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro])
0662f2bb
ML
29
30AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li],
728f6de5 31 [libserialport], [http://sigrok.org/wiki/Libserialport])
7c081505 32AC_CONFIG_HEADERS([config.h])
0662f2bb
ML
33AC_CONFIG_MACRO_DIR([autostuff])
34AC_CONFIG_AUX_DIR([autostuff])
35
5ca38cdf
UH
36AH_TOP([#ifndef SP_CONFIG_H
37#define SP_CONFIG_H])
38AH_BOTTOM([#endif])
39
0662f2bb 40# We require at least automake 1.11 (needed for 'silent rules').
9fb99134 41AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news])
0662f2bb
ML
42m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
43m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
44
7f450f46 45# Enable more compiler warnings.
613c48f1 46CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic -Wmissing-prototypes -Wshadow"
0662f2bb
ML
47
48# Checks for programs.
49AC_PROG_CC
50AC_PROG_CPP
51AC_PROG_INSTALL
52AC_PROG_LN_S
53
0662f2bb
ML
54# Initialize libtool.
55LT_INIT
56
57# Initialize pkg-config.
f92f1f0c 58# We require at least 0.22, as "Requires.private" behaviour changed there.
0662f2bb
ML
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
e4bffe06
UH
76# Checks for libraries.
77
78# This variable collects the pkg-config names of all detected libs.
79# It is then used to construct the "Requires.private:" field in the
80# libserialport.pc file.
81SP_PKGLIBS=""
a93fb468 82SP_LIBS=""
0662f2bb 83
3cb7aa98 84case $host_os in
1ebf4347 85*linux*)
27e231ff 86 AM_CONDITIONAL([LINUX], true)
e33dcf90
ML
87 AM_CONDITIONAL([WIN32], false)
88 AM_CONDITIONAL([MACOSX], false)
ccd512d5 89 AM_CONDITIONAL([FREEBSD], false)
1ebf4347
ML
90 ;;
91*darwin*)
27e231ff 92 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
93 AM_CONDITIONAL([WIN32], false)
94 AM_CONDITIONAL([MACOSX], true)
ccd512d5 95 AM_CONDITIONAL([FREEBSD], false)
1ebf4347
ML
96 LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
97 AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
98 ;;
a93fb468
AJ
99mingw* | cygwin*)
100 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
101 AM_CONDITIONAL([WIN32], true)
102 AM_CONDITIONAL([MACOSX], false)
ccd512d5 103 AM_CONDITIONAL([FREEBSD], false)
777347a6 104 SP_LIBS="-lsetupapi"
a93fb468 105 ;;
ccd512d5
UJ
106*freebsd*)
107 AM_CONDITIONAL([LINUX], false)
108 AM_CONDITIONAL([WIN32], false)
109 AM_CONDITIONAL([MACOSX], false)
110 AM_CONDITIONAL([FREEBSD], true)
111 ;;
27e231ff
ML
112*)
113 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
114 AM_CONDITIONAL([WIN32], false)
115 AM_CONDITIONAL([MACOSX], false)
ccd512d5 116 AM_CONDITIONAL([FREEBSD], false)
7c081505
ML
117 AC_DEFINE(NO_ENUMERATION,,[Enumeration is unsupported])
118 AC_DEFINE(NO_PORT_METADATA,,[Port metadata is unavailable])
1ebf4347
ML
119esac
120
e4bffe06 121AC_SUBST(SP_PKGLIBS)
a93fb468 122AC_SUBST(SP_LIBS)
e4bffe06 123
7c3a1ee3 124# Define size_t if not defined as standard.
0662f2bb 125AC_TYPE_SIZE_T
2dcf8308
ML
126
127# Check for specific termios structures.
7c081505
ML
128AC_CHECK_TYPE([struct termios2],
129 [AC_DEFINE(HAVE_TERMIOS2, 1,
130 [struct termios2 is available.])],
131 [], [[#include <linux/termios.h>]])
132AC_CHECK_TYPE([struct termiox],
133 [AC_DEFINE(HAVE_TERMIOX, 1,
134 [struct termiox is available.])],
135 [], [[#include <linux/termios.h>]])
5cea279a 136AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
7c081505
ML
137 [AC_DEFINE(HAVE_TERMIOS_SPEED, 1,
138 [struct termios has c_ispeed/c_ospeed.])],
139 [], [[#include <linux/termios.h>]])
5cea279a 140AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
7c081505
ML
141 [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1,
142 [struct termios2 has c_ispeed/c_ospeed.])],
143 [], [[#include <linux/termios.h>]])
0662f2bb 144
59182fbb
ML
145# Check for the BOTHER definition, needed for setting arbitrary baud rates.
146# We can't just #ifdef BOTHER in the code, because of the separation between
147# code using libc headers and code using kernel termios.h headers.
148AC_MSG_CHECKING(for BOTHER)
149AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
150#include <linux/termios.h>
151]],
152[[
153#ifndef BOTHER
154#error BOTHER is not defined
155#endif
156]])],
7c081505 157[AC_DEFINE(HAVE_BOTHER, 1, [BOTHER macro is available])
59182fbb
ML
158AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
159
12056e2f 160# Check for serial_struct.
7c081505
ML
161AC_CHECK_TYPE([struct serial_struct],
162 [AC_DEFINE(HAVE_SERIAL_STRUCT, 1,
163 [struct serial is available.])],
12056e2f
MC
164 [], [[#include <linux/serial.h>]])
165
970f279a 166saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
7c081505
ML
167AC_DEFINE(SP_API,,[Macro preceding public API functions])
168AC_DEFINE(SP_PRIV,,[Macro preceding private functions])
970f279a
AJ
169AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
170 __attribute__((visibility("hidden"))) void foo(void) { }
171 ]])],
8c6de591 172 [AC_DEFINE(SP_API, __attribute__((visibility("default"))))]
970f279a
AJ
173 [AC_DEFINE(SP_PRIV, __attribute__((visibility("hidden"))))],
174AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
175 __declspec(dllexport) void foo(void) { }
176 ]])],
8c6de591 177 [AC_DEFINE(SP_API, __declspec(dllexport))]
970f279a
AJ
178 [AC_DEFINE(SP_PRIV,)],
179 [AC_DEFINE(SP_API,)]
180 [AC_DEFINE(SP_PRIV,)]))
181CFLAGS="$saved"
182
0662f2bb
ML
183AC_SUBST(MAKEFLAGS, '--no-print-directory')
184AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
185
186SP_PACKAGE_VERSION_MAJOR=sp_package_version_major
187SP_PACKAGE_VERSION_MINOR=sp_package_version_minor
7de20e39 188SP_PACKAGE_VERSION_MICRO=sp_package_version_micro
0662f2bb
ML
189SP_PACKAGE_VERSION=sp_package_version
190
191AC_SUBST(SP_PACKAGE_VERSION_MAJOR)
192AC_SUBST(SP_PACKAGE_VERSION_MINOR)
7de20e39 193AC_SUBST(SP_PACKAGE_VERSION_MICRO)
0662f2bb
ML
194AC_SUBST(SP_PACKAGE_VERSION)
195
baba0759 196AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc])
0662f2bb
ML
197
198AC_OUTPUT
199
200echo
201echo "libserialport configuration summary:"
202echo
7de20e39 203echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION"
0662f2bb
ML
204echo " - Library version (current:revision:age): $SP_LIB_VERSION"
205echo " - Prefix: $prefix"
206echo " - Building on: $build"
207echo " - Building for: $host"
208echo