]>
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]) | |
26 | m4_define([sp_package_version_minor], [1]) | |
7de20e39 UH |
27 | m4_define([sp_package_version_micro], [0]) |
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]) |
0662f2bb ML |
32 | AC_CONFIG_MACRO_DIR([autostuff]) |
33 | AC_CONFIG_AUX_DIR([autostuff]) | |
34 | ||
1ebf4347 ML |
35 | AC_CANONICAL_TARGET |
36 | ||
0662f2bb | 37 | # We require at least automake 1.11 (needed for 'silent rules'). |
9fb99134 | 38 | AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news]) |
0662f2bb ML |
39 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
40 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) | |
41 | ||
0662f2bb ML |
42 | # Enable more compiler warnings via -Wall and -Wextra. |
43 | CFLAGS="$CFLAGS -Wall -Wextra" | |
44 | ||
45 | # Checks for programs. | |
46 | AC_PROG_CC | |
47 | AC_PROG_CPP | |
48 | AC_PROG_INSTALL | |
49 | AC_PROG_LN_S | |
50 | ||
0662f2bb ML |
51 | # Initialize libtool. |
52 | LT_INIT | |
53 | ||
54 | # Initialize pkg-config. | |
f92f1f0c | 55 | # We require at least 0.22, as "Requires.private" behaviour changed there. |
0662f2bb ML |
56 | PKG_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 | |
62 | SP_LIB_VERSION_CURRENT=0 | |
63 | SP_LIB_VERSION_REVISION=0 | |
64 | SP_LIB_VERSION_AGE=0 | |
65 | SP_LIB_VERSION="$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE" | |
66 | SP_LIB_LDFLAGS="-version-info $SP_LIB_VERSION" | |
67 | AC_SUBST(SP_LIB_VERSION_CURRENT) | |
68 | AC_SUBST(SP_LIB_VERSION_REVISION) | |
69 | AC_SUBST(SP_LIB_VERSION_AGE) | |
70 | AC_SUBST(SP_LIB_VERSION) | |
71 | AC_SUBST(SP_LIB_LDFLAGS) | |
72 | ||
e4bffe06 UH |
73 | # Checks for libraries. |
74 | ||
75 | # This variable collects the pkg-config names of all detected libs. | |
76 | # It is then used to construct the "Requires.private:" field in the | |
77 | # libserialport.pc file. | |
78 | SP_PKGLIBS="" | |
0662f2bb | 79 | |
1ebf4347 ML |
80 | case $target_os in |
81 | *linux*) | |
27e231ff | 82 | AM_CONDITIONAL([LINUX], true) |
397d89de ML |
83 | # On Linux libudev is currently required for enumeration. |
84 | AC_ARG_WITH([libudev], | |
85 | [AS_HELP_STRING([--with-libudev], | |
86 | [use libudev for serial port enumeration @<:@default=check@:>@])], | |
87 | [], [with_libudev=check]) | |
88 | AS_IF([test "x$with_libudev" != xno], [ | |
1ebf4347 | 89 | PKG_CHECK_MODULES([libudev], [libudev >= 0], |
e4bffe06 | 90 | [CFLAGS="$CFLAGS $libudev_CFLAGS"; LIBS="$LIBS $libudev_LIBS"; |
397d89de | 91 | SP_PKGLIBS="$SP_PKGLIBS libudev"; AC_DEFINE(HAVE_LIBUDEV)])], []) |
1ebf4347 ML |
92 | ;; |
93 | *darwin*) | |
27e231ff | 94 | AM_CONDITIONAL([LINUX], false) |
1ebf4347 ML |
95 | LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation" |
96 | AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])]) | |
97 | ;; | |
27e231ff ML |
98 | *) |
99 | AM_CONDITIONAL([LINUX], false) | |
1ebf4347 ML |
100 | esac |
101 | ||
e4bffe06 UH |
102 | AC_SUBST(SP_PKGLIBS) |
103 | ||
7c3a1ee3 | 104 | # Define size_t if not defined as standard. |
0662f2bb | 105 | AC_TYPE_SIZE_T |
2dcf8308 ML |
106 | |
107 | # Check for specific termios structures. | |
7c3a1ee3 UH |
108 | AC_CHECK_TYPE([struct termios2], [AC_DEFINE(HAVE_TERMIOS2, 1)], [], [[#include <linux/termios.h>]]) |
109 | AC_CHECK_TYPE([struct termiox], [AC_DEFINE(HAVE_TERMIOX, 1)], [], [[#include <linux/termios.h>]]) | |
5cea279a ML |
110 | AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed], |
111 | [AC_DEFINE(HAVE_TERMIOS_SPEED, 1)], [], [[#include <linux/termios.h>]]) | |
112 | AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed], | |
113 | [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]]) | |
0662f2bb | 114 | |
0662f2bb ML |
115 | AC_SUBST(MAKEFLAGS, '--no-print-directory') |
116 | AC_SUBST(AM_LIBTOOLFLAGS, '--silent') | |
117 | ||
118 | SP_PACKAGE_VERSION_MAJOR=sp_package_version_major | |
119 | SP_PACKAGE_VERSION_MINOR=sp_package_version_minor | |
7de20e39 | 120 | SP_PACKAGE_VERSION_MICRO=sp_package_version_micro |
0662f2bb ML |
121 | SP_PACKAGE_VERSION=sp_package_version |
122 | ||
123 | AC_SUBST(SP_PACKAGE_VERSION_MAJOR) | |
124 | AC_SUBST(SP_PACKAGE_VERSION_MINOR) | |
7de20e39 | 125 | AC_SUBST(SP_PACKAGE_VERSION_MICRO) |
0662f2bb ML |
126 | AC_SUBST(SP_PACKAGE_VERSION) |
127 | ||
baba0759 | 128 | AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc]) |
0662f2bb ML |
129 | |
130 | AC_OUTPUT | |
131 | ||
132 | echo | |
133 | echo "libserialport configuration summary:" | |
134 | echo | |
7de20e39 | 135 | echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION" |
0662f2bb ML |
136 | echo " - Library version (current:revision:age): $SP_LIB_VERSION" |
137 | echo " - Prefix: $prefix" | |
138 | echo " - Building on: $build" | |
139 | echo " - Building for: $host" | |
140 | echo |