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