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