2 AC_INIT([openocd], [0.11.0+dev],
3 [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
4 AC_CONFIG_SRCDIR([src/openocd.c])
7 m4_include([config_subdir.m4])dnl
9 # check for makeinfo before calling AM_INIT_AUTOMAKE
10 AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo])
11 AS_IF([test "x$MAKEINFO" = "x"], [
12 MAKEINFO='echo makeinfo missing; true'
13 AC_MSG_WARN([Info documentation will not be built.])
17 AM_INIT_AUTOMAKE([-Wall -Wno-portability dist-bzip2 dist-zip subdir-objects])
19 AC_CONFIG_HEADERS([config.h])
21 #include <helper/system.h>
22 #include <helper/types.h>
23 #include <helper/replacements.h>
28 # autoconf 2.70 obsoletes AC_PROG_CC_C99 and includes it in AC_PROG_CC
29 m4_version_prereq([2.70],[],[AC_PROG_CC_C99])
32 PKG_PROG_PKG_CONFIG([0.23])
34 dnl disable checks for C++, Fortran and GNU Java Compiler
35 m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
36 m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
37 m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
40 AC_SUBST([LIBTOOL_DEPS])
42 dnl configure checks required for Jim files (these are obsolete w/ C99)
46 AC_SEARCH_LIBS([ioperm], [ioperm])
47 AC_SEARCH_LIBS([dlopen], [dl])
48 AC_SEARCH_LIBS([openpty], [util])
50 AC_CHECK_HEADERS([sys/socket.h])
51 AC_CHECK_HEADERS([elf.h])
52 AC_CHECK_HEADERS([dirent.h])
53 AC_CHECK_HEADERS([fcntl.h])
54 AC_CHECK_HEADERS([malloc.h])
55 AC_CHECK_HEADERS([netdb.h])
56 AC_CHECK_HEADERS([poll.h])
57 AC_CHECK_HEADERS([pthread.h])
58 AC_CHECK_HEADERS([strings.h])
59 AC_CHECK_HEADERS([sys/ioctl.h])
60 AC_CHECK_HEADERS([sys/param.h])
61 AC_CHECK_HEADERS([sys/select.h])
62 AC_CHECK_HEADERS([sys/stat.h])
63 AC_CHECK_HEADERS([sys/sysctl.h])
64 AC_CHECK_HEADERS([sys/time.h])
65 AC_CHECK_HEADERS([sys/types.h])
66 AC_CHECK_HEADERS([unistd.h])
67 AC_CHECK_HEADERS([arpa/inet.h ifaddrs.h netinet/in.h netinet/tcp.h net/if.h], [], [], [dnl
77 #ifdef HAVE_SYS_SOCKET_H
78 # include <sys/socket.h>
87 AC_CHECK_FUNCS([strndup])
88 AC_CHECK_FUNCS([strnlen])
89 AC_CHECK_FUNCS([gettimeofday])
90 AC_CHECK_FUNCS([usleep])
91 AC_CHECK_FUNCS([vasprintf])
92 AC_CHECK_FUNCS([realpath])
94 # guess-rev.sh only exists in the repository, not in the released archives
95 AC_MSG_CHECKING([whether to build a release])
96 AS_IF([test -x "$srcdir/guess-rev.sh"], [
101 AC_MSG_RESULT([$build_release])
104 # 1st column -- configure option
105 # 2nd column -- description
106 # 3rd column -- symbol used for both config.h and automake
107 m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
108 m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
109 m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
110 m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
111 m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
113 m4_define([USB1_ADAPTERS],
114 [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
115 [[stlink], [ST-Link Programmer], [HLADAPTER_STLINK]],
116 [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
117 [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
118 [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
119 [[ft232r], [Bitbang mode of FT232R based devices], [FT232R]],
120 [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]],
121 [[xds110], [TI XDS110 Debug Probe], [XDS110]],
122 [[cmsis_dap_v2], [CMSIS-DAP v2 Compliant Debugger], [CMSIS_DAP_USB]],
123 [[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
124 [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
125 [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]],
126 [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
127 [[usbprog], [USBProg JTAG Programmer], [USBPROG]],
128 [[aice], [Andes JTAG Programmer], [AICE]]])
130 m4_define([HIDAPI_ADAPTERS],
131 [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP_HID]],
132 [[nulink], [Nu-Link Programmer], [HLADAPTER_NULINK]]])
134 m4_define([HIDAPI_USB1_ADAPTERS],
135 [[[kitprog], [Cypress KitProg Programmer], [KITPROG]]])
137 m4_define([LIBFTDI_ADAPTERS],
138 [[[usb_blaster], [Altera USB-Blaster Compatible], [USB_BLASTER]],
139 [[presto], [ASIX Presto Adapter], [PRESTO]]])
141 m4_define([LIBFTDI_USB1_ADAPTERS],
142 [[[openjtag], [OpenJTAG Adapter], [OPENJTAG]]])
144 m4_define([LIBGPIOD_ADAPTERS],
145 [[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]])
147 m4_define([LIBJAYLINK_ADAPTERS],
148 [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
150 m4_define([PCIE_ADAPTERS],
151 [[[xlnx_pcie_xvc], [Xilinx XVC/PCIe], [XLNX_PCIE_XVC]]])
153 m4_define([OPTIONAL_LIBRARIES],
154 [[[capstone], [Use Capstone disassembly framework], []]])
156 AC_ARG_ENABLE([doxygen-html],
157 AS_HELP_STRING([--disable-doxygen-html],
158 [Disable building Doxygen manual as HTML.]),
159 [doxygen_as_html=$enableval], [doxygen_as_html=yes])
160 AC_SUBST([doxygen_as_html])
161 AC_MSG_CHECKING([whether to build Doxygen as HTML])
162 AC_MSG_RESULT([$doxygen_as_html])
164 AC_ARG_ENABLE([doxygen-pdf],
165 AS_HELP_STRING([--enable-doxygen-pdf],
166 [Enable building Doxygen manual as PDF.]),
167 [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
168 AC_SUBST([doxygen_as_pdf])
169 AC_MSG_CHECKING([whether to build Doxygen as PDF])
170 AC_MSG_RESULT([$doxygen_as_pdf])
172 AC_ARG_ENABLE([gccwarnings],
173 AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
174 [gcc_warnings=$enableval], [gcc_warnings=yes])
176 AC_ARG_ENABLE([wextra],
177 AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
178 [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
180 AC_ARG_ENABLE([werror],
181 AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
182 [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
184 # set default verbose options, overridden by following options
188 AC_ARG_ENABLE([verbose],
189 AS_HELP_STRING([--enable-verbose],
190 [Enable verbose JTAG I/O messages (for debugging).]),
192 debug_usb_io=$enableval
193 debug_usb_comms=$enableval
196 AC_ARG_ENABLE([verbose_usb_io],
197 AS_HELP_STRING([--enable-verbose-usb-io],
198 [Enable verbose USB I/O messages (for debugging)]),
199 [debug_usb_io=$enableval], [])
201 AC_ARG_ENABLE([verbose_usb_comms],
202 AS_HELP_STRING([--enable-verbose-usb-comms],
203 [Enable verbose USB communication messages (for debugging)]),
204 [debug_usb_comms=$enableval], [])
206 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
207 AC_MSG_RESULT([$debug_usb_io])
208 AS_IF([test "x$debug_usb_io" = "xyes"], [
209 AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
212 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
213 AC_MSG_RESULT([$debug_usb_comms])
214 AS_IF([test "x$debug_usb_comms" = "xyes"], [
215 AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
219 AC_ARG_ENABLE([malloc_logging],
220 AS_HELP_STRING([--enable-malloc-logging],
221 [Include free space in logging messages (requires malloc.h).]),
222 [debug_malloc=$enableval], [])
224 AC_MSG_CHECKING([whether to enable malloc free space logging]);
225 AC_MSG_RESULT([$debug_malloc])
226 AS_IF([test "x$debug_malloc" = "xyes"], [
227 AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
230 AC_ARG_ENABLE([dummy],
231 AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
232 [build_dummy=$enableval], [build_dummy=no])
234 AC_ARG_ENABLE([rshim],
235 AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
236 [build_rshim=$enableval], [build_rshim=no])
238 m4_define([AC_ARG_ADAPTERS], [
239 m4_foreach([adapter], [$1],
240 [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
241 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
242 [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
243 [], [ADAPTER_VAR([adapter])=$2])
250 HIDAPI_USB1_ADAPTERS,
252 LIBFTDI_USB1_ADAPTERS
257 AC_ARG_ENABLE([parport],
258 AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
259 [build_parport=$enableval], [build_parport=no])
261 AC_ARG_ENABLE([parport_ppdev],
262 AS_HELP_STRING([--disable-parport-ppdev],
263 [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
264 [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
266 AC_ARG_ENABLE([parport_giveio],
267 AS_HELP_STRING([--enable-parport-giveio],
268 [Enable use of giveio for parport (for CygWin only)]),
269 [parport_use_giveio=$enableval], [parport_use_giveio=])
271 AC_ARG_ENABLE([jtag_vpi],
272 AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
273 [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
275 AC_ARG_ENABLE([jtag_dpi],
276 AS_HELP_STRING([--enable-jtag_dpi], [Enable building support for JTAG DPI]),
277 [build_jtag_dpi=$enableval], [build_jtag_dpi=no])
279 AC_ARG_ENABLE([amtjtagaccel],
280 AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
281 [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
283 AS_CASE(["${host_cpu}"],
285 AC_ARG_ENABLE([bcm2835gpio],
286 AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
287 [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
288 AC_ARG_ENABLE([imx_gpio],
289 AS_HELP_STRING([--enable-imx_gpio], [Enable building support for bitbanging on NXP IMX processors]),
290 [build_imx_gpio=$enableval], [build_imx_gpio=no])
297 AS_CASE(["${host_cpu}"],
299 AC_ARG_ENABLE([ep93xx],
300 AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
301 [build_ep93xx=$enableval], [build_ep93xx=no])
303 AC_ARG_ENABLE([at91rm9200],
304 AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
305 [build_at91rm9200=$enableval], [build_at91rm9200=no])
312 AC_ARG_ENABLE([gw16012],
313 AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
314 [build_gw16012=$enableval], [build_gw16012=no])
316 AC_ARG_ENABLE([buspirate],
317 AS_HELP_STRING([--enable-buspirate], [Enable building support for the Buspirate]),
318 [build_buspirate=$enableval], [build_buspirate=no])
320 AC_ARG_ENABLE([sysfsgpio],
321 AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
322 [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
324 AC_ARG_ENABLE([xlnx_pcie_xvc],
325 AS_HELP_STRING([--enable-xlnx-pcie-xvc], [Enable building support for Xilinx XVC/PCIe.]),
326 [build_xlnx_pcie_xvc=$enableval], [build_xlnx_pcie_xvc=no])
331 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
332 AC_MSG_ERROR([sysfsgpio is only available on linux])
335 AS_IF([test "x$enable_linuxgpiod" = "xyes"], [
336 AC_MSG_ERROR([linuxgpiod is only available on linux])
339 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
340 AC_MSG_ERROR([xlnx_pcie_xvc is only available on linux])
343 AS_CASE([$host_os], [freebsd*], [],
345 AS_IF([test "x$build_rshim" = "xyes"], [
346 AC_MSG_ERROR([build_rshim is only available on linux or freebsd])
351 AC_ARG_ENABLE([internal-jimtcl],
352 AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
353 [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
355 AC_ARG_ENABLE([internal-libjaylink],
356 AS_HELP_STRING([--disable-internal-libjaylink],
357 [Disable building internal libjaylink]),
358 [use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
360 AC_ARG_ENABLE([remote-bitbang],
361 AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
362 [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
364 AS_CASE(["${host_cpu}"],
367 AS_IF([test "x$parport_use_ppdev" = "xno"], [
368 AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
370 parport_use_ppdev=yes
378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
379 [is_mingw=yes],[is_mingw=no])
380 AS_IF([test "x$is_mingw" = "xyes"], [
381 AS_IF([test "x$parport_use_giveio" = "xno"], [
382 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
384 parport_use_giveio=yes
388 # sys/io.h needed under cygwin for parport access
389 AS_IF([test "x$build_parport" = "xyes"], [
390 AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
394 [*-mingw* | *-msys*], [
399 AS_IF([test "x$parport_use_giveio" = "xno"], [
400 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
402 parport_use_giveio=yes
404 AS_IF([test "x$build_buspirate" = "xyes"], [
405 AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
408 AC_SUBST([HOST_CPPFLAGS], [-D__USE_MINGW_ANSI_STDIO])
413 AS_IF([test "x$parport_use_giveio" = "xyes"], [
414 AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
416 parport_use_giveio=no
419 AS_IF([test "x$parport_use_giveio" = "xyes"], [
420 AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
422 parport_use_giveio=no
425 AS_IF([test "x$is_cygwin" = "xyes"], [
426 AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
428 AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
431 AS_IF([test "x$is_mingw" = "xyes"], [
432 AC_DEFINE([IS_MINGW], [1], [1 if building for Mingw.])
434 AC_DEFINE([IS_MINGW], [0], [0 if not building for Mingw.])
437 AS_IF([test "x$is_win32" = "xyes"], [
438 AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
440 AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
443 AS_IF([test "x$is_darwin" = "xyes"], [
444 AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
446 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
449 AS_IF([test "x$build_parport" = "xyes"], [
451 AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
453 AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
456 AS_IF([test "x$build_rshim" = "xyes"], [
457 AC_DEFINE([BUILD_RSHIM], [1], [1 if you want to debug BlueField SoC via rshim.])
459 AC_DEFINE([BUILD_RSHIM], [0], [0 if you don't want to debug BlueField SoC via rshim.])
462 AS_IF([test "x$build_dummy" = "xyes"], [
464 AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
466 AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
469 AS_IF([test "x$build_ep93xx" = "xyes"], [
471 AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
473 AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
476 AS_IF([test "x$build_at91rm9200" = "xyes"], [
478 AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
480 AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
483 AS_IF([test "x$build_bcm2835gpio" = "xyes"], [
485 AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
487 AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
490 AS_IF([test "x$build_imx_gpio" = "xyes"], [
492 AC_DEFINE([BUILD_IMX_GPIO], [1], [1 if you want imx_gpio.])
494 AC_DEFINE([BUILD_IMX_GPIO], [0], [0 if you don't want imx_gpio.])
497 AS_IF([test "x$parport_use_ppdev" = "xyes"], [
498 AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
500 AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
503 AS_IF([test "x$parport_use_giveio" = "xyes"], [
504 AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
506 AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
509 AS_IF([test "x$build_jtag_vpi" = "xyes"], [
510 AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
512 AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
515 AS_IF([test "x$build_jtag_dpi" = "xyes"], [
516 AC_DEFINE([BUILD_JTAG_DPI], [1], [1 if you want JTAG DPI.])
518 AC_DEFINE([BUILD_JTAG_DPI], [0], [0 if you don't want JTAG DPI.])
522 AS_IF([test "x$build_amtjtagaccel" = "xyes"], [
523 AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
525 AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
528 AS_IF([test "x$build_gw16012" = "xyes"], [
529 AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
531 AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
534 AS_IF([test "x$build_buspirate" = "xyes"], [
535 AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
537 AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
540 AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
541 AS_IF([test -f "$srcdir/jimtcl/configure.ac"], [
542 AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
544 AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
548 AS_IF([test "x$build_remote_bitbang" = "xyes"], [
550 AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
552 AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
555 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
557 AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
559 AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
562 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
563 build_xlnx_pcie_xvc=yes
564 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [1], [1 if you want the Xilinx XVC/PCIe driver.])
566 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [0], [0 if you don't want Xilinx XVC/PCIe driver.])
569 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
571 AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
572 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
573 [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
574 [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
575 LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
576 AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
577 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
578 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
581 AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
584 AC_ARG_WITH([capstone],
585 AS_HELP_STRING([--with-capstone], [Use Capstone disassembly library (default=auto)])
587 enable_capstone=$withval
592 AS_IF([test "x$enable_capstone" != xno], [
593 PKG_CHECK_MODULES([CAPSTONE], [capstone], [
594 AC_DEFINE([HAVE_CAPSTONE], [1], [1 if you have Capstone disassembly framework.])
596 AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.])
597 if test "x$enable_capstone" != xauto; then
598 AC_MSG_ERROR([--with-capstone was given, but test for Capstone failed])
604 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
605 PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
613 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [
615 PKG_CHECK_EXISTS([libftdi1 >= 1.5],
616 [AC_DEFINE([HAVE_LIBFTDI_TCIOFLUSH], [1], [Define if your libftdi has ftdi_tcioflush()])])
618 PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
621 PKG_CHECK_MODULES([LIBGPIOD], [libgpiod], [use_libgpiod=yes], [use_libgpiod=no])
623 PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2],
624 [use_libjaylink=yes], [use_libjaylink=no])
626 m4_define([PROCESS_ADAPTERS], [
627 m4_foreach([adapter], [$1], [
629 AS_IF([test "x$ADAPTER_VAR([adapter])" != "xno"], [
630 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
632 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
635 AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [
636 AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
638 ADAPTER_VAR([adapter])=no
640 AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test "x$ADAPTER_VAR([adapter])" != "xno"])
644 PROCESS_ADAPTERS([USB1_ADAPTERS], ["x$use_libusb1" = "xyes"], [libusb-1.x])
645 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], ["x$use_hidapi" = "xyes"], [hidapi])
646 PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libusb1" = "xyes"], [hidapi and libusb-1.x])
647 PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
648 PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
649 PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [libgpiod])
650 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2])
652 AS_IF([test "x$enable_linuxgpiod" != "xno"], [
656 AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enable_nulink" != "xno"], [
657 AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
658 AM_CONDITIONAL([HLADAPTER], [true])
660 AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
661 AM_CONDITIONAL([HLADAPTER], [false])
663 AM_CONDITIONAL([HLADAPTER_STLINK], [test "x$enable_stlink" != "xno"])
664 AM_CONDITIONAL([HLADAPTER_ICDI], [test "x$enable_ti_icdi" != "xno"])
665 AM_CONDITIONAL([HLADAPTER_NULINK], [test "x$enable_nulink" != "xno"])
667 AS_IF([test "x$enable_jlink" != "xno"], [
668 AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
669 AS_IF([test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"], [
670 AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
671 [--enable-subproject-build])
673 AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
678 # Presto needs the bitq module
679 AS_IF([test "x$enable_presto" != "xno"], [
683 AM_CONDITIONAL([RELEASE], [test "x$build_release" = "xyes"])
684 AM_CONDITIONAL([PARPORT], [test "x$build_parport" = "xyes"])
685 AM_CONDITIONAL([DUMMY], [test "x$build_dummy" = "xyes"])
686 AM_CONDITIONAL([GIVEIO], [test "x$parport_use_giveio" = "xyes"])
687 AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
688 AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
689 AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
690 AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
691 AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
692 AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes" -o "x$build_jtag_vpi" = "xyes"])
693 AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes" -o "x$build_jtag_dpi" = "xyes"])
694 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
695 AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
696 AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
697 AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
698 AM_CONDITIONAL([BUSPIRATE], [test "x$build_buspirate" = "xyes"])
699 AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
700 AM_CONDITIONAL([XLNX_PCIE_XVC], [test "x$build_xlnx_pcie_xvc" = "xyes"])
701 AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
702 AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
703 AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"])
704 AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "xyes"])
705 AM_CONDITIONAL([IS_DARWIN], [test "x$is_darwin" = "xyes"])
706 AM_CONDITIONAL([BITQ], [test "x$build_bitq" = "xyes"])
707 AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
708 AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"])
709 AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"])
710 AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
711 AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
712 AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
714 AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
715 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
717 # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
718 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
719 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
723 ]], [[char **ep = environ;]]
730 # Possibility #2: can environ be found in an available library?
731 AC_MSG_CHECKING([for extern environ])
732 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
733 extern char **environ;
734 ]], [[char **ep = environ;]]
736 AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
741 AC_MSG_RESULT([${has_environ}])
744 AS_IF([test "x${has_environ}" != "xyes" ], [
745 AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
748 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
750 # set default gcc warnings
751 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
752 AS_IF([test "x${gcc_wextra}" = "xyes"], [
753 GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
754 GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
755 GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
756 GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
757 GCC_WARNINGS="${GCC_WARNINGS} -Wpointer-arith"
759 AS_IF([test "x${gcc_werror}" = "xyes"], [
760 GCC_WARNINGS="${GCC_WARNINGS} -Werror"
763 # override default gcc cflags
764 AS_IF([test "x$gcc_warnings" = "xyes"], [
765 AC_SUBST([GCC_WARNINGS], [$GCC_WARNINGS])
768 AC_SUBST(EXTRA_DIST_NEWS, ["$(echo $srcdir/NEWS-*)"])
777 echo OpenOCD configuration summary
778 echo --------------------------------------------------
779 m4_foreach([adapter], [USB1_ADAPTERS,
780 HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS,
781 LIBFTDI_USB1_ADAPTERS,
783 LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS,
785 [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
786 AS_CASE([$ADAPTER_VAR([adapter])],
788 echo "$s"yes '(auto)'