]> sigrok.org Git - libsigrok.git/blame - configure.ac
brymen-bm86x: Add current loop sensor support.
[libsigrok.git] / configure.ac
CommitLineData
826938d8 1##
50985c20 2## This file is part of the libsigrok project.
826938d8 3##
c73d2ea4 4## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
d375b3c3 5## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
826938d8
UH
6##
7## This program is free software: you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation, either version 3 of the License, or
10## (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 General Public License
18## along with this program. If not, see <http://www.gnu.org/licenses/>.
19##
20
ef7228ba
UH
21# We require at least autoconf 2.63 (AC_INIT format changed there).
22AC_PREREQ([2.63])
826938d8 23
3af71f0d 24# libsigrok package version number (NOT the same as shared lib version!).
6dddd902 25m4_define([sr_package_version_major], [0])
4133caab
UH
26m4_define([sr_package_version_minor], [3])
27m4_define([sr_package_version_micro], [0])
6dddd902 28m4_define([sr_package_version], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro])
826938d8 29
6dddd902 30AC_INIT([libsigrok], [sr_package_version], [sigrok-devel@lists.sourceforge.net],
db8ae7b9 31 [libsigrok], [http://www.sigrok.org])
826938d8 32AC_CONFIG_HEADER([config.h])
d8521c93
UH
33AC_CONFIG_MACRO_DIR([autostuff])
34AC_CONFIG_AUX_DIR([autostuff])
826938d8 35
ef7228ba 36# We require at least automake 1.11 (needed for 'silent rules').
67bd8055 37AM_INIT_AUTOMAKE([1.11 -Wall -Werror subdir-objects check-news color-tests])
826938d8 38m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
432e5e95 39m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
826938d8 40
6dddd902
UH
41AH_TOP([#ifndef SR_CONFIG_H
42#define SR_CONFIG_H /* To stop multiple inclusions. */])
43AH_BOTTOM([#endif /* SR_CONFIG_H */])
826938d8 44
1a081ca6
UH
45# Enable more compiler warnings via -Wall and -Wextra. Add -fvisibility=hidden
46# and enforce use of SR_API to explicitly mark all public API functions.
4f10853e
ML
47COMMON_FLAGS="$CFLAGS -Wall -Wextra -fvisibility=hidden"
48CFLAGS="$COMMON_FLAGS -Wmissing-prototypes"
c23c8659 49CXXFLAGS="-std=c++11 $COMMON_FLAGS"
826938d8
UH
50
51# Checks for programs.
826938d8
UH
52AC_PROG_CC
53AC_PROG_CPP
c23c8659 54AC_PROG_CXX
826938d8
UH
55AC_PROG_INSTALL
56AC_PROG_LN_S
57
bb203cde
UH
58# Required for per-target flags or subdir-objects with C sources.
59AM_PROG_CC_C_O
60
826938d8
UH
61# Initialize libtool.
62LT_INIT
63
64# Initialize pkg-config.
65# We require at least 0.22, as "Requires.private" behaviour changed there.
66PKG_PROG_PKG_CONFIG([0.22])
67
3af71f0d 68# Library version for libsigrok (NOT the same as the package version).
826938d8
UH
69# Carefully read the libtool docs before updating these numbers!
70# The algorithm for determining which number to change (and how) is nontrivial!
71# http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
85ca913c
UH
72SR_LIB_VERSION_CURRENT=2
73SR_LIB_VERSION_REVISION=0
6dddd902
UH
74SR_LIB_VERSION_AGE=0
75SR_LIB_VERSION="$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"
76SR_LIB_LDFLAGS="-version-info $SR_LIB_VERSION"
77AC_SUBST(SR_LIB_VERSION_CURRENT)
78AC_SUBST(SR_LIB_VERSION_REVISION)
79AC_SUBST(SR_LIB_VERSION_AGE)
80AC_SUBST(SR_LIB_VERSION)
81AC_SUBST(SR_LIB_LDFLAGS)
826938d8 82
dbf2482e
BV
83AC_ARG_ENABLE(all-drivers, AC_HELP_STRING([--enable-all-drivers],
84 [enable all drivers by default [default=yes]]),
85 [HW_ENABLED_DEFAULT="$enableval"],
86 [HW_ENABLED_DEFAULT="yes"])
87
d4b38748
BV
88# Usage: DRIVER([Device name], [driver-name])
89# An optional third argument [no] disables that driver.
90m4_define([driverize], [m4_tolower(m4_bpatsubst([$1], [[^0-9a-zA-Z-]+], [-]))])
91m4_define([upperize], [m4_toupper(m4_bpatsubst([$1], [[^0-9a-zA-Z_]+], [_]))])
92AC_DEFUN([DRIVER], [
93 if test -z "$3"; then
94 default=$HW_ENABLED_DEFAULT
95 else
96 default="$3"
97 fi
98 AC_ARG_ENABLE($2, AC_HELP_STRING([--enable-$2], [enable $1 support]),
99 [m4_join([], [HW_], upperize([$2]))="$enableval"],
100 [m4_join([], [HW_], upperize([$2]))=$default])
43cd4637
BV
101 dots=$(echo -n ".............................." | cut -c 1-$(expr 32 - $(echo -n $2|wc -c)))
102 driver_summary="${driver_summary} - $2${dots} \${m4_join([], [HW_], upperize([$2]))}@"
d4b38748
BV
103])
104
105DRIVER([Agilent DMM], [agilent-dmm])
106DRIVER([Appa 55II], [appa-55ii])
107DRIVER([ASIX SIGMA/SIGMA2], [asix-sigma])
108DRIVER([Atten PPS3xxx], [atten-pps3xxx])
bb993797 109DRIVER([BeagleLogic], [beaglelogic])
d4b38748
BV
110DRIVER([Brymen BM86x], [brymen-bm86x])
111DRIVER([Brymen DMM], [brymen-dmm])
112DRIVER([CEM DT-885x], [cem-dt-885x])
113DRIVER([Center 3xx], [center-3xx])
114DRIVER([ChronoVu LA], [chronovu-la])
115DRIVER([Colead SLM], [colead-slm])
116DRIVER([Conrad DIGI 35 CPU], [conrad-digi-35-cpu])
117DRIVER([demo], [demo])
118DRIVER([Fluke DMM], [fluke-dmm])
119DRIVER([fx2lafw], [fx2lafw])
120DRIVER([GMC MH 1x/2x], [gmc-mh-1x-2x])
121DRIVER([Hameg HMO], [hameg-hmo])
122DRIVER([Hantek DSO], [hantek-dso])
123DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2])
124DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus])
125DRIVER([Kecheng KC-330B], [kecheng-kc-330b])
126DRIVER([Lascar EL-USB], [lascar-el-usb])
127DRIVER([Manson HCS-3xxx], [manson-hcs-3xxx])
128DRIVER([MIC 985xx], [mic-985xx])
129DRIVER([Motech LPS 30x], [motech-lps-30x])
130DRIVER([Norma DMM], [norma-dmm])
131DRIVER([OpenBench Logic Sniffer], [openbench-logic-sniffer])
4bd80e12 132DRIVER([Pipistrello-OLS], [pipistrello-ols])
d4b38748
BV
133DRIVER([Rigol DS], [rigol-ds])
134DRIVER([Saleae Logic16], [saleae-logic16])
135DRIVER([serial DMM], [serial-dmm])
136DRIVER([Sysclk LWLA], [sysclk-lwla])
137DRIVER([Teleinfo], [teleinfo])
138DRIVER([Testo], [testo])
139DRIVER([Tondaj SL-814], [tondaj-sl-814])
140DRIVER([UNI-T DMM], [uni-t-dmm])
141DRIVER([UNI-T UT32x], [uni-t-ut32x])
142DRIVER([Victor DMM], [victor-dmm])
10763937 143DRIVER([Yokogawa DL/DLM], [yokogawa-dlm])
d4b38748 144DRIVER([ZEROPLUS Logic Cube], [zeroplus-logic-cube])
826938d8 145
a4737997
MF
146AC_ARG_ENABLE(libserialport,
147 AC_HELP_STRING([--disable-libserialport],
148 [disable libserialport support [default=detect]]))
149
150AC_ARG_ENABLE(libftdi,
151 AC_HELP_STRING([--disable-libftdi],
152 [disable libftdi support [default=detect]]))
153
154AC_ARG_ENABLE(libusb,
155 AC_HELP_STRING([--disable-libusb],
156 [disable libusb support [default=detect]]))
157
c23c8659
ML
158# Language binding '--enable' options
159
6223feeb
BV
160AC_ARG_ENABLE(bindings,
161 AC_HELP_STRING([--enable-bindings],
162 [build language bindings [default=yes]]),
163 [BINDINGS_ALL="$enableval"], [BINDINGS_ALL="yes"])
164
165AC_ARG_ENABLE(cxx,
c23c8659
ML
166 AC_HELP_STRING([--enable-cxx],
167 [build C++ bindings [default=yes]]),
6223feeb 168 [BINDINGS_CXX="$enableval"], [BINDINGS_CXX=$BINDINGS_ALL])
c23c8659 169
f7740954
ML
170AC_ARG_ENABLE(python,
171 AC_HELP_STRING([--enable-python],
172 [build Python bindings [default=yes]]),
6223feeb 173 [BINDINGS_PYTHON="$enableval"], [BINDINGS_PYTHON=$BINDINGS_ALL])
f7740954 174
9fcf4d0b
ML
175AC_ARG_ENABLE(java,
176 AC_HELP_STRING([--enable-java],
177 [build Java bindings [default=yes]]),
6223feeb 178 [BINDINGS_JAVA="$enableval"], [BINDINGS_JAVA=$BINDINGS_ALL])
9fcf4d0b 179
3e27b177
MC
180AC_ARG_WITH(jni-include-path,
181 AC_HELP_STRING([--with-jni-include-path=path],
182 [specify include path for JNI [default=autodetect]]),
183 [JNI_INCLUDE_DIRS="$withval"], [JNI_INCLUDE_DIRS=auto])
184
c23c8659
ML
185# Check if the C++ compiler supports the C++11 standard.
186
f8158d56
BV
187m4_ifdef([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX_11(,[optional])],
188 [AC_MSG_NOTICE([Missing macro m4_toupper(aX_CXX_COMPILE_STDCXX_11), no C++11 check])])
c23c8659
ML
189
190if test "x$HAVE_CXX11" != "x1"; then
1029d384 191 BINDINGS_CXX="no"; cxx_msg="C++11 compiler required"
c23c8659
ML
192fi
193
3532ed01
ML
194# The C++ bindings use doxygen to parse libsigrok symbols.
195AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes])
196if test "x$HAVE_DOXYGEN" != "xyes"; then
197 BINDINGS_CXX="no"; cxx_msg="doxygen required"
bcacb863
BV
198fi
199
de44e114
BV
200# Python is needed for the C++ bindings.
201AC_CHECK_PROG([HAVE_PYTHON], [python], [yes])
202if test "x$HAVE_PYTHON" != "xyes"; then
203 BINDINGS_CXX="no"; cxx_msg="Python required"
204fi
205
206# The Python bindings need Python development files
57d62c4c 207PKG_CHECK_MODULES([python], [python >= 2.7],
bcacb863
BV
208 [CXXFLAGS="$CXXFLAGS $python_CFLAGS";
209 CXXLIBS="$CXXLIBS $python_LIBS"],
2ba308ec
MC
210[PKG_CHECK_MODULES([python27], [python-2.7 >= 2.7],
211 [CXXFLAGS="$CXXFLAGS $python27_CFLAGS";
212 CXXLIBS="$CXXLIBS $python27_LIBS"],
213 [BINDINGS_PYTHON="no"; python_msg="Python headers required"])])
bcacb863 214
de44e114 215# The Python bindings need the setuptools Python module.
0afa91b7
BV
216m4_ifdef([AX_PYTHON_MODULE], [AX_PYTHON_MODULE([setuptools])],
217 # We'll let it go through even if the macro wasn't found, the python
218 # module may still be there.
219 [HAVE_PYTHON_SETUPTOOLS="yes";
220 AC_MSG_NOTICE([Missing macro m4_toupper(aX_PYTHON_MODULE), no setuptools check])]
221)
222if test "x$HAVE_PYMOD_SETUPTOOLS" != "xyes"; then
de44e114 223 BINDINGS_PYTHON="no"; python_msg="Python setuptools module required"
0afa91b7 224fi
f7740954 225
0afa91b7
BV
226# The Python and Java bindings use swig to generate code.
227AC_CHECK_PROG([HAVE_SWIG], [swig], [yes])
228if test "x$HAVE_SWIG" != "xyes"; then
1029d384
BV
229 BINDINGS_PYTHON="no"; python_msg="swig required"
230 BINDINGS_JAVA="no"; java_msg="swig required"
f7740954
ML
231fi
232
826938d8
UH
233# Checks for libraries.
234
1c6736ab
ML
235case "$host" in
236*mingw*)
237 # We need to link against the Winsock2 library for SCPI over TCP.
238 LIBS="$LIBS -lws2_32";;
239esac
240
826938d8
UH
241# This variable collects the pkg-config names of all detected libs.
242# It is then used to construct the "Requires.private:" field in the
243# libsigrok.pc file.
6dddd902 244SR_PKGLIBS=""
826938d8 245
ee8ddd8f
UH
246# libm (the standard math library) is always needed.
247AC_SEARCH_LIBS([pow], [m])
248
7d4874c1 249# RPC is only needed for VXI support.
d5876cfb
AJ
250AC_MSG_CHECKING([for RPC support])
251AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <rpc/rpc.h>],
823b4e58
MH
252 [CLIENT *rpc_test(void)],
253 [{ return clnt_create("", 0, 0, ""); }])],
254 [AC_MSG_RESULT([yes]); have_rpc=1],
255 [AC_MSG_RESULT([no]); have_rpc=0])
d5876cfb 256# Define HAVE_RPC in config.h if we found RPC support.
7d4874c1 257AC_DEFINE_UNQUOTED(HAVE_RPC, [$have_rpc], [Specifies whether we have RPC support.])
d5876cfb 258# VXI support is only compiled if RPC support was found.
7d4874c1 259AM_CONDITIONAL(NEED_RPC, test "x$have_rpc" != "x0")
d5876cfb 260
aba69262 261# libglib-2.0 is always needed. Abort if it's not found.
826938d8 262# Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
406569dd
UH
263# We require at least 2.32.0 due to e.g. g_variant_new_fixed_array().
264AM_PATH_GLIB_2_0([2.32.0],
4f10853e 265 [LIB_CFLAGS="$LIB_CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
826938d8 266
aba69262 267# libzip is always needed. Abort if it's not found.
8819bf5a 268PKG_CHECK_MODULES([libzip], [libzip >= 0.10],
4f10853e 269 [LIB_CFLAGS="$LIB_CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
6dddd902 270 SR_PKGLIBS="$SR_PKGLIBS libzip"])
826938d8 271
c4f2dfd0
UH
272# libserialport is only needed for some hardware drivers. Disable the
273# respective drivers if it is not found.
a4737997 274if test "x$enable_libserialport" != "xno"; then
81a69107 275 PKG_CHECK_MODULES([libserialport], [libserialport >= 0.2.0],
a4737997
MF
276 [have_libserialport="yes"; LIB_CFLAGS="$LIB_CFLAGS $libserialport_CFLAGS";
277 LIBS="$LIBS $libserialport_LIBS";
278 SR_PKGLIBS="$SR_PKGLIBS libserialport"],
279 [have_libserialport="no"])
280 if test "x$enable_libserialport$have_libserialport" = "xyesno"; then
281 AC_MSG_ERROR([libserialport support requested, but it was not found])
282 fi
283else
284 have_libserialport="no"
285fi
286
287# Define HAVE_LIBSERIALPORT in config.h if we found libserialport.
288if test "x$have_libserialport" = "xno"; then
289 HW_AGILENT_DMM="no"; HW_APPA_55II="no";
1c183900 290 HW_ATTEN_PPS3XXX="no"; HW_BRYMEN_DMM="no"; HW_CEM_DT_885X="no";
823b4e58 291 HW_CENTER_3XX="no"; HW_COLEAD_SLM="no"; HW_CONRAD_DIGI_35_CPU="no";
8c21897f 292 HW_FLUKE_DMM="no"; HW_GMC_MH_1X_2X="no"; HW_HAMEG_HMO="no";
adeae78f 293 HW_MANSON_HCS_3XXX="no"; HW_MIC_985XX="no"; HW_MOTECH_LPS_30X="no";
d4b38748
BV
294 HW_NORMA_DMM="no"; HW_OPENBENCH_LOGIC_SNIFFER="no"; HW_SERIAL_DMM="no";
295 HW_TELEINFO="no"; HW_TONDAJ_SL_814="no";
a4737997 296else
c4f2dfd0
UH
297 AC_DEFINE_UNQUOTED(HAVE_LIBSERIALPORT, [1],
298 [Specifies whether we have libserialport.])
299fi
300
301# Serial port helper code is only compiled in if libserialport was found.
302AM_CONDITIONAL(NEED_SERIAL, test "x$have_libserialport" != xno)
a9bce5a5 303
d6e63a2c 304# VISA SCPI backend is only compiled in if librevisa was found.
1fb2312f 305PKG_CHECK_MODULES([librevisa], [librevisa >= 0.0.20130812],
4f10853e 306 [have_librevisa="yes"; LIB_CFLAGS="$LIB_CFLAGS $librevisa_CFLAGS";
1fb2312f 307 LIBS="$LIBS $librevisa_LIBS";
b84b7ee7
ML
308 SR_PKGLIBS="$SR_PKGLIBS librevisa"],
309 [have_librevisa="no"])
1fb2312f
ML
310AM_CONDITIONAL(NEED_VISA, test "x$have_librevisa" != xno)
311
312# Define HAVE_LIBREVISA in config.h if we found librevisa.
313if test "x$have_librevisa" != "xno"; then
314 AC_DEFINE_UNQUOTED(HAVE_LIBREVISA, [1],
315 [Specifies whether we have librevisa.])
316fi
317
bb2a4ed4 318# GPIB backend is only compiled in if libgpib headers found.
d6e63a2c
BV
319PKG_CHECK_MODULES([libgpib], [libgpib],
320 [have_libgpib="yes"; LIB_CFLAGS="$LIB_CFLAGS $libgpib_CFLAGS";
321 LIBS="$LIBS $libgpib_LIBS";
322 SR_PKGLIBS="$SR_PKGLIBS libgpib"],
323 [have_libgpib="no"])
bb2a4ed4 324AM_CONDITIONAL(NEED_GPIB, test "x$have_libgpib" != xno)
d6e63a2c
BV
325
326# Define HAVE_LIBGPIB in config.h if we found libgpib.
bb2a4ed4
ML
327if test "x$have_libgpib" != "xno"; then
328 AC_DEFINE_UNQUOTED(HAVE_LIBGPIB, [1],
329 [Specifies whether we have libgpib.])
330fi
331
aba69262
UH
332# libusb-1.0 is only needed for some hardware drivers. Disable the respective
333# drivers if it is not found.
a4737997
MF
334if test "x$enable_libusb" != "xno"; then
335 case "$host" in
336 *freebsd*)
337 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
338 # This means libusb-1.0 is always available, no need to check for it,
339 # and no need to (potentially) disable any drivers if it's not found.
340 have_libusb1_0="yes"
341 ;;
342 *)
343 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.16],
344 [have_libusb1_0="yes"; LIB_CFLAGS="$LIB_CFLAGS $libusb_CFLAGS";
345 LIBS="$LIBS $libusb_LIBS";
346 SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"],
347 [have_libusb1_0="no"])
348 if test "x$enable_libusb$have_libusb1_0" = "xyesno"; then
349 AC_MSG_ERROR([libusb support requested, but it was not found])
350 fi
351 ;;
352 esac
353else
354 have_libusb1_0="no"
355fi
356
357# Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
358if test "x$have_libusb1_0" = "xno"; then
359 HW_BRYMEN_BM86X="no"; HW_FX2LAFW="no";
360 HW_HANTEK_DSO="no"; HW_IKALOGIC_SCANALOGIC2="no";
361 HW_KECHENG_KC_330B="no"; HW_LASCAR_EL_USB="no";
0acdd793 362 HW_SYSCLK_LWLA="no"; HW_TESTO="no"; HW_UNI_T_DMM="no";
a4737997
MF
363 HW_UNI_T_UT32X="no"; HW_VICTOR_DMM="no";
364 HW_ZEROPLUS_LOGIC_CUBE="no"; HW_SALEAE_LOGIC16="no";
365else
aba69262
UH
366 AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
367 [Specifies whether we have a libusb.h header.])
a4737997 368fi
aba69262 369
3fd1d0ee
UH
370# USB + FX2 firmware helper code is only compiled in if libusb-1.0 was found.
371AM_CONDITIONAL(NEED_USB, test "x$have_libusb1_0" != xno)
372
aba69262 373# libftdi is only needed for some hardware drivers. Disable them if not found.
a4737997
MF
374if test "x$enable_libftdi" != "xno"; then
375 PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
376 [have_libftdi="yes"; LIB_CFLAGS="$LIB_CFLAGS $libftdi_CFLAGS";
377 LIBS="$LIBS $libftdi_LIBS";
378 SR_PKGLIBS="$SR_PKGLIBS libftdi"],
c78bcc6f 379 [PKG_CHECK_MODULES([libftdi1], [libftdi1 >= 1.0],
92506359
DH
380 [LIB_CFLAGS="$LIB_CFLAGS $libftdi1_CFLAGS";
381 LIBS="$LIBS $libftdi1_LIBS";
382 SR_PKGLIBS="$SR_PKGLIBS libftdi1"],
383 [have_libftdi="no"])])
a4737997
MF
384 if test "x$enable_libftdi$have_libftdi" = "xyesno"; then
385 AC_MSG_ERROR([libftdi support requested, but it was not found])
386 fi
387else
388 have_libftdi="no"
389fi
390
391if test "x$have_libftdi" = "xno"; then
392 HW_ASIX_SIGMA="no"; HW_CHRONOVU_LA="no"; HW_IKALOGIC_SCANAPLUS="no";
4bd80e12 393 HW_PIPISTRELLO_OLS="no";
a4737997 394fi
aba69262 395
c23c8659
ML
396# glibmm-2.4 is needed for the C++ bindings.
397PKG_CHECK_MODULES([glibmm], [glibmm-2.4 >= 2.32.0],
398 [CXXFLAGS="$CXXFLAGS $glibmm_CFLAGS";
1029d384
BV
399 CXXLIBS="$CXXLIBS $glibmm_LIBS"],
400 [BINDINGS_CXX="no"; cxx_msg="glibmm required"])
c23c8659 401
d92de05a
MC
402# C++ bindings want stoi and stod
403if test "x$BINDINGS_CXX" == "xyes"; then
404 AC_LANG_PUSH([C++])
405 AC_MSG_CHECKING([for stoi and stod])
406 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string>],
407 [{ return std::stoi("1")+std::stod("1.0"); }])],
408 [AC_MSG_RESULT([yes]);
409 AC_DEFINE_UNQUOTED(HAVE_STOI_STOD, [1],
410 [Specifies whether we have the stoi and stod functions.])],
411 [AC_MSG_RESULT([no])])
412 AC_LANG_POP([C++])
413fi
414
f7740954 415# PyGObject is needed for the Python bindings.
022a7fe0 416PKG_CHECK_MODULES([pygobject], [pygobject-3.0 >= 3.0.0],
f7740954 417 [CXXFLAGS="$CXXFLAGS $pygobject_CFLAGS";
abc7146d
ML
418 CXXLIBS="$CXXLIBS $pygobject_LIBS";
419 PKG_CHECK_MODULES([pygobject_3_7_91], [pygobject-3.0 >= 3.7.91],
420 [pyg_flags_signed=0], [pyg_flags_signed=1]);
421 AC_DEFINE_UNQUOTED(PYGOBJECT_FLAGS_SIGNED, [$pyg_flags_signed],
422 [Whether last argument to pyg_flags_get_value() is signed])],
1029d384 423 [BINDINGS_PYTHON="no"; python_msg="Python pygobject module required"])
f7740954 424
aba69262 425# The Check unit testing framework is optional. Disable if not found.
79bb0e97 426PKG_CHECK_MODULES([check], [check >= 0.9.4],
82bfb646 427 [have_check="yes"], [have_check="no"])
79bb0e97
UH
428AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
429
37fa80b4
ML
430# The OLS driver uses serial port file descriptors directly, and therefore
431# will not currently work on Windows.
432case "$host" in
433*mingw*)
d4b38748 434 HW_OPENBENCH_LOGIC_SNIFFER="no"
d0a92abd 435 ;;
37fa80b4
ML
436esac
437
375340a7
UH
438# The BeagleLogic driver needs sys/mman.h and sys/ioctl.h. Don't try to
439# build it if these headers aren't available.
440AC_CHECK_HEADERS([sys/mman.h sys/ioctl.h], [], [HW_BEAGLELOGIC="no"])
441
6dddd902 442AC_SUBST(SR_PKGLIBS)
826938d8 443
55e55a3f 444CFLAGS="$CFLAGS -Iinclude/libsigrok -I${srcdir}/include/libsigrok $LIB_CFLAGS"
33c84e81 445CXXFLAGS="$CXXFLAGS -Iinclude/libsigrok -I${srcdir}/include -Ibindings/cxx -Ibindings/cxx/include/libsigrok -I${srcdir}/bindings/cxx/include $LIB_CFLAGS"
4f10853e 446
9fcf4d0b
ML
447# Find Java compiler and JNI includes for Java bindings.
448
449AC_CHECK_PROG([HAVE_JAVAC], [javac], [yes], [no])
450
451if test "x$HAVE_JAVAC" = "xyes"; then
452 AX_PROG_JAVAC
3e27b177
MC
453 if test "x$JNI_INCLUDE_DIRS" = "xauto"; then
454 if test "x$cross_compiling" = "xyes"; then
455 JNI_INCLUDE_DIRS=
456 else
457 AX_JNI_INCLUDE_DIR
458 fi
459 fi
9fcf4d0b
ML
460 for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
461 CXXFLAGS="$CXXFLAGS -I$JNI_INCLUDE_DIR"
462 done
3e27b177
MC
463 AC_LANG_PUSH([C++])
464 AC_CHECK_HEADERS([jni.h], [], [BINDINGS_JAVA="no"; java_msg="Java JNI headers required"])
465 AC_LANG_POP([C++])
9fcf4d0b 466else
1029d384
BV
467 BINDINGS_JAVA="no"; java_msg="Java compiler required"
468fi
469
470# Python and Java bindings depend on C++ bindings.
471if test "x$BINDINGS_CXX" != "xyes"; then
472 BINDINGS_PYTHON="no"; python_msg="C++ bindings required"
473 BINDINGS_JAVA="no"; java_msg="C++ bindings required"
9fcf4d0b
ML
474fi
475
ae4c3d04
UH
476# Now set AM_CONDITIONALs and AC_DEFINEs for the enabled/disabled drivers.
477
478AM_CONDITIONAL(HW_AGILENT_DMM, test x$HW_AGILENT_DMM = xyes)
479if test "x$HW_AGILENT_DMM" = "xyes"; then
480 AC_DEFINE(HAVE_HW_AGILENT_DMM, 1, [Agilent DMM support])
481fi
482
5e7a8e57
AJ
483AM_CONDITIONAL(HW_APPA_55II, test x$HW_APPA_55II = xyes)
484if test "x$HW_APPA_55II" = "xyes"; then
485 AC_DEFINE(HAVE_HW_APPA_55II, 1, [APPA 55II support])
486fi
487
9e165e74
UH
488AM_CONDITIONAL(HW_ASIX_SIGMA, test x$HW_ASIX_SIGMA = xyes)
489if test "x$HW_ASIX_SIGMA" = "xyes"; then
490 AC_DEFINE(HAVE_HW_ASIX_SIGMA, 1, [ASIX SIGMA/SIGMA2 support])
ae4c3d04
UH
491fi
492
1c183900
MS
493AM_CONDITIONAL(HW_ATTEN_PPS3XXX, test x$HW_ATTEN_PPS3XXX = xyes)
494if test "x$HW_ATTEN_PPS3XXX" = "xyes"; then
d0a92abd 495 AC_DEFINE(HAVE_HW_ATTEN_PPS3XXX, 1, [Atten PPS3xxx support])
1c183900
MS
496fi
497
bb993797
KA
498AM_CONDITIONAL(HW_BEAGLELOGIC, test x$HW_BEAGLELOGIC = xyes)
499if test "x$HW_BEAGLELOGIC" = "xyes"; then
500 AC_DEFINE(HAVE_HW_BEAGLELOGIC, 1, [BeagleLogic support])
501fi
502
1b950bc7
UH
503AM_CONDITIONAL(HW_BRYMEN_BM86X, test x$HW_BRYMEN_BM86X = xyes)
504if test "x$HW_BRYMEN_BM86X" = "xyes"; then
505 AC_DEFINE(HAVE_HW_BRYMEN_BM86X, 1, [Brymen BM86X support])
506fi
507
ae4c3d04
UH
508AM_CONDITIONAL(HW_BRYMEN_DMM, test x$HW_BRYMEN_DMM = xyes)
509if test "x$HW_BRYMEN_DMM" = "xyes"; then
e4fad80b 510 AC_DEFINE(HAVE_HW_BRYMEN_DMM, 1, [Brymen DMM support])
ae4c3d04
UH
511fi
512
32be5b22
UH
513AM_CONDITIONAL(HW_CEM_DT_885X, test x$HW_CEM_DT_885X = xyes)
514if test "x$HW_CEM_DT_885X" = "xyes"; then
515 AC_DEFINE(HAVE_HW_CEM_DT_885X, 1, [CEM DT-885x support])
516fi
517
4433145f
UH
518AM_CONDITIONAL(HW_CENTER_3XX, test x$HW_CENTER_3XX = xyes)
519if test "x$HW_CENTER_3XX" = "xyes"; then
520 AC_DEFINE(HAVE_HW_CENTER_3XX, 1, [Center 3xx support])
521fi
522
7b356712
UH
523AM_CONDITIONAL(HW_CHRONOVU_LA, test x$HW_CHRONOVU_LA = xyes)
524if test "x$HW_CHRONOVU_LA" = "xyes"; then
525 AC_DEFINE(HAVE_HW_CHRONOVU_LA, 1, [ChronoVu LA support])
ae4c3d04
UH
526fi
527
528AM_CONDITIONAL(HW_COLEAD_SLM, test x$HW_COLEAD_SLM = xyes)
529if test "x$HW_COLEAD_SLM" = "xyes"; then
530 AC_DEFINE(HAVE_HW_COLEAD_SLM, 1, [Colead SLM support])
531fi
532
823b4e58
MH
533AM_CONDITIONAL(HW_CONRAD_DIGI_35_CPU, test x$HW_CONRAD_DIGI_35_CPU = xyes)
534if test "x$HW_CONRAD_DIGI_35_CPU" = "xyes"; then
535 AC_DEFINE(HAVE_HW_CONRAD_DIGI_35_CPU, 1, [Conrad DIGI 35 CPU support])
536fi
537
9e165e74
UH
538AM_CONDITIONAL(HW_DEMO, test x$HW_DEMO = xyes)
539if test "x$HW_DEMO" = "xyes"; then
540 AC_DEFINE(HAVE_HW_DEMO, 1, [Demo driver support])
ae4c3d04
UH
541fi
542
543AM_CONDITIONAL(HW_FLUKE_DMM, test x$HW_FLUKE_DMM = xyes)
544if test "x$HW_FLUKE_DMM" = "xyes"; then
545 AC_DEFINE(HAVE_HW_FLUKE_DMM, 1, [Fluke DMM support])
546fi
547
9e165e74
UH
548AM_CONDITIONAL(HW_FX2LAFW, test x$HW_FX2LAFW = xyes)
549if test "x$HW_FX2LAFW" = "xyes"; then
550 AC_DEFINE(HAVE_HW_FX2LAFW, 1, [fx2lafw support])
ae4c3d04
UH
551fi
552
7b4edcb6
MH
553AM_CONDITIONAL(HW_GMC_MH_1X_2X, test x$HW_GMC_MH_1X_2X = xyes)
554if test "x$HW_GMC_MH_1X_2X" = "xyes"; then
555 AC_DEFINE(HAVE_HW_GMC_MH_1X_2X, 1, [gmc-mh-1x-2x support])
556fi
557
ae4c3d04
UH
558AM_CONDITIONAL(HW_HANTEK_DSO, test x$HW_HANTEK_DSO = xyes)
559if test "x$HW_HANTEK_DSO" = "xyes"; then
560 AC_DEFINE(HAVE_HW_HANTEK_DSO, 1, [Hantek DSO support])
561fi
562
582b3d21
UH
563AM_CONDITIONAL(HW_HAMEG_HMO, test x$HW_HAMEG_HMO = xyes)
564if test "x$HW_HAMEG_HMO" = "xyes"; then
565 AC_DEFINE(HAVE_HW_HAMEG_HMO, 1, [Hameg HMO support])
566fi
567
1f36a6c6
UH
568AM_CONDITIONAL(HW_IKALOGIC_SCANALOGIC2, test x$HW_IKALOGIC_SCANALOGIC2 = xyes)
569if test "x$HW_IKALOGIC_SCANALOGIC2" = "xyes"; then
ce95428c 570 AC_DEFINE(HAVE_HW_IKALOGIC_SCANALOGIC2, 1, [IKALOGIC Scanalogic-2 support])
1f36a6c6
UH
571fi
572
fdf4a1f5
UH
573AM_CONDITIONAL(HW_IKALOGIC_SCANAPLUS, test x$HW_IKALOGIC_SCANAPLUS = xyes)
574if test "x$HW_IKALOGIC_SCANAPLUS" = "xyes"; then
ce95428c 575 AC_DEFINE(HAVE_HW_IKALOGIC_SCANAPLUS, 1, [IKALOGIC ScanaPLUS support])
fdf4a1f5
UH
576fi
577
ed759a08
BV
578AM_CONDITIONAL(HW_KECHENG_KC_330B, test x$HW_KECHENG_KC_330B = xyes)
579if test "x$HW_KECHENG_KC_330B" = "xyes"; then
580 AC_DEFINE(HAVE_HW_KECHENG_KC_330B, 1, [Kecheng KC-330B support])
581fi
582
ae4c3d04
UH
583AM_CONDITIONAL(HW_LASCAR_EL_USB, test x$HW_LASCAR_EL_USB = xyes)
584if test "x$HW_LASCAR_EL_USB" = "xyes"; then
585 AC_DEFINE(HAVE_HW_LASCAR_EL_USB, 1, [Lascar EL-USB support])
586fi
587
8f4e922f
UH
588AM_CONDITIONAL(HW_MANSON_HCS_3XXX, test x$HW_MANSON_HCS_3XXX = xyes)
589if test "x$HW_MANSON_HCS_3XXX" = "xyes"; then
590 AC_DEFINE(HAVE_HW_MANSON_HCS_3XXX, 1, [Manson HCS-3xxx support])
591fi
592
ae4c3d04
UH
593AM_CONDITIONAL(HW_MIC_985XX, test x$HW_MIC_985XX = xyes)
594if test "x$HW_MIC_985XX" = "xyes"; then
595 AC_DEFINE(HAVE_HW_MIC_985XX, 1, [MIC 985xx support])
596fi
597
41b7bd01
MH
598AM_CONDITIONAL(HW_MOTECH_LPS_30X, test x$HW_MOTECH_LPS_30X = xyes)
599if test "x$HW_MOTECH_LPS_30X" = "xyes"; then
600 AC_DEFINE(HAVE_HW_MOTECH_LPS_30X, 1, [motech-lps-30x support])
601fi
602
bfd48770
MH
603AM_CONDITIONAL(HW_NORMA_DMM, test x$HW_NORMA_DMM = xyes)
604if test "x$HW_NORMA_DMM" = "xyes"; then
d0a92abd 605 AC_DEFINE(HAVE_HW_NORMA_DMM, 1, [Norma DMM support])
bfd48770
MH
606fi
607
d4b38748
BV
608AM_CONDITIONAL(HW_OPENBENCH_LOGIC_SNIFFER, test x$HW_OPENBENCH_LOGIC_SNIFFER = xyes)
609if test "x$HW_OPENBENCH_LOGIC_SNIFFER" = "xyes"; then
610 AC_DEFINE(HAVE_HW_OPENBENCH_LOGIC_SNIFFER, 1, [OpenBench Logic Sniffer (OLS) support])
ae4c3d04
UH
611fi
612
4bd80e12 613AM_CONDITIONAL(HW_PIPISTRELLO_OLS, test x$HW_PIPISTRELLO_OLS = xyes)
614if test "x$HW_PIPISTRELLO_OLS" = "xyes"; then
615 AC_DEFINE(HAVE_HW_PIPISTRELLO_OLS, 1, [Pipistrello OLS support])
616fi
617
3086efdd
ML
618AM_CONDITIONAL(HW_RIGOL_DS, test x$HW_RIGOL_DS = xyes)
619if test "x$HW_RIGOL_DS" = "xyes"; then
620 AC_DEFINE(HAVE_HW_RIGOL_DS, 1, [Rigol DS support])
ae4c3d04
UH
621fi
622
5724a20a
UH
623AM_CONDITIONAL(HW_SALEAE_LOGIC16, test x$HW_SALEAE_LOGIC16 = xyes)
624if test "x$HW_SALEAE_LOGIC16" = "xyes"; then
625 AC_DEFINE(HAVE_HW_SALEAE_LOGIC16, 1, [Saleae Logic16 support])
626fi
627
ae4c3d04
UH
628AM_CONDITIONAL(HW_SERIAL_DMM, test x$HW_SERIAL_DMM = xyes)
629if test "x$HW_SERIAL_DMM" = "xyes"; then
630 AC_DEFINE(HAVE_HW_SERIAL_DMM, 1, [Serial DMM support])
631fi
632
87283d98
UH
633AM_CONDITIONAL(HW_SYSCLK_LWLA, test x$HW_SYSCLK_LWLA = xyes)
634if test "x$HW_SYSCLK_LWLA" = "xyes"; then
635 AC_DEFINE(HAVE_HW_SYSCLK_LWLA, 1, [Sysclk LWLA support])
636fi
637
122d33d4
UH
638AM_CONDITIONAL(HW_TELEINFO, test x$HW_TELEINFO = xyes)
639if test "x$HW_TELEINFO" = "xyes"; then
640 AC_DEFINE(HAVE_HW_TELEINFO, 1, [Teleinfo support])
641fi
642
0acdd793
BV
643AM_CONDITIONAL(HW_TESTO, test x$HW_TESTO = xyes)
644if test "x$HW_TESTO" = "xyes"; then
645 AC_DEFINE(HAVE_HW_TESTO, 1, [Testo support])
646fi
647
ae4c3d04
UH
648AM_CONDITIONAL(HW_TONDAJ_SL_814, test x$HW_TONDAJ_SL_814 = xyes)
649if test "x$HW_TONDAJ_SL_814" = "xyes"; then
650 AC_DEFINE(HAVE_HW_TONDAJ_SL_814, 1, [Tondaj SL-814 support])
651fi
652
653AM_CONDITIONAL(HW_UNI_T_DMM, test x$HW_UNI_T_DMM = xyes)
654if test "x$HW_UNI_T_DMM" = "xyes"; then
655 AC_DEFINE(HAVE_HW_UNI_T_DMM, 1, [UNI-T DMM support])
656fi
657
3877dde4
BV
658AM_CONDITIONAL(HW_UNI_T_UT32X, test x$HW_UNI_T_UT32X = xyes)
659if test "x$HW_UNI_T_UT32X" = "xyes"; then
660 AC_DEFINE(HAVE_HW_UNI_T_UT32X, 1, [UNI-T UT32x support])
661fi
662
ae4c3d04
UH
663AM_CONDITIONAL(HW_VICTOR_DMM, test x$HW_VICTOR_DMM = xyes)
664if test "x$HW_VICTOR_DMM" = "xyes"; then
e4fad80b 665 AC_DEFINE(HAVE_HW_VICTOR_DMM, 1, [Victor DMM support])
ae4c3d04
UH
666fi
667
10763937
SA
668AM_CONDITIONAL(HW_YOKOGAWA_DLM, test x$HW_YOKOGAWA_DLM = xyes)
669if test "x$HW_YOKOGAWA_DLM" = "xyes"; then
670 AC_DEFINE(HAVE_HW_YOKOGAWA_DLM, 1, [Yokogawa DL/DLM support])
671fi
672
9e165e74
UH
673AM_CONDITIONAL(HW_ZEROPLUS_LOGIC_CUBE, test x$HW_ZEROPLUS_LOGIC_CUBE = xyes)
674if test "x$HW_ZEROPLUS_LOGIC_CUBE" = "xyes"; then
675 AC_DEFINE(HAVE_HW_ZEROPLUS_LOGIC_CUBE, 1, [ZEROPLUS Logic Cube support])
ae4c3d04
UH
676fi
677
c23c8659
ML
678AM_CONDITIONAL(BINDINGS_CXX, test x$BINDINGS_CXX = xyes)
679
f7740954
ML
680AM_CONDITIONAL(BINDINGS_PYTHON, test x$BINDINGS_PYTHON = xyes)
681
9fcf4d0b
ML
682AM_CONDITIONAL(BINDINGS_JAVA, test x$BINDINGS_JAVA = xyes)
683
826938d8 684# Checks for header files.
375340a7
UH
685# These are already implicitly checked: inttypes.h stdint.h stdlib.h string.h
686# unistd.h memory.h strings.h dlfcn.h sys/types.h sys/stat.h.
826938d8
UH
687
688# Checks for typedefs, structures, and compiler characteristics.
7b5daad4 689AC_C_BIGENDIAN
826938d8 690
fb6f1978 691AC_SUBST(FIRMWARE_DIR, "$datadir/sigrok-firmware")
826938d8
UH
692AC_SUBST(MAKEFLAGS, '--no-print-directory')
693AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
694
6dddd902
UH
695SR_PACKAGE_VERSION_MAJOR=sr_package_version_major
696SR_PACKAGE_VERSION_MINOR=sr_package_version_minor
697SR_PACKAGE_VERSION_MICRO=sr_package_version_micro
698SR_PACKAGE_VERSION=sr_package_version
3af71f0d 699
6dddd902
UH
700AC_SUBST(SR_PACKAGE_VERSION_MAJOR)
701AC_SUBST(SR_PACKAGE_VERSION_MINOR)
702AC_SUBST(SR_PACKAGE_VERSION_MICRO)
703AC_SUBST(SR_PACKAGE_VERSION)
3af71f0d 704
c23c8659
ML
705AC_CONFIG_FILES([Makefile include/libsigrok/version.h libsigrok.pc
706 bindings/cxx/libsigrokxx.pc])
826938d8
UH
707
708AC_OUTPUT
709
710echo
45aed072 711echo "libsigrok configuration summary:"
826938d8 712echo
6dddd902
UH
713echo " - Package version (major.minor.micro): $SR_PACKAGE_VERSION"
714echo " - Library version (current:revision:age): $SR_LIB_VERSION"
45aed072 715echo " - Prefix: $prefix"
6bad8487
UH
716echo " - Building on: $build"
717echo " - Building for: $host"
45aed072
UH
718echo
719echo "Detected libraries:"
720echo
721
722# Note: This only works for libs with pkg-config integration.
d6e63a2c
BV
723for lib in "glib-2.0 >= 2.32.0" "libzip >= 0.10" "libserialport >= 0.2.0" \
724 "librevisa >= 0.0.20130812" "libusb-1.0 >= 1.0.16" "libftdi >= 0.16" \
725 "libftdi1 >= 1.0" "glibmm-2.4 >= 2.32.0" "pygobject-3.0 >= 3.0.0" \
726 "check >= 0.9.4" "libgpib"
727do
958326f8
UH
728 optional="OPTIONAL"
729 if test "x$lib" = "xglib-2.0 >= 2.32.0"; then optional="REQUIRED"; fi
730 if test "x$lib" = "xlibzip >= 0.10"; then optional="REQUIRED"; fi
45aed072
UH
731 if `$PKG_CONFIG --exists $lib`; then
732 ver=`$PKG_CONFIG --modversion $lib`
733 answer="yes ($ver)"
734 else
735 answer="no"
736 fi
958326f8 737 echo " - ($optional) $lib: $answer"
45aed072
UH
738done
739
43cd4637 740eval echo -e "@Enabled hardware drivers:@@${driver_summary}" | tr @ \\n
826938d8 741
1029d384
BV
742# Prepare final bindings report messages
743final_cxx=""
744final_python=""
745final_java=""
746if test "$enable_bindings" = "no"; then
747 final_cxx=" (disabled)"
748 final_python=" (disabled)"
749 final_java=" (disabled)"
750else
751 if test "$enable_cxx" = "no"; then
752 final_cxx=" (disabled)"
753 elif test "$BINDINGS_CXX" = "no"; then
754 final_cxx=" ($cxx_msg)"
755 fi
756 if test "$enable_python" = "no"; then
757 final_python=" (disabled)"
758 elif test "$BINDINGS_PYTHON" = "no"; then
759 final_python=" ($python_msg)"
760 fi
761 if test "$enable_java" = "no"; then
762 final_java=" (disabled)"
763 elif test "$BINDINGS_JAVA" = "no"; then
764 final_java=" ($java_msg)"
765 fi
766fi
767
43cd4637 768echo -e "Enabled language bindings:\n"
1029d384
BV
769echo " - C++............................. $BINDINGS_CXX$final_cxx"
770echo " - Python.......................... $BINDINGS_PYTHON$final_python"
771echo " - Java............................ $BINDINGS_JAVA$final_java"
c23c8659 772echo