]>
Commit | Line | Data |
---|---|---|
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). | |
22 | AC_PREREQ([2.63]) | |
23 | ||
24 | # libserialport package version number (NOT the same as shared lib version!). | |
25 | m4_define([sp_package_version_major], [0]) | |
3f2f48fc UH |
26 | m4_define([sp_package_version_minor], [1]) |
27 | m4_define([sp_package_version_micro], [1]) | |
7de20e39 | 28 | m4_define([sp_package_version], [sp_package_version_major.sp_package_version_minor.sp_package_version_micro]) |
0662f2bb ML |
29 | |
30 | AC_INIT([libserialport], [sp_package_version], [martin-libserialport@earth.li], | |
728f6de5 | 31 | [libserialport], [http://sigrok.org/wiki/Libserialport]) |
f1c916ed | 32 | AC_CONFIG_HEADERS([config.h libserialport.h]) |
0662f2bb ML |
33 | AC_CONFIG_MACRO_DIR([autostuff]) |
34 | AC_CONFIG_AUX_DIR([autostuff]) | |
35 | ||
f1c916ed DE |
36 | AH_BOTTOM([#if HAVE_STRUCT_TERMIOS_C_ISPEED && HAVE_STRUCT_TERMIOS_C_OSPEED |
37 | # define HAVE_TERMIOS_SPEED 1 | |
38 | #endif | |
39 | #if HAVE_STRUCT_TERMIOS2_C_ISPEED && HAVE_STRUCT_TERMIOS2_C_OSPEED | |
40 | # define HAVE_TERMIOS2_SPEED 1 | |
f1c916ed | 41 | #endif]) |
5ca38cdf | 42 | |
0662f2bb | 43 | # We require at least automake 1.11 (needed for 'silent rules'). |
f1c916ed DE |
44 | AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define check-news]) |
45 | AM_SILENT_RULES([yes]) | |
0662f2bb ML |
46 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) |
47 | ||
0662f2bb ML |
48 | # Checks for programs. |
49 | AC_PROG_CC | |
0662f2bb ML |
50 | AC_PROG_INSTALL |
51 | AC_PROG_LN_S | |
52 | ||
d8de88de UH |
53 | ## SP_PROG_VERSION(program, sh-var) |
54 | ## Obtain the version of <program> and store it in <sh-var>. | |
55 | AC_DEFUN([SP_PROG_VERSION], | |
56 | [dnl | |
57 | m4_assert([$# >= 2])[]dnl | |
58 | sp_prog_ver=`$1 --version 2>&AS_MESSAGE_LOG_FD | sed 1q 2>&AS_MESSAGE_LOG_FD` | |
59 | AS_CASE([[$]?:$sp_prog_ver], | |
60 | [[0:*[0-9].[0-9]*]], [$2=$sp_prog_ver], | |
61 | [$2=unknown])[]dnl | |
62 | ]) | |
63 | ||
64 | SP_PROG_VERSION([$CC], [sp_cc_version]) | |
65 | ||
0662f2bb ML |
66 | # Initialize libtool. |
67 | LT_INIT | |
68 | ||
f1c916ed DE |
69 | AC_DEFINE([SP_PACKAGE_VERSION_MAJOR], [sp_package_version_major], [.]) |
70 | AC_DEFINE([SP_PACKAGE_VERSION_MINOR], [sp_package_version_minor], [.]) | |
71 | AC_DEFINE([SP_PACKAGE_VERSION_MICRO], [sp_package_version_micro], [.]) | |
72 | AC_DEFINE([SP_PACKAGE_VERSION_STRING], ["sp_package_version"], [.]) | |
73 | AC_SUBST([SP_PACKAGE_VERSION], [sp_package_version]) | |
0662f2bb ML |
74 | |
75 | # Library version for libserialport (NOT the same as the package version). | |
76 | # Carefully read the libtool docs before updating these numbers! | |
77 | # The algorithm for determining which number to change (and how) is nontrivial! | |
78 | # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info | |
3fcdc9f7 | 79 | SP_LIB_VERSION_CURRENT=1 |
0662f2bb | 80 | SP_LIB_VERSION_REVISION=0 |
3fcdc9f7 | 81 | SP_LIB_VERSION_AGE=1 |
f1c916ed DE |
82 | AC_SUBST([SP_LIB_VERSION], |
83 | ["$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"]) | |
84 | ||
85 | AC_DEFINE_UNQUOTED([SP_LIB_VERSION_CURRENT], [$SP_LIB_VERSION_CURRENT], [.]) | |
86 | AC_DEFINE_UNQUOTED([SP_LIB_VERSION_REVISION], [$SP_LIB_VERSION_REVISION], [.]) | |
87 | AC_DEFINE_UNQUOTED([SP_LIB_VERSION_AGE], [$SP_LIB_VERSION_AGE], [.]) | |
88 | AC_DEFINE_UNQUOTED([SP_LIB_VERSION_STRING], ["$SP_LIB_VERSION"], [.]) | |
89 | ||
b2359c5c | 90 | AM_CONDITIONAL([LINUX], [test -z "${host_os##linux*}" || test -z "${host_os##uclinux*}"]) |
f1c916ed DE |
91 | AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"]) |
92 | AM_CONDITIONAL([MACOSX], [test -z "${host_os##darwin*}"]) | |
93 | AM_CONDITIONAL([FREEBSD], [test -z "${host_os##freebsd*}"]) | |
94 | ||
95 | AM_COND_IF([WIN32], [SP_LIBS='-lsetupapi'], [SP_LIBS=]) | |
96 | AC_SUBST([SP_LIBS]) | |
97 | ||
2a6c24be UH |
98 | AM_COND_IF([FREEBSD], [SP_PKGLIBS='libusb-2.0'], [SP_PKGLIBS=]) |
99 | AC_SUBST([SP_PKGLIBS]) | |
100 | ||
f1c916ed DE |
101 | AM_COND_IF([MACOSX], [AC_CHECK_HEADER([IOKit/IOKitLib.h], [], |
102 | [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])]) | |
103 | ||
104 | AS_CASE([$host_os], [linux*|darwin*|mingw*|cygwin*|freebsd*],, [ | |
105 | AC_DEFINE([NO_ENUMERATION], [1], [Enumeration is unsupported.]) | |
106 | AC_DEFINE([NO_PORT_METADATA], [1], [Port metadata is unavailable.]) | |
107 | ]) | |
e4bffe06 | 108 | |
07f61c71 DE |
109 | AC_SYS_LARGEFILE |
110 | ||
7c3a1ee3 | 111 | # Define size_t if not defined as standard. |
0662f2bb | 112 | AC_TYPE_SIZE_T |
2dcf8308 ML |
113 | |
114 | # Check for specific termios structures. | |
f1c916ed DE |
115 | AC_CHECK_TYPES([struct termios2, struct termiox],,, |
116 | [[#include <linux/termios.h>]]) | |
117 | AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed, | |
118 | struct termios2.c_ispeed, struct termios2.c_ospeed],,, | |
119 | [[#include <linux/termios.h>]]) | |
0662f2bb | 120 | |
59182fbb ML |
121 | # Check for the BOTHER definition, needed for setting arbitrary baud rates. |
122 | # We can't just #ifdef BOTHER in the code, because of the separation between | |
123 | # code using libc headers and code using kernel termios.h headers. | |
f1c916ed | 124 | AC_CHECK_DECLS([BOTHER],,, [[#include <linux/termios.h>]]) |
59182fbb | 125 | |
12056e2f | 126 | # Check for serial_struct. |
f1c916ed DE |
127 | AC_CHECK_TYPES([struct serial_struct],,, [[#include <linux/serial.h>]]) |
128 | ||
95bad38c ST |
129 | # Check for realpath(). |
130 | AC_CHECK_FUNC([realpath], [AC_DEFINE(HAVE_REALPATH, 1, [realpath is available.])], []) | |
131 | ||
46bdc20c ML |
132 | # Check for clock_gettime(). |
133 | AC_CHECK_FUNC([clock_gettime], | |
134 | [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [clock_gettime is available.])], []) | |
135 | ||
f1c916ed DE |
136 | AC_CACHE_CHECK([for visibility control], [sp_cv_visibility_control], [ |
137 | sp_saved_CFLAGS=$CFLAGS | |
138 | CFLAGS="$CFLAGS -Werror" | |
139 | AC_COMPILE_IFELSE([AC_LANG_SOURCE( | |
140 | [[__attribute__((visibility("hidden"))) void foo(void) {}]])], | |
141 | [sp_cv_visibility_control=attribute], | |
142 | [AC_COMPILE_IFELSE([AC_LANG_SOURCE( | |
143 | [[__declspec(dllexport) void foo(void) {}]])], | |
144 | [sp_cv_visibility_control=declspec], | |
145 | [sp_cv_visibility_control=none])]) | |
146 | CFLAGS=$sp_saved_CFLAGS | |
147 | ]) | |
148 | AS_CASE([$sp_cv_visibility_control], | |
149 | [attribute], [SP_API='__attribute__((visibility("default")))' | |
150 | SP_PRIV='__attribute__((visibility("hidden")))'], | |
151 | [declspec], [SP_API='__declspec(dllexport)' SP_PRIV=], | |
152 | [SP_API= SP_PRIV=]) | |
153 | AC_DEFINE_UNQUOTED([SP_API], [$SP_API], [Macro preceding public API functions]) | |
154 | AC_DEFINE_UNQUOTED([SP_PRIV], [$SP_PRIV], [Macro preceding private functions]) | |
155 | ||
156 | AC_CONFIG_FILES([Makefile libserialport.pc]) | |
0662f2bb ML |
157 | |
158 | AC_OUTPUT | |
159 | ||
f1c916ed DE |
160 | cat >&AS_MESSAGE_FD <<_EOF |
161 | ||
162 | libserialport configuration summary: | |
163 | ||
5ec2f93b UH |
164 | - Package version................. $SP_PACKAGE_VERSION |
165 | - Library ABI version............. $SP_LIB_VERSION | |
166 | - Prefix.......................... $prefix | |
167 | - Building on..................... $build | |
168 | - Building for.................... $host | |
0b539331 | 169 | - Building shared / static........ $enable_shared / $enable_static |
f1c916ed | 170 | |
d8de88de UH |
171 | Compile configuration: |
172 | - C compiler...................... $CC | |
173 | - C compiler version.............. $sp_cc_version | |
174 | - C compiler flags................ $CFLAGS | |
175 | - Linker flags.................... $LDFLAGS | |
176 | ||
f1c916ed | 177 | _EOF |