]> sigrok.org Git - libsigrok.git/blob - configure.ac
Build: Simplify the hardware driver selection
[libsigrok.git] / configure.ac
1 ##
2 ## This file is part of the libsigrok project.
3 ##
4 ## Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
5 ## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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
21 # We require at least autoconf 2.63 (AC_INIT format changed there).
22 AC_PREREQ([2.63])
23
24 # libsigrok package version number (NOT the same as shared lib version!).
25 m4_define([sr_package_version_major], [0])
26 m4_define([sr_package_version_minor], [4])
27 m4_define([sr_package_version_micro], [0])
28
29 AC_INIT([libsigrok], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro],
30         [sigrok-devel@lists.sourceforge.net],
31         [libsigrok], [http://www.sigrok.org])
32 AC_CONFIG_HEADERS([config.h include/libsigrok/version.h])
33 AC_CONFIG_MACRO_DIR([autostuff])
34 AC_CONFIG_AUX_DIR([autostuff])
35
36 # We require at least automake 1.11 (needed for 'silent rules').
37 AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define nostdinc subdir-objects check-news color-tests])
38 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
39 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
40
41 AH_TOP([#ifndef SR_CONFIG_H
42 #define SR_CONFIG_H    /* To stop multiple inclusions. */])
43 AH_BOTTOM([#endif /* SR_CONFIG_H */])
44
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.
47 COMMON_FLAGS="$CFLAGS -Wall -Wextra -fvisibility=hidden"
48 CFLAGS="$COMMON_FLAGS -std=c11 -D_POSIX_C_SOURCE=200112L -Wmissing-prototypes"
49 CXXFLAGS="-std=c++11 $COMMON_FLAGS"
50
51 # Checks for programs.
52 AC_PROG_CC
53 AC_PROG_CPP
54 AC_PROG_CXX
55 AC_PROG_INSTALL
56 AC_PROG_LN_S
57
58 # Required for per-target flags or subdir-objects with C sources.
59 AM_PROG_CC_C_O
60
61 # Initialize libtool.
62 LT_INIT
63
64 # Initialize pkg-config.
65 # We require at least 0.22, as "Requires.private" behaviour changed there.
66 PKG_PROG_PKG_CONFIG([0.22])
67
68 CONFIG_STATUS_DEPENDENCIES=
69 SR_PACKAGE_VERSION="AC_PACKAGE_VERSION"
70
71 # Check if we can get revision information from git.
72 sr_head=`git -C "$srcdir" rev-parse --verify --short HEAD 2>&AS_MESSAGE_LOG_FD`
73
74 AS_IF([test "$?" -eq 0 && test -n "$sr_head"], [
75         CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/.git/HEAD'
76         sr_head_name=`git -C "$srcdir" rev-parse --symbolic-full-name HEAD 2>&AS_MESSAGE_LOG_FD`
77         AS_IF([test "$?" -eq 0 && test -f "$srcdir/.git/$sr_head_name"],
78                 [CONFIG_STATUS_DEPENDENCIES="$CONFIG_STATUS_DEPENDENCIES \$(top_srcdir)/.git/$sr_head_name"])
79
80         # Append the revision hash unless we are exactly on a tagged release.
81         git -C "$srcdir" describe --match 'AC_PACKAGE_NAME-AC_PACKAGE_VERSION' \
82                 --exact-match >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD \
83         || SR_PACKAGE_VERSION="$SR_PACKAGE_VERSION-git-$sr_head"
84 ])
85 AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
86 AC_SUBST([SR_PACKAGE_VERSION])
87
88 AC_DEFINE([SR_PACKAGE_VERSION_MAJOR], [sr_package_version_major], [.])
89 AC_DEFINE([SR_PACKAGE_VERSION_MINOR], [sr_package_version_minor], [.])
90 AC_DEFINE([SR_PACKAGE_VERSION_MICRO], [sr_package_version_micro], [.])
91 AC_DEFINE_UNQUOTED([SR_PACKAGE_VERSION_STRING], ["$SR_PACKAGE_VERSION"], [.])
92
93 # Library version for libsigrok (NOT the same as the package version).
94 # Carefully read the libtool docs before updating these numbers!
95 # The algorithm for determining which number to change (and how) is nontrivial!
96 # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
97 SR_LIB_VERSION_CURRENT=2
98 SR_LIB_VERSION_REVISION=0
99 SR_LIB_VERSION_AGE=0
100
101 AC_SUBST([SR_LIB_VERSION], ["$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"])
102 AC_SUBST([SR_LIB_LDFLAGS], ["-version-info $SR_LIB_VERSION"])
103
104 AC_DEFINE_UNQUOTED([SR_LIB_VERSION_CURRENT], [$SR_LIB_VERSION_CURRENT], [.])
105 AC_DEFINE_UNQUOTED([SR_LIB_VERSION_REVISION], [$SR_LIB_VERSION_REVISION], [.])
106 AC_DEFINE_UNQUOTED([SR_LIB_VERSION_AGE], [$SR_LIB_VERSION_AGE], [.])
107 AC_DEFINE_UNQUOTED([SR_LIB_VERSION_STRING], ["$SR_LIB_VERSION"], [.])
108
109 AC_ARG_ENABLE([all-drivers],
110         [AS_HELP_STRING([--enable-all-drivers],
111                         [enable all drivers by default [[default=yes]]])],
112         [HW_ENABLED_DEFAULT="$enableval"],
113         [HW_ENABLED_DEFAULT="yes"])
114
115 ## _SR_DRIVER(Device name, driver-name, enable, var-name)
116 m4_define([_SR_DRIVER], [
117         AC_ARG_ENABLE([$4],
118                 [AS_HELP_STRING([--enable-$2], [enable $1 support])],
119                 [$4=$enableval], [$4=$3])
120         m4_append([SR_DRIVER_SUMMARY],
121                 [ - m4_translit(m4_format([%-32s], [$2]), [ ], [.]) [$]$4],
122                 m4_newline)
123         AC_CONFIG_COMMANDS_PRE([dnl
124                 AM_CONDITIONAL([$4], [test "x[$]$4" = xyes])
125                 AM_COND_IF([$4], [AC_DEFINE([HAVE_$4], [1], [Whether to support $1 device.])])
126         ])
127 ])
128 ## SR_DRIVER(Device name, driver-name, [no])
129 m4_define([SR_DRIVER],
130         [_SR_DRIVER([$1], [$2],
131                 m4_default_quoted([$3], [$HW_ENABLED_DEFAULT]),
132                 m4_expand([AS_TR_CPP([HW_$2])]))])
133
134 SR_DRIVER([Agilent DMM], [agilent-dmm])
135 SR_DRIVER([Appa 55II], [appa-55ii])
136 SR_DRIVER([ASIX SIGMA/SIGMA2], [asix-sigma])
137 SR_DRIVER([Atten PPS3xxx], [atten-pps3xxx])
138 SR_DRIVER([BayLibre ACME], [baylibre-acme])
139 SR_DRIVER([BeagleLogic], [beaglelogic])
140 SR_DRIVER([Brymen BM86x], [brymen-bm86x])
141 SR_DRIVER([Brymen DMM], [brymen-dmm])
142 SR_DRIVER([CEM DT-885x], [cem-dt-885x])
143 SR_DRIVER([Center 3xx], [center-3xx])
144 SR_DRIVER([ChronoVu LA], [chronovu-la])
145 SR_DRIVER([Colead SLM], [colead-slm])
146 SR_DRIVER([Conrad DIGI 35 CPU], [conrad-digi-35-cpu])
147 SR_DRIVER([DER EE DE-5000], [deree-de5000])
148 SR_DRIVER([demo], [demo])
149 SR_DRIVER([Fluke DMM], [fluke-dmm])
150 SR_DRIVER([fx2lafw], [fx2lafw])
151 SR_DRIVER([GMC MH 1x/2x], [gmc-mh-1x-2x])
152 SR_DRIVER([Hameg HMO], [hameg-hmo])
153 SR_DRIVER([Hantek DSO], [hantek-dso])
154 SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2])
155 SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus])
156 SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b])
157 SR_DRIVER([Lascar EL-USB], [lascar-el-usb])
158 SR_DRIVER([Manson HCS-3xxx], [manson-hcs-3xxx])
159 SR_DRIVER([maynuo-m97], [maynuo-m97])
160 SR_DRIVER([MIC 985xx], [mic-985xx])
161 SR_DRIVER([Motech LPS 30x], [motech-lps-30x])
162 SR_DRIVER([Norma DMM], [norma-dmm])
163 SR_DRIVER([OpenBench Logic Sniffer], [openbench-logic-sniffer])
164 SR_DRIVER([Pipistrello-OLS], [pipistrello-ols])
165 SR_DRIVER([Rigol DS], [rigol-ds])
166 SR_DRIVER([Saleae Logic16], [saleae-logic16])
167 SR_DRIVER([SCPI PPS], [scpi-pps])
168 SR_DRIVER([serial DMM], [serial-dmm])
169 SR_DRIVER([Sysclk LWLA], [sysclk-lwla])
170 SR_DRIVER([Teleinfo], [teleinfo])
171 SR_DRIVER([Testo], [testo])
172 SR_DRIVER([Tondaj SL-814], [tondaj-sl-814])
173 SR_DRIVER([UNI-T DMM], [uni-t-dmm])
174 SR_DRIVER([UNI-T UT32x], [uni-t-ut32x])
175 SR_DRIVER([Victor DMM], [victor-dmm])
176 SR_DRIVER([Yokogawa DL/DLM], [yokogawa-dlm])
177 SR_DRIVER([ZEROPLUS Logic Cube], [zeroplus-logic-cube])
178
179 AC_ARG_ENABLE(libserialport,
180         AC_HELP_STRING([--disable-libserialport],
181         [disable libserialport support [default=detect]]))
182
183 AC_ARG_ENABLE(libftdi,
184         AC_HELP_STRING([--disable-libftdi],
185         [disable libftdi support [default=detect]]))
186
187 AC_ARG_ENABLE(libusb,
188         AC_HELP_STRING([--disable-libusb],
189         [disable libusb support [default=detect]]))
190
191 # Language binding '--enable' options:
192
193 AC_ARG_ENABLE(bindings,
194         AC_HELP_STRING([--enable-bindings],
195         [build language bindings [default=yes]]),
196         [BINDINGS_ALL="$enableval"], [BINDINGS_ALL="yes"])
197
198 AC_ARG_ENABLE(cxx,
199         AC_HELP_STRING([--enable-cxx],
200         [build C++ bindings [default=yes]]),
201         [BINDINGS_CXX="$enableval"], [BINDINGS_CXX=$BINDINGS_ALL])
202
203 AC_ARG_ENABLE(python,
204         AC_HELP_STRING([--enable-python],
205         [build Python bindings [default=yes]]),
206         [BINDINGS_PYTHON="$enableval"], [BINDINGS_PYTHON=$BINDINGS_ALL])
207
208 AC_ARG_ENABLE(java,
209         AC_HELP_STRING([--enable-java],
210         [build Java bindings [default=yes]]),
211         [BINDINGS_JAVA="$enableval"], [BINDINGS_JAVA=$BINDINGS_ALL])
212
213 AC_ARG_WITH(jni-include-path,
214         AC_HELP_STRING([--with-jni-include-path=path],
215         [specify include path for JNI [default=autodetect]]),
216         [JNI_INCLUDE_DIRS="$withval"], [JNI_INCLUDE_DIRS=auto])
217
218 # Check if the C++ compiler supports the C++11 standard.
219
220 m4_ifdef([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX_11(,[optional])],
221         [AC_MSG_NOTICE([Missing macro m4_toupper(aX_CXX_COMPILE_STDCXX_11), no C++11 check])])
222
223 if test "x$HAVE_CXX11" != "x1"; then
224         BINDINGS_CXX="no"; cxx_msg="C++11 compiler required"
225 fi
226
227 # The C++ bindings use Doxygen to parse libsigrok symbols.
228 AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes])
229 if test "x$HAVE_DOXYGEN" != "xyes"; then
230         BINDINGS_CXX="no"; cxx_msg="Doxygen required"
231 fi
232
233 # Python is needed for the C++ bindings.
234 AM_PATH_PYTHON([2.7], [HAVE_PYTHON="yes"],
235         [HAVE_PYTHON="no"; BINDINGS_CXX="no"; cxx_msg="Python required"])
236
237 # The Python bindings need Python development files.
238 PKG_CHECK_MODULES([python], [python >= 2.7],
239         [CXXFLAGS="$CXXFLAGS $python_CFLAGS";
240         CXXLIBS="$CXXLIBS $python_LIBS"],
241 [PKG_CHECK_MODULES([python27], [python-2.7 >= 2.7],
242         [CXXFLAGS="$CXXFLAGS $python27_CFLAGS";
243         CXXLIBS="$CXXLIBS $python27_LIBS"],
244                 [BINDINGS_PYTHON="no"; python_msg="Python headers required"])])
245
246 # The Python bindings need the setuptools Python module.
247 m4_ifdef([AX_PYTHON_MODULE], [AX_PYTHON_MODULE([setuptools])],
248         # We'll let it go through even if the macro wasn't found, the Python
249         # module may still be there.
250         [HAVE_PYTHON_SETUPTOOLS="yes";
251                 AC_MSG_NOTICE([Missing macro m4_toupper(aX_PYTHON_MODULE), no setuptools check])]
252 )
253 if test "x$HAVE_PYMOD_SETUPTOOLS" != "xyes"; then
254         BINDINGS_PYTHON="no"; python_msg="Python setuptools module required"
255 fi
256
257 # The Python and Java bindings use SWIG to generate code.
258 AC_CHECK_PROG([HAVE_SWIG], [swig], [yes])
259 if test "x$HAVE_SWIG" != "xyes"; then
260         BINDINGS_PYTHON="no"; python_msg="SWIG required"
261         BINDINGS_JAVA="no"; java_msg="SWIG required"
262 fi
263
264 # Checks for libraries.
265
266 case "$host" in
267 *mingw*)
268         # We need to link against the Winsock2 library for SCPI over TCP.
269         LIBS="$LIBS -lws2_32";;
270 esac
271
272 # This variable collects the pkg-config names of all detected libs.
273 # It is then used to construct the "Requires.private:" field in the
274 # libsigrok.pc file.
275 SR_PKGLIBS=""
276
277 # libm (the standard math library) is always needed.
278 AC_SEARCH_LIBS([pow], [m])
279
280 # RPC is only needed for VXI support.
281 AC_MSG_CHECKING([for RPC support])
282 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <rpc/rpc.h>],
283                         [CLIENT *rpc_test(void)],
284                         [{ return clnt_create("", 0, 0, ""); }])],
285                 [AC_MSG_RESULT([yes]); have_rpc=1],
286                 [AC_MSG_RESULT([no]);  have_rpc=0])
287 # Define HAVE_RPC in config.h if we found RPC support.
288 AC_DEFINE_UNQUOTED(HAVE_RPC, [$have_rpc], [Specifies whether we have RPC support.])
289 # VXI support is only compiled if RPC support was found.
290 AM_CONDITIONAL(NEED_RPC, test "x$have_rpc" != "x0")
291
292 AC_DEFINE_UNQUOTED(HOST, ["$host"], [.])
293
294 # libglib-2.0 is always needed. Abort if it's not found.
295 # Note: glib-2.0 is part of the libsigrok API (hard pkg-config requirement).
296 # We require at least 2.32.0 due to e.g. g_variant_new_fixed_array().
297 AM_PATH_GLIB_2_0([2.32.0],
298         [LIB_CFLAGS="$LIB_CFLAGS $GLIB_CFLAGS"; LIBS="$LIBS $GLIB_LIBS"])
299
300 # libzip is always needed. Abort if it's not found.
301 PKG_CHECK_MODULES([libzip], [libzip >= 0.10],
302         [LIB_CFLAGS="$LIB_CFLAGS $libzip_CFLAGS"; LIBS="$LIBS $libzip_LIBS";
303         SR_PKGLIBS="$SR_PKGLIBS libzip"])
304 libzip_ver=`$PKG_CONFIG --modversion libzip`
305 AC_DEFINE_UNQUOTED(HAVE_LIBZIP_VER, ["$libzip_ver"], [.])
306
307 # libserialport is only needed for some hardware drivers. Disable the
308 # respective drivers if it is not found.
309 if test "x$enable_libserialport" != "xno"; then
310         PKG_CHECK_MODULES([libserialport], [libserialport >= 0.1.1],
311                 [have_libserialport="yes"; LIB_CFLAGS="$LIB_CFLAGS $libserialport_CFLAGS";
312                 LIBS="$LIBS $libserialport_LIBS";
313                 SR_PKGLIBS="$SR_PKGLIBS libserialport"],
314                 [have_libserialport="no"])
315         if test "x$enable_libserialport$have_libserialport" = "xyesno"; then
316                 AC_MSG_ERROR([libserialport support requested, but it was not found.])
317         fi
318 else
319         have_libserialport="no"
320 fi
321 if test "x$have_libserialport" = "xno"; then
322         HW_AGILENT_DMM="no"; HW_APPA_55II="no";
323         HW_ATTEN_PPS3XXX="no"; HW_BRYMEN_DMM="no"; HW_CEM_DT_885X="no";
324         HW_CENTER_3XX="no"; HW_COLEAD_SLM="no"; HW_CONRAD_DIGI_35_CPU="no";
325         HW_DEREE_DE5000="no"; HW_FLUKE_DMM="no"; HW_GMC_MH_1X_2X="no";
326         HW_HAMEG_HMO="no"; HW_MANSON_HCS_3XXX="no"; HW_MIC_985XX="no";
327         HW_MOTECH_LPS_30X="no"; HW_NORMA_DMM="no";
328         HW_OPENBENCH_LOGIC_SNIFFER="no"; HW_SERIAL_DMM="no";
329         HW_TELEINFO="no"; HW_TONDAJ_SL_814="no";
330 else
331         # Define HAVE_LIBSERIALPORT in config.h if we found libserialport.
332         AC_DEFINE_UNQUOTED(HAVE_LIBSERIALPORT, [1],
333                 [Specifies whether we have libserialport.])
334 fi
335
336 # Serial port helper code is only compiled in if libserialport was found.
337 AM_CONDITIONAL(NEED_SERIAL, test "x$have_libserialport" != xno)
338
339 # The VISA SCPI backend is only compiled in if librevisa was found.
340 PKG_CHECK_MODULES([librevisa], [librevisa >= 0.0.20130412],
341         [have_librevisa="yes"; LIB_CFLAGS="$LIB_CFLAGS $librevisa_CFLAGS";
342         LIBS="$LIBS $librevisa_LIBS";
343         SR_PKGLIBS="$SR_PKGLIBS librevisa"],
344         [have_librevisa="no"])
345 AM_CONDITIONAL(NEED_VISA, test "x$have_librevisa" != xno)
346 if test "x$have_librevisa" != "xno"; then
347         # Define HAVE_LIBREVISA in config.h if we found librevisa.
348         AC_DEFINE_UNQUOTED(HAVE_LIBREVISA, [1],
349                 [Specifies whether we have librevisa.])
350         librevisa_ver=`$PKG_CONFIG --modversion librevisa`
351         AC_DEFINE_UNQUOTED(HAVE_LIBREVISA_VER, ["$librevisa_ver"], [.])
352 fi
353
354 # The GPIB SCPI backend is only compiled in if libgpib is found.
355 PKG_CHECK_MODULES([libgpib], [libgpib],
356         [have_libgpib="yes"; LIB_CFLAGS="$LIB_CFLAGS $libgpib_CFLAGS";
357         LIBS="$LIBS $libgpib_LIBS";
358         SR_PKGLIBS="$SR_PKGLIBS libgpib"],
359         [have_libgpib="no"])
360 AM_CONDITIONAL(NEED_GPIB, test "x$have_libgpib" != xno)
361 if test "x$have_libgpib" != "xno"; then
362         # Define HAVE_LIBGPIB in config.h if we found libgpib.
363         AC_DEFINE_UNQUOTED(HAVE_LIBGPIB, [1],
364                 [Specifies whether we have libgpib.])
365         libgpib_ver=`$PKG_CONFIG --modversion libgpib`
366         AC_DEFINE_UNQUOTED(HAVE_LIBGPIB_VER, ["$libgpib_ver"], [.])
367 fi
368
369 # libusb-1.0 is only needed for some hardware drivers. Disable the respective
370 # drivers if it is not found.
371 if test "x$enable_libusb" != "xno"; then
372         case "$host" in
373         *freebsd*)
374                 # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
375                 # This means libusb-1.0 is always available, no need to check for it,
376                 # and no need to (potentially) disable any drivers if it's not found.
377                 have_libusb1_0="yes"
378                 ;;
379         *)
380                 PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.16],
381                         [have_libusb1_0="yes"; LIB_CFLAGS="$LIB_CFLAGS $libusb_CFLAGS";
382                         LIBS="$LIBS $libusb_LIBS";
383                         SR_PKGLIBS="$SR_PKGLIBS libusb-1.0"],
384                         [have_libusb1_0="no"])
385                 if test "x$enable_libusb$have_libusb1_0" = "xyesno"; then
386                         AC_MSG_ERROR([libusb support requested, but it was not found.])
387                 fi
388                 ;;
389         esac
390 else
391         have_libusb1_0="no"
392 fi
393 if test "x$have_libusb1_0" = "xno"; then
394         HW_BRYMEN_BM86X="no"; HW_FX2LAFW="no";
395         HW_HANTEK_DSO="no"; HW_IKALOGIC_SCANALOGIC2="no";
396         HW_KECHENG_KC_330B="no"; HW_LASCAR_EL_USB="no";
397         HW_SYSCLK_LWLA="no"; HW_TESTO="no"; HW_UNI_T_DMM="no";
398         HW_UNI_T_UT32X="no"; HW_VICTOR_DMM="no";
399         HW_ZEROPLUS_LOGIC_CUBE="no"; HW_SALEAE_LOGIC16="no";
400 else
401         # Define HAVE_LIBUSB_1_0 in config.h if we found libusb-1.0.
402         AC_DEFINE_UNQUOTED(HAVE_LIBUSB_1_0, [1],
403                 [Specifies whether we have libusb-1.0.])
404 fi
405
406 # USB + FX2 firmware helper code is only compiled in if libusb-1.0 was found.
407 AM_CONDITIONAL(NEED_USB, test "x$have_libusb1_0" != xno)
408
409 # libftdi is only needed for some hardware drivers. Disable them if not found.
410 if test "x$enable_libftdi" != "xno"; then
411         PKG_CHECK_MODULES([libftdi], [libftdi >= 0.16],
412                 [have_libftdi="yes"; LIB_CFLAGS="$LIB_CFLAGS $libftdi_CFLAGS";
413                 LIBS="$LIBS $libftdi_LIBS"; SR_PKGLIBS="$SR_PKGLIBS libftdi";
414                 libftdi_ver=`$PKG_CONFIG --modversion libftdi`],
415                 [PKG_CHECK_MODULES([libftdi1], [libftdi1 >= 1.0],
416                         [LIB_CFLAGS="$LIB_CFLAGS $libftdi1_CFLAGS";
417                         LIBS="$LIBS $libftdi1_LIBS";
418                         SR_PKGLIBS="$SR_PKGLIBS libftdi1";
419                         libftdi_ver=`$PKG_CONFIG --modversion libftdi1`],
420                         [have_libftdi="no"])])
421         if test "x$enable_libftdi$have_libftdi" = "xyesno"; then
422                 AC_MSG_ERROR([libftdi support requested, but it was not found.])
423         fi
424 else
425         have_libftdi="no"
426 fi
427 if test "x$have_libftdi" = "xno"; then
428         HW_ASIX_SIGMA="no"; HW_CHRONOVU_LA="no"; HW_IKALOGIC_SCANAPLUS="no";
429         HW_PIPISTRELLO_OLS="no";
430 else
431         # Define HAVE_LIBFTDI in config.h if we found libftdi.
432         AC_DEFINE_UNQUOTED(HAVE_LIBFTDI, [1],
433                 [Specifies whether we have libftdi.])
434         AC_DEFINE_UNQUOTED(HAVE_LIBFTDI_VER, ["$libftdi_ver"], [.])
435 fi
436
437 # glibmm-2.4 is needed for the C++ bindings.
438 PKG_CHECK_MODULES([glibmm], [glibmm-2.4 >= 2.32.0],
439         [CXXFLAGS="$CXXFLAGS $glibmm_CFLAGS";
440         CXXLIBS="$CXXLIBS $glibmm_LIBS"],
441         [BINDINGS_CXX="no"; cxx_msg="glibmm required"])
442
443 # C++ bindings want stoi and stod.
444 if test "x$BINDINGS_CXX" = "xyes"; then
445         AC_LANG_PUSH([C++])
446         AC_MSG_CHECKING([for stoi and stod])
447         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string>],
448                 [{ return std::stoi("1") + std::stod("1.0"); }])],
449                 [AC_MSG_RESULT([yes]);
450                 AC_DEFINE_UNQUOTED(HAVE_STOI_STOD, [1],
451                 [Specifies whether we have the stoi and stod functions.])],
452                 [AC_MSG_RESULT([no])])
453         AC_LANG_POP([C++])
454 fi
455
456 # PyGObject is needed for the Python bindings.
457 PKG_CHECK_MODULES([pygobject], [pygobject-3.0 >= 3.0.0],
458         [CXXFLAGS="$CXXFLAGS $pygobject_CFLAGS";
459         CXXLIBS="$CXXLIBS $pygobject_LIBS";
460         PKG_CHECK_MODULES([pygobject_3_7_91], [pygobject-3.0 >= 3.7.91],
461                 [pyg_flags_signed=0], [pyg_flags_signed=1]);
462         AC_DEFINE_UNQUOTED(PYGOBJECT_FLAGS_SIGNED, [$pyg_flags_signed],
463                 [Whether last argument to pyg_flags_get_value() is signed.])],
464         [BINDINGS_PYTHON="no"; python_msg="Python pygobject module required"])
465
466 # The Check unit testing framework is optional. Disable if not found.
467 PKG_CHECK_MODULES([check], [check >= 0.9.4],
468         [have_check="yes"], [have_check="no"])
469 AM_CONDITIONAL(HAVE_CHECK, test x"$have_check" = "xyes")
470
471 # The BeagleLogic driver needs sys/mman.h and sys/ioctl.h. Don't try to
472 # build it if these headers aren't available.
473 AC_CHECK_HEADERS([sys/mman.h sys/ioctl.h], [], [HW_BEAGLELOGIC="no"])
474
475 # The BayLibre ACME driver needs sys/timerfd.h. Don't try to build it if
476 # this header isn't available.
477 AC_CHECK_HEADERS([sys/timerfd.h], [], [HW_BAYLIBRE_ACME="no"])
478
479 # The ACME driver can only be built for Linux.
480 case "$host" in
481         *linux*) ;;
482         *) HW_BAYLIBRE_ACME="no" ;;
483 esac
484
485 AC_SUBST(SR_PKGLIBS)
486
487 CFLAGS="$CFLAGS $LIB_CFLAGS"
488 CXXFLAGS="$CXXFLAGS $LIB_CFLAGS"
489
490 # Find Java compiler and JNI includes for Java bindings.
491 AC_CHECK_PROG([HAVE_JAVAC], [javac], [yes], [no])
492 if test "x$HAVE_JAVAC" = "xyes" && test "x$BINDINGS_JAVA" = "xyes"; then
493         AX_PROG_JAVAC
494         if test "x$JNI_INCLUDE_DIRS" = "xauto"; then
495                 if test "x$cross_compiling" = "xyes"; then
496                         JNI_INCLUDE_DIRS=
497                 else
498                         AX_JNI_INCLUDE_DIR
499                 fi
500         fi
501         for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
502                 CXXFLAGS="$CXXFLAGS -I$JNI_INCLUDE_DIR"
503         done
504         AC_LANG_PUSH([C++])
505         AC_CHECK_HEADERS([jni.h], [], [BINDINGS_JAVA="no"; java_msg="Java JNI headers required"])
506         AC_LANG_POP([C++])
507 else
508         BINDINGS_JAVA="no"; java_msg="Java compiler required"
509 fi
510
511 # Python and Java bindings depend on C++ bindings.
512 if test "x$BINDINGS_CXX" != "xyes"; then
513         BINDINGS_PYTHON="no"; python_msg="C++ bindings required"
514         BINDINGS_JAVA="no"; java_msg="C++ bindings required"
515 fi
516
517 AM_CONDITIONAL(BINDINGS_CXX, test x$BINDINGS_CXX = xyes)
518
519 AM_CONDITIONAL(BINDINGS_PYTHON, test x$BINDINGS_PYTHON = xyes)
520
521 AM_CONDITIONAL(BINDINGS_JAVA, test x$BINDINGS_JAVA = xyes)
522
523 # Checks for header files.
524 # These are already implicitly checked: inttypes.h stdint.h stdlib.h string.h
525 # unistd.h memory.h strings.h dlfcn.h sys/types.h sys/stat.h.
526
527 # Checks for typedefs, structures, and compiler characteristics.
528 AC_C_BIGENDIAN
529
530 AC_SUBST([FIRMWARE_DIR], ['$(datadir)/sigrok-firmware'])
531 AC_SUBST(MAKEFLAGS, '--no-print-directory')
532 AC_SUBST(AM_LIBTOOLFLAGS, '--silent')
533
534 AC_CONFIG_FILES([Makefile libsigrok.pc bindings/cxx/libsigrokcxx.pc])
535
536 AC_OUTPUT
537
538 echo
539 echo "libsigrok configuration summary:"
540 echo
541 echo "  - Package version (major.minor.micro):    $SR_PACKAGE_VERSION"
542 echo "  - Library version (current:revision:age): $SR_LIB_VERSION"
543 echo "  - Prefix: $prefix"
544 echo "  - Building on: $build"
545 echo "  - Building for: $host"
546 echo
547 echo "Detected libraries:"
548 echo
549
550 # Note: This only works for libs with pkg-config integration.
551 for lib in "glib-2.0 >= 2.32.0" "libzip >= 0.10" "libserialport >= 0.1.1" \
552         "librevisa >= 0.0.20130412" "libusb-1.0 >= 1.0.16" "libftdi >= 0.16" \
553         "libftdi1 >= 1.0" "libgpib" "glibmm-2.4 >= 2.32.0" \
554         "pygobject-3.0 >= 3.0.0" "check >= 0.9.4"
555 do
556         optional="OPTIONAL"
557         if test "x$lib" = "xglib-2.0 >= 2.32.0"; then optional="REQUIRED"; fi
558         if test "x$lib" = "xlibzip >= 0.10"; then optional="REQUIRED"; fi
559         if `$PKG_CONFIG --exists $lib`; then
560                 ver=`$PKG_CONFIG --modversion $lib`
561                 answer="yes ($ver)"
562         else
563                 answer="no"
564         fi
565         echo "  - ($optional) $lib: $answer"
566 done
567
568 cat <<_EOF
569
570 Enabled hardware drivers:
571 SR_DRIVER_SUMMARY
572
573 _EOF
574
575 # Prepare final bindings report messages.
576 final_cxx=""
577 final_python=""
578 final_java=""
579 if test "$enable_bindings" = "no"; then
580         final_cxx=" (disabled)"
581         final_python=" (disabled)"
582         final_java=" (disabled)"
583 else
584         if test "$enable_cxx" = "no"; then
585                 final_cxx=" (disabled)"
586         elif test "$BINDINGS_CXX" = "no"; then
587                 final_cxx=" ($cxx_msg)"
588         fi
589         if test "$enable_python" = "no"; then
590                 final_python=" (disabled)"
591         elif test "$BINDINGS_PYTHON" = "no"; then
592                 final_python=" ($python_msg)"
593         fi
594         if test "$enable_java" = "no"; then
595                 final_java=" (disabled)"
596         elif test "$BINDINGS_JAVA" = "no"; then
597                 final_java=" ($java_msg)"
598         fi
599 fi
600
601 echo "Enabled SCPI backends:"
602 echo " - TCP............................. yes"
603 if test "x$have_rpc" = "x0"; then
604 echo " - RPC............................. no"
605 else
606 echo " - RPC............................. yes"
607 fi
608 echo " - serial.......................... $have_libserialport"
609 echo " - VISA............................ $have_librevisa"
610 echo " - GPIB............................ $have_libgpib"
611 echo " - USBTMC.......................... $have_libusb1_0"
612 echo
613
614 echo "Enabled language bindings:"
615 echo " - C++............................. $BINDINGS_CXX$final_cxx"
616 echo " - Python.......................... $BINDINGS_PYTHON$final_python"
617 echo " - Java............................ $BINDINGS_JAVA$final_java"
618 echo