configure.ac 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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. # We require at least autoconf 2.63 (AC_INIT format changed there).
  21. AC_PREREQ([2.63])
  22. AC_INIT([libsigrok], [0.6.0],
  23. [sigrok-devel@lists.sourceforge.net],
  24. [libsigrok], [http://www.sigrok.org])
  25. AC_CONFIG_MACRO_DIR([m4])
  26. AC_CONFIG_AUX_DIR([autostuff])
  27. AC_CONFIG_HEADERS([config.h include/libsigrok/version.h])
  28. # We require at least automake 1.11 (needed for 'silent rules').
  29. AM_INIT_AUTOMAKE([1.11 -Wall -Werror no-define nostdinc subdir-objects check-news color-tests])
  30. AM_SILENT_RULES([yes])
  31. m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  32. AC_CANONICAL_HOST
  33. # Checks for programs.
  34. AC_PROG_CC
  35. AC_PROG_CXX
  36. AC_PROG_INSTALL
  37. AC_PROG_LN_S
  38. # Required for per-target flags or subdir-objects with C sources.
  39. AM_PROG_CC_C_O
  40. # Set the standard the C library headers should conform to.
  41. AH_VERBATIM([_POSIX_C_SOURCE], [/* The targeted POSIX standard. */
  42. #ifndef _POSIX_C_SOURCE
  43. # define _POSIX_C_SOURCE 200112L
  44. #endif])
  45. # Get compiler versions.
  46. SR_PROG_VERSION([$CC], [sr_cc_version])
  47. SR_PROG_VERSION([$CXX], [sr_cxx_version])
  48. # Check for optional make features.
  49. SR_PROG_MAKE_ORDER_ONLY
  50. # Initialize libtool.
  51. LT_INIT
  52. # Set up the libsigrok version defines.
  53. SR_PKG_VERSION_SET([SR_PACKAGE_VERSION], [AC_PACKAGE_VERSION])
  54. # Library version for libsigrok (NOT the same as the package version).
  55. # Carefully read the libtool docs before updating these numbers!
  56. # The algorithm for determining which number to change (and how) is nontrivial!
  57. # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
  58. # Format: current:revision:age.
  59. SR_LIB_VERSION_SET([SR_LIB_VERSION], [4:0:0])
  60. AM_CONDITIONAL([WIN32], [test -z "${host_os##mingw*}" || test -z "${host_os##cygwin*}"])
  61. #############################
  62. ## Optional dependencies ##
  63. #############################
  64. AC_LANG([C])
  65. # Initialize pkg-config.
  66. # We require at least 0.22, as "Requires.private" behaviour changed there.
  67. PKG_PROG_PKG_CONFIG([0.22])
  68. # Keep track of all checked modules so we can list them at the end.
  69. SR_PKG_CHECK_SUMMARY([sr_pkglibs_summary])
  70. # Collect the pkg-config module names of all dependencies in SR_PKGLIBS.
  71. # These are used to derive the compiler flags and for the "Requires.private"
  72. # field in the generated libsigrok.pc file.
  73. SR_VAR_OPT_PKG([SR_PKGLIBS], [sr_deps_avail])
  74. SR_PKGLIBS_TESTS=
  75. SR_PKGLIBS_CXX=
  76. SR_PKGLIBS_PYTHON=
  77. SR_PKGLIBS_RUBY=
  78. SR_EXTRA_LIBS=
  79. SR_EXTRA_CXX_LIBS=
  80. SR_ARG_OPT_PKG([libserialport], [LIBSERIALPORT], [NEED_SERIAL],
  81. [libserialport >= 0.1.1])
  82. SR_ARG_OPT_PKG([libftdi], [LIBFTDI], , [libftdi1 >= 1.0])
  83. # FreeBSD comes with an "integrated" libusb-1.0-style USB API.
  84. # This means libusb-1.0 is always available; no need to check for it.
  85. # On Windows, require the latest version we can get our hands on,
  86. # until the new generic event handling has seen an official release.
  87. AS_CASE([$host_os],
  88. [freebsd*], [sr_libusb_req='libusb-1.0' sr_have_libusb=yes],
  89. [mingw*], [sr_libusb_req='libusb-1.0 >= 1.0.20'],
  90. [sr_libusb_req='libusb-1.0 >= 1.0.16'])
  91. SR_ARG_OPT_PKG([libusb], [LIBUSB_1_0], [NEED_USB],
  92. [$sr_libusb_req])
  93. SR_ARG_OPT_PKG([librevisa], [LIBREVISA], [NEED_VISA],
  94. [librevisa >= 0.0.20130412])
  95. SR_ARG_OPT_PKG([libgpib], [LIBGPIB], [NEED_GPIB],
  96. [libgpib])
  97. SR_ARG_OPT_CHECK([libieee1284], [LIBIEEE1284],, [
  98. sr_save_LIBS=$LIBS
  99. LIBS="-lieee1284 $LIBS"
  100. AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <ieee1284.h>]],
  101. [[(void) ieee1284_open(0, 0, 0);]])],
  102. [sr_have_libieee1284=yes], [sr_have_libieee1284=no])
  103. LIBS=$sr_save_LIBS
  104. ])
  105. AS_IF([test "x$sr_have_libieee1284" = xyes],
  106. [SR_PREPEND([SR_EXTRA_LIBS], [-lieee1284])])
  107. ######################
  108. ## Feature checks ##
  109. ######################
  110. # The Check unit testing framework is optional. Disable if not found.
  111. SR_PKG_CHECK([check], [SR_PKGLIBS_TESTS], [check >= 0.9.4])
  112. AM_CONDITIONAL([HAVE_CHECK], [test "x$sr_have_check" = xyes])
  113. # Enable the C99 standard if possible, and enforce the use
  114. # of SR_API to explicitly mark all public API functions.
  115. SR_EXTRA_CFLAGS=
  116. SR_CHECK_COMPILE_FLAGS([SR_EXTRA_CFLAGS], [C99], [-std=c99 -c99 -AC99 -qlanglvl=extc99])
  117. SR_CHECK_COMPILE_FLAGS([SR_EXTRA_CFLAGS], [visibility], [-fvisibility=hidden])
  118. SR_ARG_ENABLE_WARNINGS([SR_WFLAGS], [-Wall], [-Wall -Wextra -Wmissing-prototypes])
  119. # Check host characteristics.
  120. AC_SYS_LARGEFILE
  121. AC_C_BIGENDIAN
  122. AC_CHECK_HEADERS([sys/mman.h], [SR_APPEND([sr_deps_avail], [sys_mman_h])])
  123. AC_CHECK_HEADERS([sys/ioctl.h], [SR_APPEND([sr_deps_avail], [sys_ioctl_h])])
  124. AC_CHECK_HEADERS([sys/timerfd.h], [SR_APPEND([sr_deps_avail], [sys_timerfd_h])])
  125. # We need to link against the Winsock2 library for SCPI over TCP.
  126. AS_CASE([$host_os], [mingw*], [SR_PREPEND([SR_EXTRA_LIBS], [-lws2_32])])
  127. # libm (the standard math library) is always needed.
  128. SR_SEARCH_LIBS([SR_EXTRA_LIBS], [pow], [m])
  129. # RPC is only needed for VXI support.
  130. AC_CACHE_CHECK([for RPC support], [sr_cv_have_rpc],
  131. [AC_LINK_IFELSE([AC_LANG_PROGRAM(
  132. [[#include <rpc/rpc.h>]m4_newline[CLIENT *rpc_test(void);]],
  133. [[(void) clnt_create("", 0, 0, "");]])],
  134. [sr_cv_have_rpc=yes], [sr_cv_have_rpc=no])])
  135. AS_IF([test "x$sr_cv_have_rpc" = xyes],
  136. [AC_DEFINE([HAVE_RPC], [1], [Specifies whether we have RPC support.])])
  137. # VXI support is only compiled if RPC support was found.
  138. AM_CONDITIONAL([NEED_RPC], [test "x$sr_cv_have_rpc" = xyes])
  139. # Check for compiler support of 128 bit integers
  140. AC_CHECK_TYPES([__int128_t, __uint128_t], [], [], [])
  141. ########################
  142. ## Hardware drivers ##
  143. ########################
  144. # Keep track of all drivers so we can list them at the end.
  145. SR_VAR_SUMMARY([sr_driver_summary])
  146. # Check whether the sr_deps_avail list contains all of the arguments.
  147. # Unavailable dependencies are collected in sr_deps_missing.
  148. sr_check_driver_deps() {
  149. sr_deps_missing=
  150. for sr_dep
  151. do
  152. AS_CASE([" $sr_deps_avail "], [*" $sr_dep "*],,
  153. [SR_APPEND([sr_deps_missing], [', '], [$sr_dep])])
  154. done
  155. test -z "$sr_deps_missing" || return 1
  156. }
  157. AC_ARG_ENABLE([all-drivers],
  158. [AS_HELP_STRING([--enable-all-drivers],
  159. [enable all drivers by default [default=yes]])],
  160. [], [enable_all_drivers=yes])
  161. ## _SR_DRIVER(Device name, driver-name, var-name, [dependencies...])
  162. m4_define([_SR_DRIVER], [
  163. AC_ARG_ENABLE([$2],
  164. [AS_HELP_STRING([--enable-$2], [enable $1 support])],
  165. [$3=$enableval], [$3=$enable_all_drivers])
  166. AS_IF([test "x[$]$3" = xyes], [sr_hw_info=yes[]m4_ifval([$4], [
  167. sr_check_driver_deps $4 \
  168. || $3=no sr_hw_info="no (missing: $sr_deps_missing)"
  169. ])], [sr_hw_info='no (disabled)'])
  170. sr_driver_summary_append "$2" "$sr_hw_info"
  171. AM_CONDITIONAL([$3], [test "x[$]$3" = xyes])
  172. AM_COND_IF([$3], [AC_DEFINE([HAVE_$3], [1], [Whether to support $1 device.]) AC_DEFINE([HAVE_DRIVERS], [1], [Whether at least one driver is enabled.])])
  173. ])
  174. ## SR_DRIVER(Device name, driver-name, [dependencies...])
  175. m4_define([SR_DRIVER],
  176. [_SR_DRIVER([$1], [$2], m4_expand([AS_TR_CPP([HW_$2])]), [$3])])
  177. SR_DRIVER([Agilent DMM], [agilent-dmm], [libserialport])
  178. SR_DRIVER([Appa 55II], [appa-55ii], [libserialport])
  179. SR_DRIVER([Arachnid Labs Re:load Pro], [arachnid-labs-re-load-pro], [libserialport])
  180. SR_DRIVER([ASIX SIGMA/SIGMA2], [asix-sigma], [libftdi])
  181. SR_DRIVER([Atten PPS3xxx], [atten-pps3xxx], [libserialport])
  182. SR_DRIVER([BayLibre ACME], [baylibre-acme], [sys_timerfd_h])
  183. SR_DRIVER([BeagleLogic], [beaglelogic], [sys_mman_h sys_ioctl_h])
  184. SR_DRIVER([Brymen BM86x], [brymen-bm86x], [libusb])
  185. SR_DRIVER([Brymen DMM], [brymen-dmm], [libserialport])
  186. SR_DRIVER([CEM DT-885x], [cem-dt-885x], [libserialport])
  187. SR_DRIVER([Center 3xx], [center-3xx], [libserialport])
  188. SR_DRIVER([ChronoVu LA], [chronovu-la], [libusb libftdi])
  189. SR_DRIVER([Colead SLM], [colead-slm], [libserialport])
  190. SR_DRIVER([Conrad DIGI 35 CPU], [conrad-digi-35-cpu], [libserialport])
  191. SR_DRIVER([demo], [demo])
  192. SR_DRIVER([DreamSourceLab DSLogic], [dreamsourcelab-dslogic], [libusb])
  193. SR_DRIVER([Fluke DMM], [fluke-dmm], [libserialport])
  194. SR_DRIVER([FTDI LA], [ftdi-la], [libusb libftdi])
  195. SR_DRIVER([fx2lafw], [fx2lafw], [libusb])
  196. SR_DRIVER([GMC MH 1x/2x], [gmc-mh-1x-2x], [libserialport])
  197. SR_DRIVER([GW Instek GDS-800], [gwinstek-gds-800], [libserialport])
  198. SR_DRIVER([Hameg HMO], [hameg-hmo], [libserialport])
  199. SR_DRIVER([Hantek 6xxx], [hantek-6xxx], [libusb])
  200. SR_DRIVER([Hantek DSO], [hantek-dso], [libusb])
  201. SR_DRIVER([HP 3457A], [hp-3457a])
  202. SR_DRIVER([Hung-Chang DSO-2100], [hung-chang-dso-2100], [libieee1284])
  203. SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2], [libusb])
  204. SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus], [libftdi])
  205. SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b], [libusb])
  206. SR_DRIVER([KERN scale], [kern-scale], [libserialport])
  207. SR_DRIVER([Korad KAxxxxP], [korad-kaxxxxp], [libserialport])
  208. SR_DRIVER([Lascar EL-USB], [lascar-el-usb], [libusb])
  209. SR_DRIVER([LeCroy LogicStudio], [lecroy-logicstudio], [libusb])
  210. SR_DRIVER([LeCroy X-Stream], [lecroy-xstream])
  211. SR_DRIVER([Manson HCS-3xxx], [manson-hcs-3xxx], [libserialport])
  212. SR_DRIVER([maynuo-m97], [maynuo-m97])
  213. SR_DRIVER([MIC 985xx], [mic-985xx], [libserialport])
  214. SR_DRIVER([Motech LPS 30x], [motech-lps-30x], [libserialport])
  215. SR_DRIVER([Norma DMM], [norma-dmm], [libserialport])
  216. SR_DRIVER([OpenBench Logic Sniffer], [openbench-logic-sniffer], [libserialport])
  217. SR_DRIVER([PCE PCE-322A], [pce-322a], [libserialport])
  218. SR_DRIVER([Pipistrello-OLS], [pipistrello-ols], [libftdi])
  219. SR_DRIVER([Rigol DS], [rigol-ds])
  220. SR_DRIVER([Rohde&Schwarz SME-0x], [rohde-schwarz-sme-0x], [libserialport])
  221. SR_DRIVER([Saleae Logic16], [saleae-logic16], [libusb])
  222. SR_DRIVER([Saleae Logic Pro], [saleae-logic-pro], [libusb])
  223. SR_DRIVER([SCPI PPS], [scpi-pps])
  224. SR_DRIVER([serial DMM], [serial-dmm], [libserialport])
  225. SR_DRIVER([serial LCR], [serial-lcr], [libserialport])
  226. SR_DRIVER([Sysclk LWLA], [sysclk-lwla], [libusb])
  227. SR_DRIVER([Teleinfo], [teleinfo], [libserialport])
  228. SR_DRIVER([Testo], [testo], [libusb])
  229. SR_DRIVER([Tondaj SL-814], [tondaj-sl-814], [libserialport])
  230. SR_DRIVER([UNI-T DMM], [uni-t-dmm], [libusb])
  231. SR_DRIVER([UNI-T UT32x], [uni-t-ut32x], [libusb])
  232. SR_DRIVER([Victor DMM], [victor-dmm], [libusb])
  233. SR_DRIVER([Yokogawa DL/DLM], [yokogawa-dlm])
  234. SR_DRIVER([ZEROPLUS Logic Cube], [zeroplus-logic-cube], [libusb])
  235. ###############################
  236. ## Language bindings setup ##
  237. ###############################
  238. AC_LANG([C++])
  239. SR_ARG_ENABLE_WARNINGS([SR_WXXFLAGS], [-Wall], [-Wall -Wextra])
  240. AC_ARG_ENABLE([bindings],
  241. [AS_HELP_STRING([--enable-bindings], [build language bindings [default=yes]])],
  242. [], [enable_bindings=yes])
  243. AC_ARG_ENABLE([cxx],
  244. [AS_HELP_STRING([--enable-cxx], [build C++ bindings [default=yes]])],
  245. [], [enable_cxx=$enable_bindings])
  246. AC_ARG_ENABLE([python],
  247. [AS_HELP_STRING([--enable-python], [build Python bindings [default=yes]])],
  248. [], [enable_python=$enable_bindings])
  249. AC_ARG_ENABLE([ruby],
  250. [AS_HELP_STRING([--enable-ruby], [build Ruby bindings [default=yes]])],
  251. [], [enable_ruby=$enable_bindings])
  252. AC_ARG_ENABLE([java],
  253. [AS_HELP_STRING([--enable-java], [build Java bindings [default=yes]])],
  254. [], [enable_java=$enable_bindings])
  255. ####################
  256. ## C++ bindings ##
  257. ####################
  258. sr_cxx_missing=
  259. # Check if the C++ compiler supports the C++11 standard.
  260. AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
  261. AS_IF([test "x$HAVE_CXX11" != x1],
  262. [SR_APPEND([sr_cxx_missing], [', '], ['C++11'])])
  263. # The C++ bindings need glibmm.
  264. SR_PKG_CHECK([glibmm], [SR_PKGLIBS_CXX], [glibmm-2.4 >= 2.32.0])
  265. AS_IF([test "x$sr_have_glibmm" != xyes],
  266. [SR_APPEND([sr_cxx_missing], [', '], [glibmm])])
  267. # The C++ bindings use Doxygen to parse libsigrok symbols.
  268. AC_CHECK_PROG([HAVE_DOXYGEN], [doxygen], [yes], [no])
  269. AS_IF([test "x$HAVE_DOXYGEN" != xyes],
  270. [SR_APPEND([sr_cxx_missing], [', '], [Doxygen])])
  271. # Link C++ code with gnustl_shared if it exists (Android)
  272. SR_SEARCH_LIBS([SR_EXTRA_CXX_LIBS], [__cxa_throw], [gnustl_shared])
  273. # Python is needed for the C++ bindings.
  274. AM_PATH_PYTHON([2.7],
  275. [HAVE_PYTHON=yes],
  276. [HAVE_PYTHON=no
  277. SR_APPEND([sr_cxx_missing], [', '], [Python])])
  278. AS_IF([test -z "$sr_cxx_missing"],
  279. [BINDINGS_CXX=$enable_cxx], [BINDINGS_CXX=no])
  280. AM_CONDITIONAL([BINDINGS_CXX], [test "x$BINDINGS_CXX" = xyes])
  281. # C++ bindings want stoi and stod.
  282. AM_COND_IF([BINDINGS_CXX], [
  283. AC_CACHE_CHECK([for stoi and stod], [sr_cv_have_stoi_stod],
  284. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string>]],
  285. [[(void) std::stoi("1"); (void) std::stod("1.0");]])],
  286. [sr_cv_have_stoi_stod=yes], [sr_cv_have_stoi_stod=no])])
  287. AS_IF([test "x$sr_cv_have_stoi_stod" = xyes],
  288. [AC_DEFINE([HAVE_STOI_STOD], [1],
  289. [Specifies whether we have the stoi and stod functions.])])
  290. ])
  291. #######################
  292. ## Python bindings ##
  293. #######################
  294. AS_IF([test "x$BINDINGS_CXX" = xyes],
  295. [sr_python_missing=],
  296. [sr_python_missing='C++ bindings'])
  297. # Extract major and minor version number of the Python interpreter.
  298. sr_pymajor=${PYTHON_VERSION%%.*}
  299. sr_pyminor=${PYTHON_VERSION#*.}
  300. # The Python bindings need Python development files. Check for either
  301. # Python 3 or Python 2 headers depending on the interpreter version.
  302. SR_PKG_CHECK([python_dev], [SR_PKGLIBS_PYTHON],
  303. [python = $PYTHON_VERSION],
  304. [python$sr_pymajor = $PYTHON_VERSION],
  305. [python$sr_pymajor$sr_pyminor = $PYTHON_VERSION],
  306. [python-$PYTHON_VERSION = $PYTHON_VERSION])
  307. AS_IF([test "x$sr_have_python_dev" != xyes],
  308. [SR_APPEND([sr_python_missing], [', '], [Headers])])
  309. # PyGObject is needed for the Python bindings.
  310. SR_PKG_CHECK([pygobject], [SR_PKGLIBS_PYTHON], [pygobject-3.0 >= 3.0.0])
  311. AS_IF([test "x$sr_have_pygobject" != xyes],
  312. [SR_APPEND([sr_python_missing], [', '], [PyGObject])])
  313. PKG_CHECK_EXISTS([pygobject-3.0 < 3.7.91],
  314. [AC_DEFINE([PYGOBJECT_FLAGS_SIGNED], [1],
  315. [Whether last argument to pyg_flags_get_value() is signed.])])
  316. # The Python bindings need the setuptools and numpy Python modules.
  317. # We'll let it go through even if the AX macro wasn't found, as the
  318. # Python modules may still be there.
  319. m4_ifdef([AX_PYTHON_MODULE], [
  320. AX_PYTHON_MODULE([setuptools])
  321. AX_PYTHON_MODULE([numpy])
  322. ], [
  323. HAVE_PYMOD_SETUPTOOLS=yes
  324. HAVE_PYMOD_NUMPY=yes
  325. m4_warn([unsupported],
  326. [Missing macro AX_PYTHON_MODULE: no check for setuptools and numpy])
  327. ])
  328. AS_IF([test "x$HAVE_PYMOD_SETUPTOOLS" != xyes],
  329. [SR_APPEND([sr_python_missing], [', '], [setuptools])])
  330. AS_IF([test "x$HAVE_PYMOD_NUMPY" != xyes],
  331. [SR_APPEND([sr_python_missing], [', '], [numpy])])
  332. # The Python bindings use SWIG to generate code.
  333. AC_CHECK_PROGS([SWIG], [swig swig3.0 swig2.0])
  334. AS_IF([test "x$SWIG" != x],
  335. AC_MSG_CHECKING([for $SWIG version])
  336. [SWIG_VERSION=`$SWIG -version 2>&1 | sed -n 's/SWIG Version //p'`]
  337. AC_MSG_RESULT([$SWIG_VERSION]))
  338. AS_IF([test "x$SWIG" = x],
  339. [SR_APPEND([sr_python_missing], [', '], [SWIG])])
  340. AS_IF([test -z "$sr_python_missing"],
  341. [BINDINGS_PYTHON=$enable_python], [BINDINGS_PYTHON=no])
  342. AM_CONDITIONAL([BINDINGS_PYTHON], [test "x$BINDINGS_PYTHON" = xyes])
  343. #####################
  344. ## Ruby bindings ##
  345. #####################
  346. AS_IF([test "x$BINDINGS_CXX" = xyes],
  347. [sr_ruby_missing=],
  348. [sr_ruby_missing='C++ bindings'])
  349. AC_PATH_PROGS(RUBY, ["${RUBY-ruby}"], [])
  350. AS_IF([test "x$RUBY" != x],
  351. AC_MSG_CHECKING([for Ruby version])
  352. [RUBY_VERSION=`$RUBY -e 'puts RUBY_VERSION'`]
  353. AC_MSG_RESULT([$RUBY_VERSION])
  354. [RUBY_DLEXT=`$RUBY -rrbconfig -e 'puts RbConfig::CONFIG[["DLEXT"]]'`]
  355. AC_SUBST(RUBY_DLEXT))
  356. AS_IF([test "x$RUBY" = x],
  357. [SR_APPEND([sr_ruby_missing], [', '], [Ruby])])
  358. # Extract major and minor version number of the Ruby interpreter.
  359. sr_rbmajor=${RUBY_VERSION%%.*}
  360. sr_rbminor=${RUBY_VERSION#*.}
  361. sr_rbminor=${sr_rbminor%%.*}
  362. # The Ruby bindings need Ruby development files.
  363. SR_PKG_CHECK([ruby_dev], [SR_PKGLIBS_RUBY],
  364. [ruby],
  365. [ruby-$sr_rbmajor.$sr_rbminor])
  366. AS_IF([test "x$sr_have_ruby_dev" != xyes],
  367. [SR_APPEND([sr_ruby_missing], [', '], [Headers])])
  368. # The Ruby bindings use SWIG >= 3.0.8 to generate code.
  369. AS_IF([test "x$SWIG" = x],
  370. [SR_APPEND([sr_ruby_missing], [', '], [SWIG])],
  371. [AS_VERSION_COMPARE($SWIG_VERSION, "3.0.8",
  372. [SR_APPEND([sr_ruby_missing], [', '], ['SWIG >= 3.0.8'])])])
  373. AS_IF([test -z "$sr_ruby_missing"],
  374. [BINDINGS_RUBY=$enable_ruby], [BINDINGS_RUBY=no])
  375. AM_CONDITIONAL([BINDINGS_RUBY], [test "x$BINDINGS_RUBY" = xyes])
  376. ####################
  377. ## Java bindings ##
  378. ####################
  379. AS_IF([test "x$BINDINGS_CXX" = xyes],
  380. [sr_java_missing=],
  381. [sr_java_missing='C++ bindings'])
  382. # The Java bindings use SWIG to generate code.
  383. AS_IF([test "x$SWIG" = x],
  384. [SR_APPEND([sr_java_missing], [', '], [SWIG])])
  385. # Find Java compiler and JNI includes for Java bindings.
  386. AC_CHECK_PROG([HAVE_JAVAC], [javac], [yes], [no])
  387. AS_IF([test "x$HAVE_JAVAC" = xno],
  388. [SR_APPEND([sr_java_missing], [', '], [JavaC])])
  389. AC_ARG_WITH([jni-include-path],
  390. [AS_HELP_STRING([[--with-jni-include-path=DIR-LIST (space-separated)]],
  391. [specify JNI include directories [default=detect]])],
  392. [JNI_INCLUDE_DIRS=" $withval"], [JNI_INCLUDE_DIRS=])
  393. JNI_CPPFLAGS=
  394. AS_IF([test "x$enable_java$HAVE_JAVAC" = xyesyes], [
  395. AX_PROG_JAVAC
  396. AS_IF([test -z "$JNI_INCLUDE_DIRS" && test "x$cross_compiling" != xyes], [
  397. ## Work around the totally broken logic in AX_JNI_INCLUDE_DIR:
  398. ## If we can find jni.h without any special search path, skip
  399. ## the execution of the broken macro to increase our chances of
  400. ## success.
  401. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <jni.h>]], [])],,
  402. [AX_JNI_INCLUDE_DIR])
  403. ])
  404. ])
  405. for sr_dir in $JNI_INCLUDE_DIRS
  406. do
  407. SR_APPEND([JNI_CPPFLAGS], ["-I$sr_dir"])
  408. done
  409. AC_SUBST([JNI_CPPFLAGS])
  410. sr_save_cppflags=$CPPFLAGS
  411. SR_APPEND([CPPFLAGS], [$JNI_CPPFLAGS])
  412. AC_CHECK_HEADER([jni.h],,
  413. [SR_APPEND([sr_java_missing], [', '], ['JNI headers'])])
  414. CPPFLAGS=$sr_save_cppflags
  415. AS_IF([test -z "$sr_java_missing"],
  416. [BINDINGS_JAVA=$enable_java], [BINDINGS_JAVA=no])
  417. AM_CONDITIONAL([BINDINGS_JAVA], [test "x$BINDINGS_JAVA" = xyes])
  418. ##############################
  419. ## Finalize configuration ##
  420. ##############################
  421. # Add mandatory dependencies to module list.
  422. SR_APPEND([SR_PKGLIBS], ['libzip >= 0.10'])
  423. AC_SUBST([SR_PKGLIBS])
  424. # Retrieve the compile and link flags for all modules combined.
  425. # Also, bail out at this point if any module dependency is not met.
  426. PKG_CHECK_MODULES([LIBSIGROK], [glib-2.0 >= 2.32.0 $SR_PKGLIBS])
  427. PKG_CHECK_MODULES([TESTS], [$SR_PKGLIBS_TESTS glib-2.0 $SR_PKGLIBS])
  428. # SR_PKGLIBS_CXX may be empty, so only invoke these checks when
  429. # the C++ bindings are enabled.
  430. AM_COND_IF([BINDINGS_CXX], [
  431. PKG_CHECK_MODULES([LIBSIGROKCXX], [$SR_PKGLIBS_CXX])
  432. PKG_CHECK_MODULES([PYSIGROK], [$SR_PKGLIBS_PYTHON $SR_PKGLIBS_CXX])
  433. PKG_CHECK_MODULES([RBSIGROK], [$SR_PKGLIBS_RUBY $SR_PKGLIBS_CXX], [AC_SUBST(RBSIGROK_EXTDIR, "lib/$($PKG_CONFIG --variable=sitearch $SR_PKGLIBS_RUBY)/$($PKG_CONFIG --variable=RUBY_BASE_NAME $SR_PKGLIBS_RUBY)/vendor_ruby/$($PKG_CONFIG --variable=ruby_version $SR_PKGLIBS_RUBY)")])
  434. ])
  435. # Check for specific libusb features, now that we know the CFLAGS.
  436. AC_LANG([C])
  437. sr_save_cflags=$CFLAGS
  438. sr_save_libs=$LIBS
  439. CFLAGS="$LIBSIGROK_CFLAGS $CFLAGS"
  440. LIBS="$LIBSIGROK_LIBS $LIBS"
  441. AC_CHECK_TYPES([libusb_os_handle],
  442. [sr_have_libusb_os_handle=yes], [sr_have_libusb_os_handle=no],
  443. [[#include <libusb.h>]])
  444. AC_CHECK_FUNCS([zip_discard])
  445. LIBS=$sr_save_libs
  446. CFLAGS=$sr_save_cflags
  447. AM_COND_IF([NEED_USB], [AS_CASE([$sr_have_libusb_os_handle:$host_os], [no:mingw*],
  448. [AC_MSG_ERROR([Windows builds require the event-abstraction branch of libusb])])])
  449. sr_glib_version=`$PKG_CONFIG --modversion glib-2.0 2>&AS_MESSAGE_LOG_FD`
  450. sr_libzip_version=`$PKG_CONFIG --modversion libzip 2>&AS_MESSAGE_LOG_FD`
  451. AC_DEFINE_UNQUOTED([CONF_LIBZIP_VERSION], ["$sr_libzip_version"],
  452. [Build-time version of libzip.])
  453. AC_DEFINE_UNQUOTED([CONF_HOST], ["$host"],
  454. [The canonical host libsigrok will run on.])
  455. AC_CONFIG_FILES([Makefile libsigrok.pc bindings/cxx/libsigrokcxx.pc])
  456. AC_OUTPUT
  457. # Prepare bindings report messages.
  458. m4_define([SR_PREPARE_BINDING_REPORT], [
  459. sr_report_$1=
  460. test -z "$sr_$1_missing" || sr_report_$1=" (missing: $sr_$1_missing)"
  461. test "x$enable_$1" = xyes || sr_report_$1=' (disabled)'
  462. ])
  463. m4_map_args([SR_PREPARE_BINDING_REPORT], [cxx], [python], [ruby], [java])
  464. cat >&AS_MESSAGE_FD <<_EOF
  465. libsigrok configuration summary:
  466. - Package version................. $SR_PACKAGE_VERSION
  467. - Library ABI version............. $SR_LIB_VERSION
  468. - Prefix.......................... $prefix
  469. - Building on..................... $build
  470. - Building for.................... $host
  471. - Building shared / static........ $enable_shared / $enable_static
  472. Compile configuration:
  473. - C compiler...................... $CC
  474. - C compiler version.............. $sr_cc_version
  475. - C compiler flags................ $CFLAGS
  476. - Additional C compiler flags..... $SR_EXTRA_CFLAGS
  477. - C compiler warnings............. $SR_WFLAGS
  478. - C++ compiler.................... $CXX
  479. - C++ compiler version............ $sr_cxx_version
  480. - C++ compiler flags.............. $CXXFLAGS
  481. - C++ compiler warnings........... $SR_WXXFLAGS
  482. - Linker flags.................... $LDFLAGS
  483. Detected libraries (required):
  484. - glib-2.0 >= 2.32.0.............. $sr_glib_version
  485. - libzip >= 0.10.................. $sr_libzip_version
  486. Detected libraries (optional):
  487. $sr_pkglibs_summary
  488. Enabled hardware drivers:
  489. $sr_driver_summary
  490. Enabled SCPI backends:
  491. - TCP............................. yes
  492. - RPC............................. $sr_cv_have_rpc
  493. - serial.......................... $sr_have_libserialport
  494. - VISA............................ $sr_have_librevisa
  495. - GPIB............................ $sr_have_libgpib
  496. - USBTMC.......................... $sr_have_libusb
  497. Enabled language bindings:
  498. - C++............................. $BINDINGS_CXX$sr_report_cxx
  499. - Python.......................... $BINDINGS_PYTHON$sr_report_python
  500. - Ruby............................ $BINDINGS_RUBY$sr_report_ruby
  501. - Java............................ $BINDINGS_JAVA$sr_report_java
  502. _EOF