]> sigrok.org Git - libserialport.git/blame - configure.ac
windows: -no-undefined is required to make a DLL.
[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])
0662f2bb
ML
32AC_CONFIG_MACRO_DIR([autostuff])
33AC_CONFIG_AUX_DIR([autostuff])
34
1ebf4347
ML
35AC_CANONICAL_TARGET
36
0662f2bb 37# We require at least automake 1.11 (needed for 'silent rules').
9fb99134 38AM_INIT_AUTOMAKE([1.11 -Wall -Werror check-news])
0662f2bb
ML
39m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
40m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
41
7f450f46
ML
42# Enable more compiler warnings.
43CFLAGS="$CFLAGS -std=c99 -Wall -Wextra -pedantic"
0662f2bb
ML
44
45# Checks for programs.
46AC_PROG_CC
47AC_PROG_CPP
48AC_PROG_INSTALL
49AC_PROG_LN_S
50
0662f2bb
ML
51# Initialize libtool.
52LT_INIT
53
54# Initialize pkg-config.
f92f1f0c 55# We require at least 0.22, as "Requires.private" behaviour changed there.
0662f2bb
ML
56PKG_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
62SP_LIB_VERSION_CURRENT=0
63SP_LIB_VERSION_REVISION=0
64SP_LIB_VERSION_AGE=0
65SP_LIB_VERSION="$SP_LIB_VERSION_CURRENT:$SP_LIB_VERSION_REVISION:$SP_LIB_VERSION_AGE"
66SP_LIB_LDFLAGS="-version-info $SP_LIB_VERSION"
67AC_SUBST(SP_LIB_VERSION_CURRENT)
68AC_SUBST(SP_LIB_VERSION_REVISION)
69AC_SUBST(SP_LIB_VERSION_AGE)
70AC_SUBST(SP_LIB_VERSION)
71AC_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.
78SP_PKGLIBS=""
a93fb468 79SP_LIBS=""
0662f2bb 80
1ebf4347
ML
81case $target_os in
82*linux*)
27e231ff 83 AM_CONDITIONAL([LINUX], true)
e33dcf90
ML
84 AM_CONDITIONAL([WIN32], false)
85 AM_CONDITIONAL([MACOSX], false)
1ebf4347
ML
86 ;;
87*darwin*)
27e231ff 88 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
89 AM_CONDITIONAL([WIN32], false)
90 AM_CONDITIONAL([MACOSX], true)
1ebf4347
ML
91 LDFLAGS="$LDFLAGS -Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
92 AC_CHECK_HEADER(IOKit/IOKitLib.h, [], [AC_MSG_ERROR([IOKit/IOKitLib.h not found])])
93 ;;
a93fb468
AJ
94mingw* | cygwin*)
95 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
96 AM_CONDITIONAL([WIN32], true)
97 AM_CONDITIONAL([MACOSX], false)
a93fb468
AJ
98 SP_LIBS="-lsetupapi -luuid"
99 ;;
27e231ff
ML
100*)
101 AM_CONDITIONAL([LINUX], false)
e33dcf90
ML
102 AM_CONDITIONAL([WIN32], false)
103 AM_CONDITIONAL([MACOSX], false)
e4ce975a
ML
104 AC_DEFINE(NO_ENUMERATION)
105 AC_DEFINE(NO_PORT_METADATA)
1ebf4347
ML
106esac
107
e4bffe06 108AC_SUBST(SP_PKGLIBS)
a93fb468 109AC_SUBST(SP_LIBS)
e4bffe06 110
7c3a1ee3 111# Define size_t if not defined as standard.
0662f2bb 112AC_TYPE_SIZE_T
2dcf8308
ML
113
114# Check for specific termios structures.
7c3a1ee3
UH
115AC_CHECK_TYPE([struct termios2], [AC_DEFINE(HAVE_TERMIOS2, 1)], [], [[#include <linux/termios.h>]])
116AC_CHECK_TYPE([struct termiox], [AC_DEFINE(HAVE_TERMIOX, 1)], [], [[#include <linux/termios.h>]])
5cea279a
ML
117AC_CHECK_MEMBERS([struct termios.c_ispeed, struct termios.c_ospeed],
118 [AC_DEFINE(HAVE_TERMIOS_SPEED, 1)], [], [[#include <linux/termios.h>]])
119AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
120 [AC_DEFINE(HAVE_TERMIOS2_SPEED, 1)], [], [[#include <linux/termios.h>]])
0662f2bb 121
12056e2f
MC
122# Check for serial_struct.
123AC_CHECK_TYPE([struct serial_struct], [AC_DEFINE(HAVE_SERIAL_STRUCT, 1)],
124 [], [[#include <linux/serial.h>]])
125
970f279a
AJ
126saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
127AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
128 __attribute__((visibility("hidden"))) void foo(void) { }
129 ]])],
130 [AC_DEFINE(SP_API , __attribute__((visibility("default"))))]
131 [AC_DEFINE(SP_PRIV, __attribute__((visibility("hidden"))))],
132AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
133 __declspec(dllexport) void foo(void) { }
134 ]])],
135 [AC_DEFINE(SP_API , __declspec(dllexport))]
136 [AC_DEFINE(SP_PRIV,)],
137 [AC_DEFINE(SP_API,)]
138 [AC_DEFINE(SP_PRIV,)]))
139CFLAGS="$saved"
140
0662f2bb
ML
141AC_SUBST(MAKEFLAGS, '--no-print-directory')
142AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
143
144SP_PACKAGE_VERSION_MAJOR=sp_package_version_major
145SP_PACKAGE_VERSION_MINOR=sp_package_version_minor
7de20e39 146SP_PACKAGE_VERSION_MICRO=sp_package_version_micro
0662f2bb
ML
147SP_PACKAGE_VERSION=sp_package_version
148
149AC_SUBST(SP_PACKAGE_VERSION_MAJOR)
150AC_SUBST(SP_PACKAGE_VERSION_MINOR)
7de20e39 151AC_SUBST(SP_PACKAGE_VERSION_MICRO)
0662f2bb
ML
152AC_SUBST(SP_PACKAGE_VERSION)
153
baba0759 154AC_CONFIG_FILES([Makefile libserialport.h libserialport.pc])
0662f2bb
ML
155
156AC_OUTPUT
157
158echo
159echo "libserialport configuration summary:"
160echo
7de20e39 161echo " - Package version (major.minor.micro): $SP_PACKAGE_VERSION"
0662f2bb
ML
162echo " - Library version (current:revision:age): $SP_LIB_VERSION"
163echo " - Prefix: $prefix"
164echo " - Building on: $build"
165echo " - Building for: $host"
166echo