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