]> sigrok.org Git - libserialport.git/blame - configure.ac
Build: Use GNUMAKEFLAGS and $@
[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])
f1c916ed 32AC_CONFIG_HEADERS([config.h libserialport.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])
f1c916ed
DE
38
39AH_BOTTOM([#if HAVE_STRUCT_TERMIOS_C_ISPEED && HAVE_STRUCT_TERMIOS_C_OSPEED
40# define HAVE_TERMIOS_SPEED 1
41#endif
42#if HAVE_STRUCT_TERMIOS2_C_ISPEED && HAVE_STRUCT_TERMIOS2_C_OSPEED
43# define HAVE_TERMIOS2_SPEED 1
44#endif
45
46#endif])
5ca38cdf 47
0662f2bb 48# We require at least automake 1.11 (needed for 'silent rules').
f1c916ed
DE
49AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define check-news])
50AM_SILENT_RULES([yes])
0662f2bb
ML
51m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
52
0662f2bb
ML
53# Checks for programs.
54AC_PROG_CC
0662f2bb
ML
55AC_PROG_INSTALL
56AC_PROG_LN_S
57
0662f2bb
ML
58# Initialize libtool.
59LT_INIT
60
f1c916ed
DE
61AC_DEFINE([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major], [.])
62AC_DEFINE([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor], [.])
63AC_DEFINE([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.])
64AC_DEFINE([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.])
65AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version])
0662f2bb
ML
66
67# Library version for libserialport (NOT the same as the package version).
68# Carefully read the libtool docs before updating these numbers!
69# The algorithm for determining which number to change (and how) is nontrivial!
70# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
71SP_LIB_VERSION_CURRENT=0
72SP_LIB_VERSION_REVISION=0
73SP_LIB_VERSION_AGE=0
f1c916ed
DE
74AC_SUBST([SP_LIB_VERSION],
75 ["$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"])
76
77AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [$SP_LIB_VERSION_CURRENT], [.])
78AC_DEFINE_UNQUOTED([SP_LIB_VERSION_REVISION], [$SP_LIB_VERSION_REVISION], [.])
79AC_DEFINE_UNQUOTED([SP_LIB_VERSION_AGE], [$SP_LIB_VERSION_AGE], [.])
80AC_DEFINE_UNQUOTED([SP_LIB_VERSION_STRING], ["$SP_LIB_VERSION"], [.])
81
82AM_CONDITIONAL([LINUX], [test -z "${host_os##linux*}"])
83AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"])
84AM_CONDITIONAL([MACOSX], [test -z "${host_os##darwin*}"])
85AM_CONDITIONAL([FREEBSD], [test -z "${host_os##freebsd*}"])
86
87AM_COND_IF([WIN32], [SP_LIBS='-lsetupapi'], [SP_LIBS=])
88AC_SUBST([SP_LIBS])
89
90AM_COND_IF([MACOSX], [AC_CHECK_HEADER([IOKit/IOKitLib.h], [],
91 [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])])
92
93AS_CASE([$host_os], [linux*|darwin*|mingw*|cygwin*|freebsd*],, [
94 AC_DEFINE([NO_ENUMERATION], [1], [Enumeration is unsupported.])
95 AC_DEFINE([NO_PORT_METADATA], [1], [Port metadata is unavailable.])
96])
e4bffe06 97
07f61c71
DE
98AC_SYS_LARGEFILE
99
7c3a1ee3 100# Define size_t if not defined as standard.
0662f2bb 101AC_TYPE_SIZE_T
2dcf8308
ML
102
103# Check for specific termios structures.
f1c916ed
DE
104AC_CHECK_TYPES([struct termios2, struct termiox],,,
105 [[#include <linux/termios.h>]])
106AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed,
107 struct termios2.c_ispeed, struct termios2.c_ospeed],,,
108 [[#include <linux/termios.h>]])
0662f2bb 109
59182fbb
ML
110# Check for the BOTHER definition, needed for setting arbitrary baud rates.
111# We can't just #ifdef BOTHER in the code, because of the separation between
112# code using libc headers and code using kernel termios.h headers.
f1c916ed 113AC_CHECK_DECLS([BOTHER],,, [[#include <linux/termios.h>]])
59182fbb 114
12056e2f 115# Check for serial_struct.
f1c916ed
DE
116AC_CHECK_TYPES([struct serial_struct],,, [[#include <linux/serial.h>]])
117
118AC_CACHE_CHECK([for visibility control], [sp_cv_visibility_control], [
119 sp_saved_CFLAGS=$CFLAGS
120 CFLAGS="$CFLAGS -Werror"
121 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
122 [[__attribute__((visibility("hidden"))) void foo(void) {}]])],
123 [sp_cv_visibility_control=attribute],
124 [AC_COMPILE_IFELSE([AC_LANG_SOURCE(
125 [[__declspec(dllexport) void foo(void) {}]])],
126 [sp_cv_visibility_control=declspec],
127 [sp_cv_visibility_control=none])])
128 CFLAGS=$sp_saved_CFLAGS
129])
130AS_CASE([$sp_cv_visibility_control],
131 [attribute], [SP_API='__attribute__((visibility("default")))'
132 SP_PRIV='__attribute__((visibility("hidden")))'],
133 [declspec], [SP_API='__declspec(dllexport)' SP_PRIV=],
134 [SP_API= SP_PRIV=])
135AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions])
136AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions])
137
138AC_CONFIG_FILES([Makefile libserialport.pc])
0662f2bb
ML
139
140AC_OUTPUT
141
f1c916ed
DE
142cat >&AS_MESSAGE_FD <<_EOF
143
144libserialport configuration summary:
145
146 - Package version (major.minor.micro): $SP_PACKAGE_VERSION
147 - Library version (current:revision:age): $SP_LIB_VERSION
148 - Prefix: $prefix
149 - Building on: $build
150 - Building for: $host
151
152_EOF