]> sigrok.org Git - libserialport.git/blame - configure.ac
doc: Additional notes on sp_last_error_{code,message}.
[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
0662f2bb
ML
45# Checks for programs.
46AC_PROG_CC
47AC_PROG_CPP
48AC_PROG_INSTALL
49AC_PROG_LN_S
50
0662f2bb
ML
51# Initialize libtool.
52LT_INIT
53
54# Initialize pkg-config.
f92f1f0c 55# We require at least 0.22, as "Requires.private" behaviour changed there.
0662f2bb
ML
56PKG_PROG_PKG_CONFIG([0.22])
57
58# Library version for libserialport (NOT the same as the package version).
59# Carefully read the libtool docs before updating these numbers!
60# The algorithm for determining which number to change (and how) is nontrivial!
61# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
62SP_LIB_VERSION_CURRENT=0
63SP_LIB_VERSION_REVISION=0
64SP_LIB_VERSION_AGE=0
65SP_LIB_VERSION="$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"
66SP_LIB_LDFLAGS="-version-info $SP_LIB_VERSION"
67AC_SUBST(SP_LIB_VERSION_CURRENT)
68AC_SUBST(SP_LIB_VERSION_REVISION)
69AC_SUBST(SP_LIB_VERSION_AGE)
70AC_SUBST(SP_LIB_VERSION)
71AC_SUBST(SP_LIB_LDFLAGS)
72
e4bffe06
UH
73# Checks for libraries.
74
a93fb468 75SP_LIBS=""
0662f2bb 76
3cb7aa98 77case $host_os in
1ebf4347 78*linux*)
27e231ff 79 AM_CONDITIONAL([LINUX], true)
e33dcf90
ML
80 AM_CONDITIONAL([WIN32], false)
81 AM_CONDITIONAL([MACOSX], false)
ccd512d5 82 AM_CONDITIONAL([FREEBSD], false)
1ebf4347
ML
83 ;;
84*darwin*)
27e231ff 85 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
86 AM_CONDITIONAL([WIN32], false)
87 AM_CONDITIONAL([MACOSX], true)
ccd512d5 88 AM_CONDITIONAL([FREEBSD], false)
1ebf4347
ML
89 AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
90 ;;
a93fb468
AJ
91mingw* | cygwin*)
92 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
93 AM_CONDITIONAL([WIN32], true)
94 AM_CONDITIONAL([MACOSX], false)
ccd512d5 95 AM_CONDITIONAL([FREEBSD], false)
777347a6 96 SP_LIBS="-lsetupapi"
a93fb468 97 ;;
ccd512d5
UJ
98*freebsd*)
99 AM_CONDITIONAL([LINUX], false)
100 AM_CONDITIONAL([WIN32], false)
101 AM_CONDITIONAL([MACOSX], false)
102 AM_CONDITIONAL([FREEBSD], true)
103 ;;
27e231ff
ML
104*)
105 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
106 AM_CONDITIONAL([WIN32], false)
107 AM_CONDITIONAL([MACOSX], false)
ccd512d5 108 AM_CONDITIONAL([FREEBSD], false)
7c081505
ML
109 AC_DEFINE(NO_ENUMERATION,,[Enumeration is unsupported])
110 AC_DEFINE(NO_PORT_METADATA,,[Port metadata is unavailable])
1ebf4347
ML
111esac
112
a93fb468 113AC_SUBST(SP_LIBS)
e4bffe06 114
7c3a1ee3 115# Define size_t if not defined as standard.
0662f2bb 116AC_TYPE_SIZE_T
2dcf8308
ML
117
118# Check for specific termios structures.
7c081505
ML
119AC_CHECK_TYPE([struct termios2],
120 [AC_DEFINE(HAVE_TERMIOS2, 1,
121 [struct termios2 is available.])],
122 [], [[#include <linux/termios.h>]])
123AC_CHECK_TYPE([struct termiox],
124 [AC_DEFINE(HAVE_TERMIOX, 1,
125 [struct termiox is available.])],
126 [], [[#include <linux/termios.h>]])
5cea279a 127AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
7c081505
ML
128 [AC_DEFINE(HAVE_TERMIOS_SPEED, 1,
129 [struct termios has c_ispeed/c_ospeed.])],
130 [], [[#include <linux/termios.h>]])
5cea279a 131AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
7c081505
ML
132 [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1,
133 [struct termios2 has c_ispeed/c_ospeed.])],
134 [], [[#include <linux/termios.h>]])
0662f2bb 135
59182fbb
ML
136# Check for the BOTHER definition, needed for setting arbitrary baud rates.
137# We can't just #ifdef BOTHER in the code, because of the separation between
138# code using libc headers and code using kernel termios.h headers.
139AC_MSG_CHECKING(for BOTHER)
140AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
141#include <linux/termios.h>
142]],
143[[
144#ifndef BOTHER
145#error BOTHER is not defined
146#endif
147]])],
7c081505 148[AC_DEFINE(HAVE_BOTHER, 1, [BOTHER macro is available])
59182fbb
ML
149AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
150
12056e2f 151# Check for serial_struct.
7c081505
ML
152AC_CHECK_TYPE([struct serial_struct],
153 [AC_DEFINE(HAVE_SERIAL_STRUCT, 1,
154 [struct serial is available.])],
12056e2f
MC
155 [], [[#include <linux/serial.h>]])
156
970f279a 157saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
7c081505
ML
158AC_DEFINE(SP_API,,[Macro preceding public API functions])
159AC_DEFINE(SP_PRIV,,[Macro preceding private functions])
970f279a
AJ
160AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
161 __attribute__((visibility("hidden"))) void foo(void) { }
162 ]])],
8c6de591 163 [AC_DEFINE(SP_API, __attribute__((visibility("default"))))]
970f279a
AJ
164 [AC_DEFINE(SP_PRIV, __attribute__((visibility("hidden"))))],
165AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
166 __declspec(dllexport) void foo(void) { }
167 ]])],
8c6de591 168 [AC_DEFINE(SP_API, __declspec(dllexport))]
970f279a
AJ
169 [AC_DEFINE(SP_PRIV,)],
170 [AC_DEFINE(SP_API,)]
171 [AC_DEFINE(SP_PRIV,)]))
172CFLAGS="$saved"
173
0662f2bb
ML
174AC_SUBST(MAKEFLAGS, '--no-print-directory')
175AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
176
177SP_PACKAGE_VERSION_MAJOR=sp_package_version_major
178SP_PACKAGE_VERSION_MINOR=sp_package_version_minor
7de20e39 179SP_PACKAGE_VERSION_MICRO=sp_package_version_micro
0662f2bb
ML
180SP_PACKAGE_VERSION=sp_package_version
181
182AC_SUBST(SP_PACKAGE_VERSION_MAJOR)
183AC_SUBST(SP_PACKAGE_VERSION_MINOR)
7de20e39 184AC_SUBST(SP_PACKAGE_VERSION_MICRO)
0662f2bb
ML
185AC_SUBST(SP_PACKAGE_VERSION)
186
baba0759 187AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc])
0662f2bb
ML
188
189AC_OUTPUT
190
191echo
192echo "libserialport configuration summary:"
193echo
7de20e39 194echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION"
0662f2bb
ML
195echo " - Library version (current:revision:age): $SP_LIB_VERSION"
196echo " - Prefix: $prefix"
197echo " - Building on: $build"
198echo " - Building for: $host"
199echo