1 # SPDX-License-Identifier: GPL-2.0-or-later
4 AC_INIT([openocd], [0.12.0+dev],
5 [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
6 AC_CONFIG_SRCDIR([src/openocd.c])
7 AC_CONFIG_AUX_DIR([build-aux])
9 m4_include([config_subdir.m4])dnl
11 # check for makeinfo before calling AM_INIT_AUTOMAKE
12 AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo])
13 AS_IF([test "x$MAKEINFO" = "x"], [
14 MAKEINFO='echo makeinfo missing; true'
15 AC_MSG_WARN([Info documentation will not be built.])
19 AM_INIT_AUTOMAKE([-Wall -Wno-portability dist-bzip2 dist-zip subdir-objects])
21 AC_CONFIG_HEADERS([config.h])
25 # autoconf 2.70 obsoletes AC_PROG_CC_C99 and includes it in AC_PROG_CC
26 m4_version_prereq([2.70],[],[AC_PROG_CC_C99])
30 # If macro PKG_PROG_PKG_CONFIG is not available, Autoconf generates a misleading error message,
31 # so check for existence first, and otherwise provide helpful advice.
32 m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal(m4_normalize([
33 Macro PKG_PROG_PKG_CONFIG is not available.
34 It is usually defined in file pkg.m4 provided by package pkg-config.]))])
35 PKG_PROG_PKG_CONFIG([0.23])
37 dnl disable checks for C++, Fortran and GNU Java Compiler
38 m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
39 m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
40 m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
43 AC_SUBST([LIBTOOL_DEPS])
45 dnl configure checks required for Jim files (these are obsolete w/ C99)
49 AC_SEARCH_LIBS([ioperm], [ioperm])
50 AC_SEARCH_LIBS([dlopen], [dl])
51 AC_SEARCH_LIBS([openpty], [util])
53 AC_CHECK_HEADERS([sys/socket.h])
54 AC_CHECK_HEADERS([elf.h])
55 AC_EGREP_HEADER(Elf64_Ehdr, [elf.h], [
56 AC_DEFINE([HAVE_ELF64], [1], [Define to 1 if the system has the type `Elf64_Ehdr'.])
58 AC_CHECK_HEADERS([fcntl.h])
59 AC_CHECK_HEADERS([malloc.h])
60 AC_CHECK_HEADERS([netdb.h])
61 AC_CHECK_HEADERS([poll.h])
62 AC_CHECK_HEADERS([strings.h])
63 AC_CHECK_HEADERS([sys/ioctl.h])
64 AC_CHECK_HEADERS([sys/param.h])
65 AC_CHECK_HEADERS([sys/select.h])
66 AC_CHECK_HEADERS([sys/stat.h])
67 AC_CHECK_HEADERS([sys/sysctl.h])
68 AC_CHECK_HEADERS([sys/time.h])
69 AC_CHECK_HEADERS([sys/types.h])
70 AC_CHECK_HEADERS([unistd.h])
71 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h netinet/tcp.h], [], [], [dnl
81 #ifdef HAVE_SYS_SOCKET_H
82 # include <sys/socket.h>
91 AC_CHECK_FUNCS([strndup])
92 AC_CHECK_FUNCS([strnlen])
93 AC_CHECK_FUNCS([gettimeofday])
94 AC_CHECK_FUNCS([usleep])
95 AC_CHECK_FUNCS([realpath])
97 # guess-rev.sh only exists in the repository, not in the released archives
98 AC_MSG_CHECKING([whether to build a release])
99 AS_IF([test -x "$srcdir/guess-rev.sh"], [
104 AC_MSG_RESULT([$build_release])
107 # 1st column -- configure option
108 # 2nd column -- description
109 # 3rd column -- symbol used for both config.h and automake
110 m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
111 m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
112 m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
113 m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
114 m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
116 m4_define([USB1_ADAPTERS],
117 [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
118 [[stlink], [ST-Link Programmer], [HLADAPTER_STLINK]],
119 [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
120 [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
121 [[angie], [ANGIE Adapter], [ANGIE]],
122 [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
123 [[ft232r], [Bitbang mode of FT232R based devices], [FT232R]],
124 [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]],
125 [[xds110], [TI XDS110 Debug Probe], [XDS110]],
126 [[cmsis_dap_v2], [CMSIS-DAP v2 Compliant Debugger], [CMSIS_DAP_USB]],
127 [[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
128 [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
129 [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]],
130 [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
131 [[usbprog], [USBProg JTAG Programmer], [USBPROG]],
132 [[esp_usb_jtag], [Espressif JTAG Programmer], [ESP_USB_JTAG]]])
134 m4_define([HIDAPI_ADAPTERS],
135 [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP_HID]],
136 [[nulink], [Nu-Link Programmer], [HLADAPTER_NULINK]]])
138 m4_define([HIDAPI_USB1_ADAPTERS],
139 [[[kitprog], [Cypress KitProg Programmer], [KITPROG]]])
141 m4_define([LIBFTDI_ADAPTERS],
142 [[[usb_blaster], [Altera USB-Blaster Compatible], [USB_BLASTER]],
143 [[presto], [ASIX Presto Adapter], [PRESTO]]])
145 m4_define([LIBFTDI_USB1_ADAPTERS],
146 [[[openjtag], [OpenJTAG Adapter], [OPENJTAG]]])
148 m4_define([LIBGPIOD_ADAPTERS],
149 [[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]])
151 m4_define([LIBJAYLINK_ADAPTERS],
152 [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
154 m4_define([PCIE_ADAPTERS],
155 [[[xlnx_pcie_xvc], [Xilinx XVC/PCIe], [XLNX_PCIE_XVC]]])
157 m4_define([SERIAL_PORT_ADAPTERS],
158 [[[buspirate], [Bus Pirate], [BUS_PIRATE]]])
160 m4_define([OPTIONAL_LIBRARIES],
161 [[[capstone], [Use Capstone disassembly framework], []]])
163 AC_ARG_ENABLE([doxygen-html],
164 AS_HELP_STRING([--disable-doxygen-html],
165 [Disable building Doxygen manual as HTML.]),
166 [doxygen_as_html=$enableval], [doxygen_as_html=yes])
167 AC_SUBST([doxygen_as_html])
168 AC_MSG_CHECKING([whether to build Doxygen as HTML])
169 AC_MSG_RESULT([$doxygen_as_html])
171 AC_ARG_ENABLE([doxygen-pdf],
172 AS_HELP_STRING([--enable-doxygen-pdf],
173 [Enable building Doxygen manual as PDF.]),
174 [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
175 AC_SUBST([doxygen_as_pdf])
176 AC_MSG_CHECKING([whether to build Doxygen as PDF])
177 AC_MSG_RESULT([$doxygen_as_pdf])
179 AC_ARG_ENABLE([gccwarnings],
180 AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
181 [gcc_warnings=$enableval], [gcc_warnings=yes])
183 AC_ARG_ENABLE([wextra],
184 AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
185 [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
187 AC_ARG_ENABLE([werror],
188 AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
189 [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
191 # set default verbose options, overridden by following options
195 AC_ARG_ENABLE([verbose],
196 AS_HELP_STRING([--enable-verbose],
197 [Enable verbose JTAG I/O messages (for debugging).]),
199 debug_usb_io=$enableval
200 debug_usb_comms=$enableval
203 AC_ARG_ENABLE([verbose_usb_io],
204 AS_HELP_STRING([--enable-verbose-usb-io],
205 [Enable verbose USB I/O messages (for debugging)]),
206 [debug_usb_io=$enableval], [])
208 AC_ARG_ENABLE([verbose_usb_comms],
209 AS_HELP_STRING([--enable-verbose-usb-comms],
210 [Enable verbose USB communication messages (for debugging)]),
211 [debug_usb_comms=$enableval], [])
213 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
214 AC_MSG_RESULT([$debug_usb_io])
215 AS_IF([test "x$debug_usb_io" = "xyes"], [
216 AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
219 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
220 AC_MSG_RESULT([$debug_usb_comms])
221 AS_IF([test "x$debug_usb_comms" = "xyes"], [
222 AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
226 AC_ARG_ENABLE([malloc_logging],
227 AS_HELP_STRING([--enable-malloc-logging],
228 [Include free space in logging messages (requires malloc.h).]),
229 [debug_malloc=$enableval], [])
231 AC_MSG_CHECKING([whether to enable malloc free space logging]);
232 AC_MSG_RESULT([$debug_malloc])
233 AS_IF([test "x$debug_malloc" = "xyes"], [
234 AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
237 AC_ARG_ENABLE([dummy],
238 AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
239 [build_dummy=$enableval], [build_dummy=no])
241 AC_ARG_ENABLE([rshim],
242 AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
243 [build_rshim=$enableval], [build_rshim=no])
245 AC_ARG_ENABLE([dmem],
246 AS_HELP_STRING([--enable-dmem], [Enable building the dmem driver]),
247 [build_dmem=$enableval], [build_dmem=no])
249 m4_define([AC_ARG_ADAPTERS], [
250 m4_foreach([adapter], [$1],
251 [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
252 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
253 [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
254 [], [ADAPTER_VAR([adapter])=$2])
261 HIDAPI_USB1_ADAPTERS,
263 LIBFTDI_USB1_ADAPTERS
265 SERIAL_PORT_ADAPTERS,
269 AC_ARG_ENABLE([parport],
270 AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
271 [build_parport=$enableval], [build_parport=no])
273 AC_ARG_ENABLE([parport_ppdev],
274 AS_HELP_STRING([--disable-parport-ppdev],
275 [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
276 [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
278 AC_ARG_ENABLE([parport_giveio],
279 AS_HELP_STRING([--enable-parport-giveio],
280 [Enable use of giveio for parport (for CygWin only)]),
281 [parport_use_giveio=$enableval], [parport_use_giveio=])
283 AC_ARG_ENABLE([jtag_vpi],
284 AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
285 [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
287 AC_ARG_ENABLE([vdebug],
288 AS_HELP_STRING([--enable-vdebug], [Enable building support for Cadence Virtual Debug Interface]),
289 [build_vdebug=$enableval], [build_vdebug=no])
291 AC_ARG_ENABLE([jtag_dpi],
292 AS_HELP_STRING([--enable-jtag_dpi], [Enable building support for JTAG DPI]),
293 [build_jtag_dpi=$enableval], [build_jtag_dpi=no])
295 AC_ARG_ENABLE([amtjtagaccel],
296 AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
297 [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
299 AS_CASE(["${host_cpu}"],
301 AC_ARG_ENABLE([bcm2835gpio],
302 AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
303 [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
304 AC_ARG_ENABLE([imx_gpio],
305 AS_HELP_STRING([--enable-imx_gpio], [Enable building support for bitbanging on NXP IMX processors]),
306 [build_imx_gpio=$enableval], [build_imx_gpio=no])
307 AC_ARG_ENABLE([am335xgpio],
308 AS_HELP_STRING([--enable-am335xgpio], [Enable building support for bitbanging on AM335x (as found in Beaglebones)]),
309 [build_am335xgpio=$enableval], [build_am335xgpio=no])
317 AS_CASE(["${host_cpu}"],
319 AC_ARG_ENABLE([ep93xx],
320 AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
321 [build_ep93xx=$enableval], [build_ep93xx=no])
323 AC_ARG_ENABLE([at91rm9200],
324 AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
325 [build_at91rm9200=$enableval], [build_at91rm9200=no])
332 AC_ARG_ENABLE([gw16012],
333 AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
334 [build_gw16012=$enableval], [build_gw16012=no])
336 AC_ARG_ENABLE([sysfsgpio],
337 AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
338 [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
340 AC_ARG_ENABLE([xlnx_pcie_xvc],
341 AS_HELP_STRING([--enable-xlnx-pcie-xvc], [Enable building support for Xilinx XVC/PCIe.]),
342 [build_xlnx_pcie_xvc=$enableval], [build_xlnx_pcie_xvc=no])
347 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
348 AC_MSG_ERROR([sysfsgpio is only available on linux])
351 AS_IF([test "x$enable_linuxgpiod" = "xyes"], [
352 AC_MSG_ERROR([linuxgpiod is only available on linux])
355 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
356 AC_MSG_ERROR([xlnx_pcie_xvc is only available on linux])
359 AS_CASE([$host_os], [freebsd*], [],
361 AS_IF([test "x$build_rshim" = "xyes"], [
362 AC_MSG_ERROR([build_rshim is only available on linux or freebsd])
366 AS_IF([test "x$build_dmem" = "xyes"], [
367 AC_MSG_ERROR([dmem is only available on linux])
371 AC_ARG_ENABLE([internal-jimtcl],
372 AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
373 [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
375 AC_ARG_ENABLE([jimtcl-maintainer],
376 AS_HELP_STRING([--enable-jimtcl-maintainer], [Enable maintainer mode when building internal jimtcl]),
377 [use_internal_jimtcl_maintainer=$enableval], [use_internal_jimtcl_maintainer=no])
379 AC_ARG_ENABLE([internal-libjaylink],
380 AS_HELP_STRING([--enable-internal-libjaylink],
381 [Enable building internal libjaylink]),
382 [use_internal_libjaylink=$enableval], [use_internal_libjaylink=no])
384 AC_ARG_ENABLE([remote-bitbang],
385 AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
386 [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
388 AS_CASE(["${host_cpu}"],
391 AS_IF([test "x$parport_use_ppdev" = "xno"], [
392 AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
394 parport_use_ppdev=yes
402 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
403 [is_mingw=yes],[is_mingw=no])
404 AS_IF([test "x$is_mingw" = "xyes"], [
405 AS_IF([test "x$parport_use_giveio" = "xno"], [
406 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
408 parport_use_giveio=yes
412 # sys/io.h needed under cygwin for parport access
413 AS_IF([test "x$build_parport" = "xyes"], [
414 AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
418 [*-mingw* | *-msys*], [
423 AS_IF([test "x$parport_use_giveio" = "xno"], [
424 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
426 parport_use_giveio=yes
428 AS_IF([test "x$enable_buspirate" = "xyes"], [
429 AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
432 # In case enable_buspirate=auto, make sure it will not be built.
435 AC_SUBST([HOST_CPPFLAGS], [-D__USE_MINGW_ANSI_STDIO])
440 AS_IF([test "x$parport_use_giveio" = "xyes"], [
441 AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
443 parport_use_giveio=no
446 AS_IF([test "x$parport_use_giveio" = "xyes"], [
447 AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
449 parport_use_giveio=no
452 AS_IF([test "x$is_cygwin" = "xyes"], [
453 AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
455 AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
458 AS_IF([test "x$is_mingw" = "xyes"], [
459 AC_DEFINE([IS_MINGW], [1], [1 if building for Mingw.])
461 AC_DEFINE([IS_MINGW], [0], [0 if not building for Mingw.])
464 AS_IF([test "x$is_win32" = "xyes"], [
465 AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
467 AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
470 AS_IF([test "x$is_darwin" = "xyes"], [
471 AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
473 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
476 AS_IF([test "x$build_parport" = "xyes"], [
478 AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
480 AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
483 AS_IF([test "x$build_rshim" = "xyes"], [
484 AC_DEFINE([BUILD_RSHIM], [1], [1 if you want to debug BlueField SoC via rshim.])
486 AC_DEFINE([BUILD_RSHIM], [0], [0 if you don't want to debug BlueField SoC via rshim.])
489 AS_IF([test "x$build_dmem" = "xyes"], [
490 AC_DEFINE([BUILD_DMEM], [1], [1 if you want to debug via Direct Mem.])
492 AC_DEFINE([BUILD_DMEM], [0], [0 if you don't want to debug via Direct Mem.])
495 AS_IF([test "x$build_dummy" = "xyes"], [
497 AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
499 AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
502 AS_IF([test "x$build_ep93xx" = "xyes"], [
504 AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
506 AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
509 AS_IF([test "x$build_at91rm9200" = "xyes"], [
511 AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
513 AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
516 AS_IF([test "x$build_bcm2835gpio" = "xyes"], [
518 AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
520 AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
523 AS_IF([test "x$build_imx_gpio" = "xyes"], [
525 AC_DEFINE([BUILD_IMX_GPIO], [1], [1 if you want imx_gpio.])
527 AC_DEFINE([BUILD_IMX_GPIO], [0], [0 if you don't want imx_gpio.])
530 AS_IF([test "x$build_am335xgpio" = "xyes"], [
532 AC_DEFINE([BUILD_AM335XGPIO], [1], [1 if you want am335xgpio.])
534 AC_DEFINE([BUILD_AM335XGPIO], [0], [0 if you don't want am335xgpio.])
537 AS_IF([test "x$parport_use_ppdev" = "xyes"], [
538 AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
540 AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
543 AS_IF([test "x$parport_use_giveio" = "xyes"], [
544 AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
546 AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
549 AS_IF([test "x$build_jtag_vpi" = "xyes"], [
550 AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
552 AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
555 AS_IF([test "x$build_vdebug" = "xyes"], [
556 AC_DEFINE([BUILD_VDEBUG], [1], [1 if you want Cadence vdebug interface.])
558 AC_DEFINE([BUILD_VDEBUG], [0], [0 if you don't want Cadence vdebug interface.])
561 AS_IF([test "x$build_jtag_dpi" = "xyes"], [
562 AC_DEFINE([BUILD_JTAG_DPI], [1], [1 if you want JTAG DPI.])
564 AC_DEFINE([BUILD_JTAG_DPI], [0], [0 if you don't want JTAG DPI.])
568 AS_IF([test "x$build_amtjtagaccel" = "xyes"], [
569 AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
571 AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
574 AS_IF([test "x$build_gw16012" = "xyes"], [
575 AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
577 AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
580 AS_IF([test "x$enable_buspirate" != "xno"], [
581 AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
583 AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
586 AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
587 AS_IF([test -f "$srcdir/jimtcl/configure"], [
588 AS_IF([test "x$use_internal_jimtcl_maintainer" = "xyes"], [
589 jimtcl_config_options="--disable-install-jim --with-ext=json --minimal --disable-ssl --maintainer"
591 jimtcl_config_options="--disable-install-jim --with-ext=json --minimal --disable-ssl"
593 AX_CONFIG_SUBDIR_OPTION([jimtcl], [$jimtcl_config_options])
595 AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
599 AS_IF([test "x$build_remote_bitbang" = "xyes"], [
601 AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
603 AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
606 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
608 AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
610 AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
613 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
614 build_xlnx_pcie_xvc=yes
615 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [1], [1 if you want the Xilinx XVC/PCIe driver.])
617 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [0], [0 if you don't want Xilinx XVC/PCIe driver.])
620 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
622 AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
623 LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
624 AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
625 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
626 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
629 AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
632 AC_ARG_WITH([capstone],
633 AS_HELP_STRING([--with-capstone], [Use Capstone disassembly library (default=auto)])
635 enable_capstone=$withval
640 AS_IF([test "x$enable_capstone" != xno], [
641 PKG_CHECK_MODULES([CAPSTONE], [capstone], [
642 AC_DEFINE([HAVE_CAPSTONE], [1], [1 if you have Capstone disassembly framework.])
644 if test "x$enable_capstone" != xauto; then
645 AC_MSG_ERROR([--with-capstone was given, but test for Capstone failed])
651 AS_IF([test "x$enable_capstone" == xno], [
652 AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.])
655 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
656 PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
664 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [
666 PKG_CHECK_EXISTS([libftdi1 >= 1.5],
667 [AC_DEFINE([HAVE_LIBFTDI_TCIOFLUSH], [1], [Define if your libftdi has ftdi_tcioflush()])])
669 PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
672 PKG_CHECK_MODULES([LIBGPIOD], [libgpiod], [use_libgpiod=yes], [use_libgpiod=no])
674 PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2],
675 [use_libjaylink=yes], [use_libjaylink=no])
677 m4_define([PROCESS_ADAPTERS], [
678 m4_foreach([adapter], [$1], [
680 AS_IF([test "x$ADAPTER_VAR([adapter])" != "xno"], [
681 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
683 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
686 AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [
687 AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
689 ADAPTER_VAR([adapter])=no
690 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
692 AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test "x$ADAPTER_VAR([adapter])" != "xno"])
696 PROCESS_ADAPTERS([USB1_ADAPTERS], ["x$use_libusb1" = "xyes"], [libusb-1.x])
697 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], ["x$use_hidapi" = "xyes"], [hidapi])
698 PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libusb1" = "xyes"], [hidapi and libusb-1.x])
699 PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
700 PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
701 PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [libgpiod])
702 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2])
704 AS_IF([test "x$enable_linuxgpiod" != "xno"], [
708 AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enable_nulink" != "xno"], [
709 AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
710 AM_CONDITIONAL([HLADAPTER], [true])
712 AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
713 AM_CONDITIONAL([HLADAPTER], [false])
715 AM_CONDITIONAL([HLADAPTER_STLINK], [test "x$enable_stlink" != "xno"])
716 AM_CONDITIONAL([HLADAPTER_ICDI], [test "x$enable_ti_icdi" != "xno"])
717 AM_CONDITIONAL([HLADAPTER_NULINK], [test "x$enable_nulink" != "xno"])
719 AS_IF([test "x$enable_jlink" != "xno"], [
720 AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
721 AS_IF([test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"], [
722 AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
723 [--enable-subproject-build])
725 AC_MSG_ERROR([Internal libjaylink not found, run 'git submodule init' and 'git submodule update'.])
730 # Presto needs the bitq module
731 AS_IF([test "x$enable_presto" != "xno"], [
735 # esp-usb-jtag also needs the bitq module
736 AS_IF([test "x$enable_esp_usb_jtag" != "xno"], [
740 AM_CONDITIONAL([RELEASE], [test "x$build_release" = "xyes"])
741 AM_CONDITIONAL([PARPORT], [test "x$build_parport" = "xyes"])
742 AM_CONDITIONAL([DUMMY], [test "x$build_dummy" = "xyes"])
743 AM_CONDITIONAL([GIVEIO], [test "x$parport_use_giveio" = "xyes"])
744 AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
745 AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
746 AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
747 AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
748 AM_CONDITIONAL([AM335XGPIO], [test "x$build_am335xgpio" = "xyes"])
749 AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
750 AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes"])
751 AM_CONDITIONAL([VDEBUG], [test "x$build_vdebug" = "xyes"])
752 AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes"])
753 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
754 AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
755 AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
756 AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
757 AM_CONDITIONAL([BUSPIRATE], [test "x$enable_buspirate" != "xno"])
758 AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
759 AM_CONDITIONAL([XLNX_PCIE_XVC], [test "x$build_xlnx_pcie_xvc" = "xyes"])
760 AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
761 AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
762 AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"])
763 AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "xyes"])
764 AM_CONDITIONAL([IS_DARWIN], [test "x$is_darwin" = "xyes"])
765 AM_CONDITIONAL([BITQ], [test "x$build_bitq" = "xyes"])
766 AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
767 AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"])
768 AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"])
769 AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
770 AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
771 AM_CONDITIONAL([DMEM], [test "x$build_dmem" = "xyes"])
772 AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
774 AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
775 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
777 # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
778 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
779 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
783 ]], [[char **ep = environ;]]
790 # Possibility #2: can environ be found in an available library?
791 AC_MSG_CHECKING([for extern environ])
792 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
793 extern char **environ;
794 ]], [[char **ep = environ;]]
796 AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
801 AC_MSG_RESULT([${has_environ}])
804 AS_IF([test "x${has_environ}" != "xyes" ], [
805 AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
808 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
810 # set default gcc warnings
811 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
812 AS_IF([test "x${gcc_wextra}" = "xyes"], [
813 GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
814 GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
815 GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
816 GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
817 GCC_WARNINGS="${GCC_WARNINGS} -Wpointer-arith"
818 GCC_WARNINGS="${GCC_WARNINGS} -Wundef"
820 AS_IF([test "x${gcc_werror}" = "xyes"], [
821 GCC_WARNINGS="${GCC_WARNINGS} -Werror"
824 # override default gcc cflags
825 AS_IF([test "x$gcc_warnings" = "xyes"], [
826 AC_SUBST([GCC_WARNINGS], [$GCC_WARNINGS])
829 AC_SUBST(EXTRA_DIST_NEWS, ["$(echo $srcdir/NEWS-*)"])
836 AS_IF([test "x$enable_jlink" != "xno"], [
837 AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
838 AC_MSG_WARN([Using the internal libjaylink is deprecated and will not be possible in the future.])
844 echo OpenOCD configuration summary
845 echo --------------------------------------------------
846 m4_foreach([adapter], [USB1_ADAPTERS,
847 HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS,
848 LIBFTDI_USB1_ADAPTERS,
850 LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
852 [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
853 AS_CASE([$ADAPTER_VAR([adapter])],
855 echo "$s"yes '(auto)'