]>
Commit | Line | Data |
---|---|---|
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). |
22 | AC_PREREQ([2.63]) | |
826938d8 | 23 | |
3af71f0d | 24 | # libsigrok package version number (NOT the same as shared lib version!). |
6dddd902 | 25 | m4_define([sr_package_version_major], [0]) |
e6b8f35f | 26 | m4_define([sr_package_version_minor], [4]) |
4133caab | 27 | m4_define([sr_package_version_micro], [0]) |
826938d8 | 28 | |
7f289d14 DE |
29 | AC_INIT([libsigrok], [sr_package_version_major.sr_package_version_minor.sr_package_version_micro], |
30 | [sigrok-devel@lists.sourceforge.net], | |
db8ae7b9 | 31 | [libsigrok], [http://www.sigrok.org]) |
b2478a23 | 32 | AC_CONFIG_HEADERS([config.h include/libsigrok/version.h]) |
d8521c93 UH |
33 | AC_CONFIG_MACRO_DIR([autostuff]) |
34 | AC_CONFIG_AUX_DIR([autostuff]) | |
826938d8 | 35 | |
ef7228ba | 36 | # We require at least automake 1.11 (needed for 'silent rules'). |
9ac018d0 | 37 | AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define nostdinc subdir-objects check-news color-tests]) |
826938d8 | 38 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
432e5e95 | 39 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) |
826938d8 | 40 | |
6dddd902 UH |
41 | AH_TOP([#ifndef SR_CONFIG_H |
42 | #define SR_CONFIG_H /* To stop multiple inclusions. */]) | |
43 | AH_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. | |
1f61c22f DE |
47 | CFLAGS="$CFLAGS -std=c11" |
48 | CFLAGS="$CFLAGS -Wall -Wextra -Wmissing-prototypes" | |
49 | CFLAGS="$CFLAGS -fvisibility=hidden" | |
50 | CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L" | |
826938d8 UH |
51 | |
52 | # Checks for programs. | |
826938d8 UH |
53 | AC_PROG_CC |
54 | AC_PROG_CPP | |
c23c8659 | 55 | AC_PROG_CXX |
826938d8 UH |
56 | AC_PROG_INSTALL |
57 | AC_PROG_LN_S | |
58 | ||
bb203cde UH |
59 | # Required for per-target flags or subdir-objects with C sources. |
60 | AM_PROG_CC_C_O | |
61 | ||
826938d8 UH |
62 | # Initialize libtool. |
63 | LT_INIT | |
64 | ||
7f289d14 DE |
65 | CONFIG_STATUS_DEPENDENCIES= |
66 | SR_PACKAGE_VERSION="AC_PACKAGE_VERSION" | |
67 | ||
68 | # Check if we can get revision information from git. | |
69 | sr_head=`git -C "$srcdir" rev-parse --verify --short HEAD 2>&AS_MESSAGE_LOG_FD` | |
70 | ||
71 | AS_IF([test "$?" -eq 0 && test -n "$sr_head"], [ | |
7c16e74d DE |
72 | sr_git_deps= |
73 | test ! -f "$srcdir/.git/HEAD" || sr_git_deps=' $(top_srcdir)/.git/HEAD' | |
74 | ||
7f289d14 DE |
75 | sr_head_name=`git -C "$srcdir" rev-parse --symbolic-full-name HEAD 2>&AS_MESSAGE_LOG_FD` |
76 | AS_IF([test "$?" -eq 0 && test -f "$srcdir/.git/$sr_head_name"], | |
7c16e74d DE |
77 | [sr_git_deps="$sr_git_deps \$(top_srcdir)/.git/$sr_head_name"]) |
78 | ||
79 | # Use $(wildcard) so that things do not break if for whatever | |
80 | # reason these files do not exist anymore at make time. | |
81 | test -z "$sr_git_deps" || CONFIG_STATUS_DEPENDENCIES="\$(wildcard$sr_git_deps)" | |
7f289d14 DE |
82 | |
83 | # Append the revision hash unless we are exactly on a tagged release. | |
84 | git -C "$srcdir" describe --match 'AC_PACKAGE_NAME-AC_PACKAGE_VERSION' \ | |
85 | --exact-match >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD \ | |
86 | || SR_PACKAGE_VERSION="$SR_PACKAGE_VERSION-git-$sr_head" | |
87 | ]) | |
88 | AC_SUBST([CONFIG_STATUS_DEPENDENCIES]) | |
89 | AC_SUBST([SR_PACKAGE_VERSION]) | |
b2478a23 DE |
90 | |
91 | AC_DEFINE([SR_PACKAGE_VERSION_MAJOR], [sr_package_version_major], [.]) | |
92 | AC_DEFINE([SR_PACKAGE_VERSION_MINOR], [sr_package_version_minor], [.]) | |
93 | AC_DEFINE([SR_PACKAGE_VERSION_MICRO], [sr_package_version_micro], [.]) | |
94 | AC_DEFINE_UNQUOTED([SR_PACKAGE_VERSION_STRING], ["$SR_PACKAGE_VERSION"], [.]) | |
95 | ||
3af71f0d | 96 | # Library version for libsigrok (NOT the same as the package version). |
826938d8 UH |
97 | # Carefully read the libtool docs before updating these numbers! |
98 | # The algorithm for determining which number to change (and how) is nontrivial! | |
99 | # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info | |
85ca913c UH |
100 | SR_LIB_VERSION_CURRENT=2 |
101 | SR_LIB_VERSION_REVISION=0 | |
6dddd902 | 102 | SR_LIB_VERSION_AGE=0 |
1f61c22f DE |
103 | AC_SUBST([SR_LIB_VERSION], |
104 | ["$SR_LIB_VERSION_CURRENT:$SR_LIB_VERSION_REVISION:$SR_LIB_VERSION_AGE"]) | |
b2478a23 DE |
105 | |
106 | AC_DEFINE_UNQUOTED([SR_LIB_VERSION_CURRENT], [$SR_LIB_VERSION_CURRENT], [.]) | |
107 | AC_DEFINE_UNQUOTED([SR_LIB_VERSION_REVISION], [$SR_LIB_VERSION_REVISION], [.]) | |
108 | AC_DEFINE_UNQUOTED([SR_LIB_VERSION_AGE], [$SR_LIB_VERSION_AGE], [.]) | |
109 | AC_DEFINE_UNQUOTED([SR_LIB_VERSION_STRING], ["$SR_LIB_VERSION"], [.]) | |
826938d8 | 110 | |
1f61c22f DE |
111 | ############################# |
112 | ## Optional dependencies ## | |
113 | ############################# | |
de44e114 | 114 | |
1f61c22f DE |
115 | # Initialize pkg-config. |
116 | # We require at least 0.22, as "Requires.private" behaviour changed there. | |
117 | PKG_PROG_PKG_CONFIG([0.22]) | |
bcacb863 | 118 | |
1f61c22f DE |
119 | # This variable collects the pkg-config module names of all dependencies. |
120 | # These are used to derive the compiler flags and for the "Requires.private" | |
121 | # field in the generated libsigrok.pc file. | |
122 | SR_PKGLIBS= | |
123 | SR_PKGLIBS_CHECK= | |
124 | SR_PKGLIBS_CXX= | |
125 | SR_PKGLIBS_PYTHON= | |
126 | ||
127 | # Keep track of all checked modules so we can list them at the end. | |
128 | sr_pkglibs_summary= | |
129 | sr_nl=' | |
130 | ' | |
131 | ## SR_PKG_CHECK(tag, [collect-var], module...) | |
132 | m4_define([SR_PKG_CHECK], [ | |
133 | sr_mod_leader=`printf '%.32s' "$3................................"` | |
134 | PKG_CHECK_EXISTS([$3], [ | |
135 | sr_have_$1=yes | |
136 | m4_ifval([$2], [$2="[$]$2[$]{$2:+ }$3"]) | |
137 | sr_$1_version=`$PKG_CONFIG --modversion "$3" 2>&AS_MESSAGE_LOG_FD` | |
138 | AS_VAR_APPEND([sr_pkglibs_summary], [" - $sr_mod_leader $sr_$1_version$sr_nl"]) | |
139 | ], [ | |
1f61c22f | 140 | AS_VAR_APPEND([sr_pkglibs_summary], [" - $sr_mod_leader no$sr_nl"]) |
d37c7109 DE |
141 | m4_ifval([$4], |
142 | [SR_PKG_CHECK([$1], [$2], m4_shift3($@))], | |
143 | [sr_have_$1=no sr_$1_version=]) | |
1f61c22f DE |
144 | ]) |
145 | ]) | |
826938d8 | 146 | |
d37c7109 DE |
147 | # List of detected features. |
148 | sr_deps_avail= | |
149 | ||
1f61c22f DE |
150 | ## SR_ARG_OPT_PKG(opt-name, [cpp-name], [cond-name], module...) |
151 | m4_define([SR_ARG_OPT_PKG], [ | |
152 | AC_ARG_WITH([$1], [AS_HELP_STRING([--without-$1], | |
153 | [disable $1 support [default=detect]])]) | |
154 | AS_IF([test "x$with_$1" = xno], [sr_have_$1=no], | |
155 | [test "x$sr_have_$1" != xyes], | |
156 | [SR_PKG_CHECK([$1], [SR_PKGLIBS], m4_shift3($@))]) | |
157 | AS_IF([test "x$with_$1$sr_have_$1" = xyesno], | |
158 | [AC_MSG_ERROR([$1 support requested, but it was not found.])]) | |
d37c7109 DE |
159 | AS_IF([test "x$sr_have_$1" = xyes], |
160 | [sr_deps_avail="$sr_deps_avail $1"[]m4_ifval([$2], [ | |
2cbde151 DE |
161 | AC_DEFINE([HAVE_$2], [1], [Whether $1 is available.]) |
162 | AC_DEFINE_UNQUOTED([CONF_$2_VERSION], ["$sr_$1_version"], [Build-time version of $1.]) | |
1f61c22f DE |
163 | ])]) |
164 | m4_ifval([$3], [AM_CONDITIONAL([$3], [test "x$sr_have_$1" = xyes])]) | |
165 | ]) | |
ee8ddd8f | 166 | |
2cbde151 | 167 | SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], [NEED_SERIAL], |
1f61c22f | 168 | [libserialport >= 0.1.1]) |
1f61c22f | 169 | |
2cbde151 | 170 | SR_ARG_OPT_PKG([libftdi], [LIBFTDI],, |
2700e63d | 171 | [libftdi >= 0.16], [libftdi1 >= 1.0]) |
1f61c22f DE |
172 | |
173 | # FreeBSD comes with an "integrated" libusb-1.0-style USB API. | |
174 | # This means libusb-1.0 is always available; no need to check for it. | |
175 | AS_CASE([$host], [*freebsd*], [sr_have_libusb=yes]) | |
176 | ||
2cbde151 | 177 | SR_ARG_OPT_PKG([libusb], [LIBUSB_1_0], [NEED_USB], |
1f61c22f | 178 | [libusb-1.0 >= 1.0.16]) |
c23c8659 | 179 | |
2cbde151 | 180 | SR_ARG_OPT_PKG([librevisa], [LIBREVISA], [NEED_VISA], |
1f61c22f | 181 | [librevisa >= 0.0.20130412]) |
d92de05a | 182 | |
2cbde151 | 183 | SR_ARG_OPT_PKG([libgpib], [LIBGPIB], [NEED_GPIB], |
1f61c22f DE |
184 | [libgpib]) |
185 | ||
186 | ###################### | |
187 | ## Feature checks ## | |
188 | ###################### | |
f7740954 | 189 | |
aba69262 | 190 | # The Check unit testing framework is optional. Disable if not found. |
1f61c22f DE |
191 | SR_PKG_CHECK([check], [SR_PKGLIBS_CHECK], [check >= 0.9.4]) |
192 | AM_CONDITIONAL([HAVE_CHECK], [test "x$sr_have_check" = xyes]) | |
193 | ||
194 | AC_LANG([C]) | |
195 | ||
196 | # Check host characteristics. | |
197 | AC_C_BIGENDIAN | |
79bb0e97 | 198 | |
d37c7109 DE |
199 | AC_CHECK_HEADERS([sys/mman.h], [sr_deps_avail="$sr_deps_avail sys_mman_h"]) |
200 | AC_CHECK_HEADERS([sys/ioctl.h], [sr_deps_avail="$sr_deps_avail sys_ioctl_h"]) | |
201 | AC_CHECK_HEADERS([sys/timerfd.h], [sr_deps_avail="$sr_deps_avail sys_timerfd_h"]) | |
1f61c22f DE |
202 | |
203 | # RPC is only needed for VXI support. | |
204 | AC_CACHE_CHECK([for RPC support], [sr_cv_have_rpc], | |
205 | [AC_LINK_IFELSE([AC_LANG_PROGRAM( | |
206 | [[#include <rpc/rpc.h>]m4_newline[CLIENT *rpc_test(void);]], | |
207 | [[(void) clnt_create("", 0, 0, "");]])], | |
208 | [sr_cv_have_rpc=yes], [sr_cv_have_rpc=no])]) | |
209 | AS_IF([test "x$sr_cv_have_rpc" = xyes], | |
210 | [AC_DEFINE([HAVE_RPC], [1], [Specifies whether we have RPC support.])]) | |
211 | # VXI support is only compiled if RPC support was found. | |
212 | AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes]) | |
213 | ||
d37c7109 DE |
214 | ######################## |
215 | ## Hardware drivers ## | |
216 | ######################## | |
217 | ||
218 | # Keep track of all drivers so we can list them at the end. | |
219 | sr_driver_summary= | |
220 | ||
221 | # Check whether the sr_deps_avail list contains all of the arguments. | |
222 | # Unavailable dependencies are collected in sr_deps_missing. | |
223 | sr_check_driver_deps() { | |
224 | sr_deps_missing= | |
225 | for sr_dep | |
226 | do | |
227 | AS_CASE([" $sr_deps_avail "], [*" $sr_dep "*],, | |
228 | [sr_deps_missing="$sr_deps_missing $sr_dep"]) | |
229 | done | |
230 | } | |
231 | ||
232 | AC_ARG_ENABLE([all-drivers], | |
233 | [AS_HELP_STRING([--enable-all-drivers], | |
234 | [enable all drivers by default [default=yes]])], | |
235 | [], [enable_all_drivers=yes]) | |
236 | ||
237 | ## _SR_DRIVER(Device name, driver-name, var-name, [dependencies...]) | |
238 | m4_define([_SR_DRIVER], [ | |
b8b727e4 | 239 | AC_ARG_ENABLE([$2], |
d37c7109 DE |
240 | [AS_HELP_STRING([--enable-$2], [enable $1 support])], |
241 | [$3=$enableval], [$3=$enable_all_drivers]) | |
242 | ||
243 | AS_IF([test "x[$]$3" = xyes], [sr_hw_info=yes[]m4_ifval([$4], [ | |
244 | sr_check_driver_deps $4 | |
245 | AS_IF([test -n "$sr_deps_missing"], | |
246 | [$3=no sr_hw_info="no (missing:$sr_deps_missing)"]) | |
247 | ])], [sr_hw_info='no (disabled)']) | |
248 | sr_hw_leader=`printf '%.32s' "$2................................"` | |
249 | AS_VAR_APPEND([sr_driver_summary], [" - $sr_hw_leader $sr_hw_info$sr_nl"]) | |
250 | ||
251 | AM_CONDITIONAL([$3], [test "x[$]$3" = xyes]) | |
252 | AM_COND_IF([$3], [AC_DEFINE([HAVE_$3], [1], [Whether to support $1 device.])]) | |
253 | ]) | |
254 | ||
255 | ## SR_DRIVER(Device name, driver-name, [dependencies...]) | |
256 | m4_define([SR_DRIVER], | |
257 | [_SR_DRIVER([$1], [$2], m4_expand([AS_TR_CPP([HW_$2])]), [$3])]) | |
258 | ||
259 | SR_DRIVER([Agilent DMM], [agilent-dmm], [libserialport]) | |
260 | SR_DRIVER([Appa 55II], [appa-55ii], [libserialport]) | |
261 | SR_DRIVER([ASIX SIGMA/SIGMA2], [asix-sigma], [libftdi]) | |
262 | SR_DRIVER([Atten PPS3xxx], [atten-pps3xxx], [libserialport]) | |
263 | SR_DRIVER([BayLibre ACME], [baylibre-acme], [sys_timerfd_h]) | |
264 | SR_DRIVER([BeagleLogic], [beaglelogic], [sys_mman_h sys_ioctl_h]) | |
265 | SR_DRIVER([Brymen BM86x], [brymen-bm86x], [libusb]) | |
266 | SR_DRIVER([Brymen DMM], [brymen-dmm], [libserialport]) | |
267 | SR_DRIVER([CEM DT-885x], [cem-dt-885x], [libserialport]) | |
268 | SR_DRIVER([Center 3xx], [center-3xx], [libserialport]) | |
269 | SR_DRIVER([ChronoVu LA], [chronovu-la], [libftdi]) | |
270 | SR_DRIVER([Colead SLM], [colead-slm], [libserialport]) | |
271 | SR_DRIVER([Conrad DIGI 35 CPU], [conrad-digi-35-cpu], [libserialport]) | |
272 | SR_DRIVER([DER EE DE-5000], [deree-de5000], [libserialport]) | |
273 | SR_DRIVER([demo], [demo]) | |
274 | SR_DRIVER([Fluke DMM], [fluke-dmm], [libserialport]) | |
275 | SR_DRIVER([fx2lafw], [fx2lafw], [libusb]) | |
276 | SR_DRIVER([GMC MH 1x/2x], [gmc-mh-1x-2x], [libserialport]) | |
277 | SR_DRIVER([Hameg HMO], [hameg-hmo], [libserialport]) | |
278 | SR_DRIVER([Hantek DSO], [hantek-dso], [libusb]) | |
279 | SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2], [libusb]) | |
280 | SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus], [libftdi]) | |
281 | SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b], [libusb]) | |
282 | SR_DRIVER([Lascar EL-USB], [lascar-el-usb], [libusb]) | |
283 | SR_DRIVER([Manson HCS-3xxx], [manson-hcs-3xxx], [libserialport]) | |
284 | SR_DRIVER([maynuo-m97], [maynuo-m97]) | |
285 | SR_DRIVER([MIC 985xx], [mic-985xx], [libserialport]) | |
286 | SR_DRIVER([Motech LPS 30x], [motech-lps-30x], [libserialport]) | |
287 | SR_DRIVER([Norma DMM], [norma-dmm], [libserialport]) | |
288 | SR_DRIVER([OpenBench Logic Sniffer], [openbench-logic-sniffer], [libserialport]) | |
289 | SR_DRIVER([Pipistrello-OLS], [pipistrello-ols], [libftdi]) | |
290 | SR_DRIVER([Rigol DS], [rigol-ds]) | |
291 | SR_DRIVER([Saleae Logic16], [saleae-logic16], [libusb]) | |
292 | SR_DRIVER([SCPI PPS], [scpi-pps]) | |
293 | SR_DRIVER([serial DMM], [serial-dmm], [libserialport]) | |
294 | SR_DRIVER([Sysclk LWLA], [sysclk-lwla], [libusb]) | |
295 | SR_DRIVER([Teleinfo], [teleinfo], [libserialport]) | |
296 | SR_DRIVER([Testo], [testo], [libusb]) | |
297 | SR_DRIVER([Tondaj SL-814], [tondaj-sl-814], [libserialport]) | |
298 | SR_DRIVER([UNI-T DMM], [uni-t-dmm], [libusb]) | |
299 | SR_DRIVER([UNI-T UT32x], [uni-t-ut32x], [libusb]) | |
300 | SR_DRIVER([Victor DMM], [victor-dmm], [libusb]) | |
301 | SR_DRIVER([Yokogawa DL/DLM], [yokogawa-dlm]) | |
302 | SR_DRIVER([ZEROPLUS Logic Cube], [zeroplus-logic-cube], [libusb]) | |
1f61c22f DE |
303 | |
304 | ############################### | |
305 | ## Language bindings setup ## | |
306 | ############################### | |
307 | ||
d37c7109 DE |
308 | AC_LANG([C++]) |
309 | ||
1f61c22f DE |
310 | AC_ARG_ENABLE([bindings], |
311 | [AS_HELP_STRING([--enable-bindings], [build language bindings [default=yes]])], | |
312 | [], [enable_bindings=yes]) | |
176c7219 | 313 | |
1f61c22f DE |
314 | AC_ARG_ENABLE([cxx], |
315 | [AS_HELP_STRING([--enable-cxx], [build C++ bindings [default=yes]])], | |
316 | [], [enable_cxx=$enable_bindings]) | |
a0b277ba | 317 | |
1f61c22f DE |
318 | AC_ARG_ENABLE([python], |
319 | [AS_HELP_STRING([--enable-python], [build Python bindings [default=yes]])], | |
320 | [], [enable_python=$enable_bindings]) | |
826938d8 | 321 | |
1f61c22f DE |
322 | AC_ARG_ENABLE([java], |
323 | [AS_HELP_STRING([--enable-java], [build Java bindings [default=yes]])], | |
324 | [], [enable_java=$enable_bindings]) | |
325 | ||
326 | #################### | |
327 | ## C++ bindings ## | |
328 | #################### | |
329 | ||
330 | sr_cxx_missing= | |
331 | ||
332 | # Check if the C++ compiler supports the C++11 standard. | |
333 | m4_ifdef([AX_CXX_COMPILE_STDCXX_11], | |
334 | [AX_CXX_COMPILE_STDCXX_11(, [optional])], | |
335 | [m4_warn(, [[Missing macro AX_CXX_COMPILE_STDCXX_11: no C++11 check possible]])]) | |
336 | test "x$HAVE_CXX11" = x1 || sr_cxx_missing="$sr_cxx_missing C++11" | |
337 | ||
338 | # The C++ bindings need glibmm. | |
339 | SR_PKG_CHECK([glibmm], [SR_PKGLIBS_CXX], [glibmm-2.4 >= 2.32.0]) | |
340 | test "x$sr_have_glibmm" = xyes || sr_cxx_missing="$sr_cxx_missing glibmm" | |
341 | ||
342 | # The C++ bindings use Doxygen to parse libsigrok symbols. | |
343 | AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes], [no]) | |
344 | test "x$HAVE_DOXYGEN" = xyes || sr_cxx_missing="$sr_cxx_missing Doxygen" | |
345 | ||
346 | # Python is needed for the C++ bindings. | |
347 | AM_PATH_PYTHON([2.7], | |
348 | [HAVE_PYTHON=yes], | |
349 | [HAVE_PYTHON=no sr_cxx_missing="$sr_cxx_missing Python"]) | |
350 | ||
351 | AS_IF([test -z "$sr_cxx_missing"], | |
352 | [BINDINGS_CXX=$enable_cxx], [BINDINGS_CXX=no]) | |
353 | AM_CONDITIONAL([BINDINGS_CXX], [test "x$BINDINGS_CXX" = xyes]) | |
354 | ||
355 | # C++ bindings want stoi and stod. | |
356 | AM_COND_IF([BINDINGS_CXX], [ | |
357 | AC_CACHE_CHECK([for stoi and stod], [sr_cv_have_stoi_stod], | |
358 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string>]], | |
359 | [[(void) std::stoi("1"); (void) std::stod("1.0");]])], | |
360 | [sr_cv_have_stoi_stod=yes], [sr_cv_have_stoi_stod=no])]) | |
361 | AS_IF([test "x$sr_cv_have_stoi_stod" = xyes], | |
362 | [AC_DEFINE([HAVE_STOI_STOD], [1], | |
363 | [Specifies whether we have the stoi and stod functions.])]) | |
364 | ]) | |
365 | ||
366 | ####################### | |
367 | ## Python bindings ## | |
368 | ####################### | |
369 | ||
370 | sr_python_missing= | |
371 | test "x$BINDINGS_CXX" = xyes || sr_python_missing=" C++ bindings" | |
372 | ||
373 | # The Python bindings need Python development files. | |
374 | SR_PKG_CHECK([python_dev], [SR_PKGLIBS_PYTHON], | |
375 | [python >= 2.7], [python2 >= 2.7], [python27 >= 2.7]) | |
376 | test "x$sr_have_python_dev" = xyes \ | |
377 | || sr_python_missing="$sr_python_missing Headers" | |
378 | ||
379 | # PyGObject is needed for the Python bindings. | |
380 | SR_PKG_CHECK([pygobject], [SR_PKGLIBS_PYTHON], [pygobject-3.0 >= 3.0.0]) | |
381 | test "x$sr_have_python_dev" = xyes \ | |
382 | || sr_python_missing="$sr_python_missing PyGObject" | |
383 | ||
384 | PKG_CHECK_EXISTS([pygobject-3.0 < 3.7.91], | |
385 | [AC_DEFINE([PYGOBJECT_FLAGS_SIGNED], [1], | |
386 | [Whether last argument to pyg_flags_get_value() is signed.])]) | |
387 | ||
388 | # The Python bindings need the setuptools Python module. | |
389 | # We'll let it go through even if the AX macro wasn't found, | |
390 | # as the Python module may still be there. | |
391 | HAVE_PYMOD_SETUPTOOLS=yes | |
392 | m4_ifdef([AX_PYTHON_MODULE], | |
393 | [AX_PYTHON_MODULE([setuptools])], | |
394 | [m4_warn(, [[Missing macro AX_PYTHON_MODULE: no setuptools check]])]) | |
395 | test "x$HAVE_PYMOD_SETUPTOOLS" = xyes \ | |
396 | || sr_python_missing="$sr_python_missing Setuptools" | |
397 | ||
398 | # The Python bindings use SWIG to generate code. | |
399 | AC_CHECK_PROG([HAVE_SWIG], [swig], [yes], [no]) | |
400 | test "x$HAVE_SWIG" = xyes || sr_python_missing="$sr_python_missing SWIG" | |
401 | ||
402 | AS_IF([test -z "$sr_python_missing"], | |
403 | [BINDINGS_PYTHON=$enable_python], [BINDINGS_PYTHON=no]) | |
404 | AM_CONDITIONAL([BINDINGS_PYTHON], [test "x$BINDINGS_PYTHON" = xyes]) | |
405 | ||
406 | #################### | |
407 | ## Java bindings ## | |
408 | #################### | |
409 | ||
410 | sr_java_missing= | |
411 | test "x$BINDINGS_CXX" = xyes || sr_java_missing=" C++ bindings" | |
412 | ||
413 | # The Java bindings use SWIG to generate code. | |
414 | test "x$HAVE_SWIG" = xyes || sr_java_missing="$sr_java_missing SWIG" | |
4f10853e | 415 | |
9fcf4d0b | 416 | # Find Java compiler and JNI includes for Java bindings. |
9fcf4d0b | 417 | AC_CHECK_PROG([HAVE_JAVAC], [javac], [yes], [no]) |
1f61c22f DE |
418 | test "x$HAVE_JAVAC" = xyes || sr_java_missing="$sr_java_missing JavaC" |
419 | ||
420 | AC_ARG_WITH([jni-include-path], | |
421 | [AS_HELP_STRING([[--with-jni-include-path=DIR-LIST (space-separated)]], | |
422 | [specify JNI include directories [default=detect]])], | |
423 | [JNI_INCLUDE_DIRS=" $withval"], [JNI_INCLUDE_DIRS=]) | |
424 | ||
425 | JNI_CPPFLAGS= | |
426 | AS_IF([test "x$enable_java$HAVE_JAVAC" = xyesyes], [ | |
9fcf4d0b | 427 | AX_PROG_JAVAC |
1f61c22f DE |
428 | AS_IF([test -z "$JNI_INCLUDE_DIRS" && test "x$cross_compiling" != xyes], [ |
429 | ## Work around the totally broken logic in AX_JNI_INCLUDE_DIR: | |
430 | ## If we can find jni.h without any special search path, skip | |
431 | ## the execution of the broken macro to increase our chances of | |
432 | ## success. | |
433 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jni.h>]], [])],, | |
434 | [AX_JNI_INCLUDE_DIR]) | |
435 | ]) | |
436 | ]) | |
437 | for sr_dir in $JNI_INCLUDE_DIRS | |
438 | do | |
439 | JNI_CPPFLAGS="$JNI_CPPFLAGS -I$sr_dir" | |
440 | done | |
441 | AC_SUBST([JNI_CPPFLAGS]) | |
442 | ||
443 | sr_save_cppflags=$CPPFLAGS | |
444 | CPPFLAGS=$CPPFLAGS$JNI_CPPFLAGS | |
445 | AC_CHECK_HEADER([jni.h],, [sr_java_missing="$sr_java_missing JNI headers"]) | |
446 | CPPFLAGS=$sr_save_cppflags | |
447 | ||
448 | AS_IF([test -z "$sr_java_missing"], | |
449 | [BINDINGS_JAVA=$enable_java], [BINDINGS_JAVA=no]) | |
450 | AM_CONDITIONAL([BINDINGS_JAVA], [test "x$BINDINGS_JAVA" = xyes]) | |
451 | ||
452 | ############################## | |
453 | ## Finalize configuration ## | |
454 | ############################## | |
455 | ||
456 | # Add mandatory dependencies to module list. | |
457 | SR_PKGLIBS="$SR_PKGLIBS${SR_PKGLIBS:+ }libzip >= 0.10" | |
458 | AC_SUBST([SR_PKGLIBS]) | |
459 | ||
460 | # Retrieve the compile and link flags for all modules combined. | |
461 | # Also, bail out at this point if any module dependency is not met. | |
462 | PKG_CHECK_MODULES([LIBSIGROK], [glib-2.0 >= 2.32.0 $SR_PKGLIBS]) | |
1f61c22f DE |
463 | PKG_CHECK_MODULES([CHECK], [$SR_PKGLIBS_CHECK glib-2.0 $SR_PKGLIBS]) |
464 | ||
da0763d0 DE |
465 | # SR_PKGLIBS_CXX may be empty, so only invoke these checks when |
466 | # the C++ bindings are enabled. | |
467 | AM_COND_IF([BINDINGS_CXX], [ | |
468 | PKG_CHECK_MODULES([LIBSIGROKCXX], [$SR_PKGLIBS_CXX]) | |
469 | PKG_CHECK_MODULES([PYSIGROK], [$SR_PKGLIBS_PYTHON $SR_PKGLIBS_CXX]) | |
470 | ]) | |
1f61c22f DE |
471 | sr_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD` |
472 | sr_libzip_version=`$PKG_CONFIG --modversion libzip 2>&AS_MESSAGE_LOG_FD` | |
473 | ||
2cbde151 DE |
474 | AC_DEFINE_UNQUOTED([CONF_LIBZIP_VERSION], ["$sr_libzip_version"], |
475 | [Build-time version of libzip.]) | |
476 | AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"], | |
477 | [The canonical host libsigrok will run on.]) | |
1f61c22f DE |
478 | |
479 | AC_LANG([C]) | |
480 | ||
481 | # libm (the standard math library) is always needed. | |
482 | AC_SEARCH_LIBS([pow], [m]) | |
483 | ||
484 | # We need to link against the Winsock2 library for SCPI over TCP. | |
485 | AS_CASE([$host], [*mingw*], [LIBS="$LIBS -lws2_32"]) | |
826938d8 | 486 | |
27a2497d | 487 | AC_SUBST([FIRMWARE_DIR], ['$(datadir)/sigrok-firmware']) |
1f61c22f DE |
488 | AC_SUBST([MAKEFLAGS], ['--no-print-directory']) |
489 | AC_SUBST([AM_LIBTOOLFLAGS], ['--silent']) | |
826938d8 | 490 | |
b2478a23 | 491 | AC_CONFIG_FILES([Makefile libsigrok.pc bindings/cxx/libsigrokcxx.pc]) |
826938d8 UH |
492 | |
493 | AC_OUTPUT | |
494 | ||
1f61c22f | 495 | # Prepare bindings report messages. |
d37c7109 DE |
496 | m4_define([SR_PREPARE_BINDING_REPORT], [ |
497 | sr_report_$1= | |
498 | test -z "$sr_$1_missing" || sr_report_$1=" (missing:$sr_$1_missing)" | |
499 | test "x$enable_$1" = xyes || sr_report_$1=' (disabled)' | |
1f61c22f | 500 | ]) |
d37c7109 | 501 | m4_map_args([SR_PREPARE_BINDING_REPORT], [cxx], [python], [java]) |
45aed072 | 502 | |
1f61c22f DE |
503 | cat >&AS_MESSAGE_FD <<_EOF |
504 | ||
505 | libsigrok configuration summary: | |
506 | - Package version................. $SR_PACKAGE_VERSION | |
507 | - Library ABI version............. $SR_LIB_VERSION | |
508 | - Prefix.......................... $prefix | |
509 | - Building on..................... $build | |
510 | - Building for.................... $host | |
511 | ||
512 | Detected libraries (required): | |
965d6889 UH |
513 | - glib-2.0 >= 2.32.0.............. $sr_glib_version |
514 | - libzip >= 0.10.................. $sr_libzip_version | |
1f61c22f DE |
515 | |
516 | Detected libraries (optional): | |
517 | $sr_pkglibs_summary | |
c5f179a9 DE |
518 | |
519 | Enabled hardware drivers: | |
d37c7109 | 520 | $sr_driver_summary |
c5f179a9 | 521 | |
1f61c22f DE |
522 | Enabled SCPI backends: |
523 | - TCP............................. yes | |
524 | - RPC............................. $sr_cv_have_rpc | |
525 | - serial.......................... $sr_have_libserialport | |
526 | - VISA............................ $sr_have_librevisa | |
527 | - GPIB............................ $sr_have_libgpib | |
528 | - USBTMC.......................... $sr_have_libusb | |
529 | ||
530 | Enabled language bindings: | |
531 | - C++............................. $BINDINGS_CXX$sr_report_cxx | |
532 | - Python.......................... $BINDINGS_PYTHON$sr_report_python | |
533 | - Java............................ $BINDINGS_JAVA$sr_report_java | |
826938d8 | 534 | |
1f61c22f | 535 | _EOF |