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 [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
122 [[ft232r], [Bitbang mode of FT232R based devices], [FT232R]],
123 [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]],
124 [[xds110], [TI XDS110 Debug Probe], [XDS110]],
125 [[cmsis_dap_v2], [CMSIS-DAP v2 Compliant Debugger], [CMSIS_DAP_USB]],
126 [[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
127 [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
128 [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]],
129 [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
130 [[usbprog], [USBProg JTAG Programmer], [USBPROG]],
131 [[esp_usb_jtag], [Espressif JTAG Programmer], [ESP_USB_JTAG]]])
133 m4_define([HIDAPI_ADAPTERS],
134 [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP_HID]],
135 [[nulink], [Nu-Link Programmer], [HLADAPTER_NULINK]]])
137 m4_define([HIDAPI_USB1_ADAPTERS],
138 [[[kitprog], [Cypress KitProg Programmer], [KITPROG]]])
140 m4_define([LIBFTDI_ADAPTERS],
141 [[[usb_blaster], [Altera USB-Blaster Compatible], [USB_BLASTER]],
142 [[presto], [ASIX Presto Adapter], [PRESTO]]])
144 m4_define([LIBFTDI_USB1_ADAPTERS],
145 [[[openjtag], [OpenJTAG Adapter], [OPENJTAG]]])
147 m4_define([LIBGPIOD_ADAPTERS],
148 [[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]])
150 m4_define([LIBJAYLINK_ADAPTERS],
151 [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
153 m4_define([PCIE_ADAPTERS],
154 [[[xlnx_pcie_xvc], [Xilinx XVC/PCIe], [XLNX_PCIE_XVC]]])
156 m4_define([SERIAL_PORT_ADAPTERS],
157 [[[buspirate], [Bus Pirate], [BUS_PIRATE]]])
159 m4_define([OPTIONAL_LIBRARIES],
160 [[[capstone], [Use Capstone disassembly framework], []]])
162 AC_ARG_ENABLE([doxygen-html],
163 AS_HELP_STRING([--disable-doxygen-html],
164 [Disable building Doxygen manual as HTML.]),
165 [doxygen_as_html=$enableval], [doxygen_as_html=yes])
166 AC_SUBST([doxygen_as_html])
167 AC_MSG_CHECKING([whether to build Doxygen as HTML])
168 AC_MSG_RESULT([$doxygen_as_html])
170 AC_ARG_ENABLE([doxygen-pdf],
171 AS_HELP_STRING([--enable-doxygen-pdf],
172 [Enable building Doxygen manual as PDF.]),
173 [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
174 AC_SUBST([doxygen_as_pdf])
175 AC_MSG_CHECKING([whether to build Doxygen as PDF])
176 AC_MSG_RESULT([$doxygen_as_pdf])
178 AC_ARG_ENABLE([gccwarnings],
179 AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
180 [gcc_warnings=$enableval], [gcc_warnings=yes])
182 AC_ARG_ENABLE([wextra],
183 AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
184 [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
186 AC_ARG_ENABLE([werror],
187 AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
188 [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
190 # set default verbose options, overridden by following options
194 AC_ARG_ENABLE([verbose],
195 AS_HELP_STRING([--enable-verbose],
196 [Enable verbose JTAG I/O messages (for debugging).]),
198 debug_usb_io=$enableval
199 debug_usb_comms=$enableval
202 AC_ARG_ENABLE([verbose_usb_io],
203 AS_HELP_STRING([--enable-verbose-usb-io],
204 [Enable verbose USB I/O messages (for debugging)]),
205 [debug_usb_io=$enableval], [])
207 AC_ARG_ENABLE([verbose_usb_comms],
208 AS_HELP_STRING([--enable-verbose-usb-comms],
209 [Enable verbose USB communication messages (for debugging)]),
210 [debug_usb_comms=$enableval], [])
212 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
213 AC_MSG_RESULT([$debug_usb_io])
214 AS_IF([test "x$debug_usb_io" = "xyes"], [
215 AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
218 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
219 AC_MSG_RESULT([$debug_usb_comms])
220 AS_IF([test "x$debug_usb_comms" = "xyes"], [
221 AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
225 AC_ARG_ENABLE([malloc_logging],
226 AS_HELP_STRING([--enable-malloc-logging],
227 [Include free space in logging messages (requires malloc.h).]),
228 [debug_malloc=$enableval], [])
230 AC_MSG_CHECKING([whether to enable malloc free space logging]);
231 AC_MSG_RESULT([$debug_malloc])
232 AS_IF([test "x$debug_malloc" = "xyes"], [
233 AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
236 AC_ARG_ENABLE([dummy],
237 AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
238 [build_dummy=$enableval], [build_dummy=no])
240 AC_ARG_ENABLE([rshim],
241 AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
242 [build_rshim=$enableval], [build_rshim=no])
244 m4_define([AC_ARG_ADAPTERS], [
245 m4_foreach([adapter], [$1],
246 [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
247 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
248 [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
249 [], [ADAPTER_VAR([adapter])=$2])
256 HIDAPI_USB1_ADAPTERS,
258 LIBFTDI_USB1_ADAPTERS
260 SERIAL_PORT_ADAPTERS,
264 AC_ARG_ENABLE([parport],
265 AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
266 [build_parport=$enableval], [build_parport=no])
268 AC_ARG_ENABLE([parport_ppdev],
269 AS_HELP_STRING([--disable-parport-ppdev],
270 [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
271 [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
273 AC_ARG_ENABLE([parport_giveio],
274 AS_HELP_STRING([--enable-parport-giveio],
275 [Enable use of giveio for parport (for CygWin only)]),
276 [parport_use_giveio=$enableval], [parport_use_giveio=])
278 AC_ARG_ENABLE([jtag_vpi],
279 AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
280 [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
282 AC_ARG_ENABLE([vdebug],
283 AS_HELP_STRING([--enable-vdebug], [Enable building support for Cadence Virtual Debug Interface]),
284 [build_vdebug=$enableval], [build_vdebug=no])
286 AC_ARG_ENABLE([jtag_dpi],
287 AS_HELP_STRING([--enable-jtag_dpi], [Enable building support for JTAG DPI]),
288 [build_jtag_dpi=$enableval], [build_jtag_dpi=no])
290 AC_ARG_ENABLE([amtjtagaccel],
291 AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
292 [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
294 AS_CASE(["${host_cpu}"],
296 AC_ARG_ENABLE([bcm2835gpio],
297 AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
298 [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
299 AC_ARG_ENABLE([imx_gpio],
300 AS_HELP_STRING([--enable-imx_gpio], [Enable building support for bitbanging on NXP IMX processors]),
301 [build_imx_gpio=$enableval], [build_imx_gpio=no])
302 AC_ARG_ENABLE([am335xgpio],
303 AS_HELP_STRING([--enable-am335xgpio], [Enable building support for bitbanging on AM335x (as found in Beaglebones)]),
304 [build_am335xgpio=$enableval], [build_am335xgpio=no])
312 AS_CASE(["${host_cpu}"],
314 AC_ARG_ENABLE([ep93xx],
315 AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
316 [build_ep93xx=$enableval], [build_ep93xx=no])
318 AC_ARG_ENABLE([at91rm9200],
319 AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
320 [build_at91rm9200=$enableval], [build_at91rm9200=no])
327 AC_ARG_ENABLE([gw16012],
328 AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
329 [build_gw16012=$enableval], [build_gw16012=no])
331 AC_ARG_ENABLE([sysfsgpio],
332 AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
333 [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
335 AC_ARG_ENABLE([xlnx_pcie_xvc],
336 AS_HELP_STRING([--enable-xlnx-pcie-xvc], [Enable building support for Xilinx XVC/PCIe.]),
337 [build_xlnx_pcie_xvc=$enableval], [build_xlnx_pcie_xvc=no])
342 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
343 AC_MSG_ERROR([sysfsgpio is only available on linux])
346 AS_IF([test "x$enable_linuxgpiod" = "xyes"], [
347 AC_MSG_ERROR([linuxgpiod is only available on linux])
350 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
351 AC_MSG_ERROR([xlnx_pcie_xvc is only available on linux])
354 AS_CASE([$host_os], [freebsd*], [],
356 AS_IF([test "x$build_rshim" = "xyes"], [
357 AC_MSG_ERROR([build_rshim is only available on linux or freebsd])
362 AC_ARG_ENABLE([internal-jimtcl],
363 AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
364 [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
366 AC_ARG_ENABLE([jimtcl-maintainer],
367 AS_HELP_STRING([--enable-jimtcl-maintainer], [Enable maintainer mode when building internal jimtcl]),
368 [use_internal_jimtcl_maintainer=$enableval], [use_internal_jimtcl_maintainer=no])
370 AC_ARG_ENABLE([internal-libjaylink],
371 AS_HELP_STRING([--enable-internal-libjaylink],
372 [Enable building internal libjaylink]),
373 [use_internal_libjaylink=$enableval], [use_internal_libjaylink=no])
375 AC_ARG_ENABLE([remote-bitbang],
376 AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
377 [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
379 AS_CASE(["${host_cpu}"],
382 AS_IF([test "x$parport_use_ppdev" = "xno"], [
383 AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
385 parport_use_ppdev=yes
393 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
394 [is_mingw=yes],[is_mingw=no])
395 AS_IF([test "x$is_mingw" = "xyes"], [
396 AS_IF([test "x$parport_use_giveio" = "xno"], [
397 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
399 parport_use_giveio=yes
403 # sys/io.h needed under cygwin for parport access
404 AS_IF([test "x$build_parport" = "xyes"], [
405 AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
409 [*-mingw* | *-msys*], [
414 AS_IF([test "x$parport_use_giveio" = "xno"], [
415 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
417 parport_use_giveio=yes
419 AS_IF([test "x$enable_buspirate" = "xyes"], [
420 AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
423 # In case enable_buspirate=auto, make sure it will not be built.
426 AC_SUBST([HOST_CPPFLAGS], [-D__USE_MINGW_ANSI_STDIO])
431 AS_IF([test "x$parport_use_giveio" = "xyes"], [
432 AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
434 parport_use_giveio=no
437 AS_IF([test "x$parport_use_giveio" = "xyes"], [
438 AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
440 parport_use_giveio=no
443 AS_IF([test "x$is_cygwin" = "xyes"], [
444 AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
446 AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
449 AS_IF([test "x$is_mingw" = "xyes"], [
450 AC_DEFINE([IS_MINGW], [1], [1 if building for Mingw.])
452 AC_DEFINE([IS_MINGW], [0], [0 if not building for Mingw.])
455 AS_IF([test "x$is_win32" = "xyes"], [
456 AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
458 AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
461 AS_IF([test "x$is_darwin" = "xyes"], [
462 AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
464 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
467 AS_IF([test "x$build_parport" = "xyes"], [
469 AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
471 AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
474 AS_IF([test "x$build_rshim" = "xyes"], [
475 AC_DEFINE([BUILD_RSHIM], [1], [1 if you want to debug BlueField SoC via rshim.])
477 AC_DEFINE([BUILD_RSHIM], [0], [0 if you don't want to debug BlueField SoC via rshim.])
480 AS_IF([test "x$build_dummy" = "xyes"], [
482 AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
484 AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
487 AS_IF([test "x$build_ep93xx" = "xyes"], [
489 AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
491 AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
494 AS_IF([test "x$build_at91rm9200" = "xyes"], [
496 AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
498 AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
501 AS_IF([test "x$build_bcm2835gpio" = "xyes"], [
503 AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
505 AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
508 AS_IF([test "x$build_imx_gpio" = "xyes"], [
510 AC_DEFINE([BUILD_IMX_GPIO], [1], [1 if you want imx_gpio.])
512 AC_DEFINE([BUILD_IMX_GPIO], [0], [0 if you don't want imx_gpio.])
515 AS_IF([test "x$build_am335xgpio" = "xyes"], [
517 AC_DEFINE([BUILD_AM335XGPIO], [1], [1 if you want am335xgpio.])
519 AC_DEFINE([BUILD_AM335XGPIO], [0], [0 if you don't want am335xgpio.])
522 AS_IF([test "x$parport_use_ppdev" = "xyes"], [
523 AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
525 AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
528 AS_IF([test "x$parport_use_giveio" = "xyes"], [
529 AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
531 AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
534 AS_IF([test "x$build_jtag_vpi" = "xyes"], [
535 AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
537 AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
540 AS_IF([test "x$build_vdebug" = "xyes"], [
541 AC_DEFINE([BUILD_VDEBUG], [1], [1 if you want Cadence vdebug interface.])
543 AC_DEFINE([BUILD_VDEBUG], [0], [0 if you don't want Cadence vdebug interface.])
546 AS_IF([test "x$build_jtag_dpi" = "xyes"], [
547 AC_DEFINE([BUILD_JTAG_DPI], [1], [1 if you want JTAG DPI.])
549 AC_DEFINE([BUILD_JTAG_DPI], [0], [0 if you don't want JTAG DPI.])
553 AS_IF([test "x$build_amtjtagaccel" = "xyes"], [
554 AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
556 AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
559 AS_IF([test "x$build_gw16012" = "xyes"], [
560 AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
562 AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
565 AS_IF([test "x$enable_buspirate" != "xno"], [
566 AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
568 AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
571 AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
572 AS_IF([test -f "$srcdir/jimtcl/configure"], [
573 AS_IF([test "x$use_internal_jimtcl_maintainer" = "xyes"], [
574 jimtcl_config_options="--disable-install-jim --with-ext=json --maintainer"
576 jimtcl_config_options="--disable-install-jim --with-ext=json"
578 AX_CONFIG_SUBDIR_OPTION([jimtcl], [$jimtcl_config_options])
580 AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
584 AS_IF([test "x$build_remote_bitbang" = "xyes"], [
586 AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
588 AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
591 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
593 AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
595 AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
598 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
599 build_xlnx_pcie_xvc=yes
600 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [1], [1 if you want the Xilinx XVC/PCIe driver.])
602 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [0], [0 if you don't want Xilinx XVC/PCIe driver.])
605 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
607 AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
608 LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
609 AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
610 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
611 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
614 AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
617 AC_ARG_WITH([capstone],
618 AS_HELP_STRING([--with-capstone], [Use Capstone disassembly library (default=auto)])
620 enable_capstone=$withval
625 AS_IF([test "x$enable_capstone" != xno], [
626 PKG_CHECK_MODULES([CAPSTONE], [capstone], [
627 AC_DEFINE([HAVE_CAPSTONE], [1], [1 if you have Capstone disassembly framework.])
629 if test "x$enable_capstone" != xauto; then
630 AC_MSG_ERROR([--with-capstone was given, but test for Capstone failed])
636 AS_IF([test "x$enable_capstone" == xno], [
637 AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.])
640 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
641 PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
649 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [
651 PKG_CHECK_EXISTS([libftdi1 >= 1.5],
652 [AC_DEFINE([HAVE_LIBFTDI_TCIOFLUSH], [1], [Define if your libftdi has ftdi_tcioflush()])])
654 PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
657 PKG_CHECK_MODULES([LIBGPIOD], [libgpiod], [use_libgpiod=yes], [use_libgpiod=no])
659 PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2],
660 [use_libjaylink=yes], [use_libjaylink=no])
662 m4_define([PROCESS_ADAPTERS], [
663 m4_foreach([adapter], [$1], [
665 AS_IF([test "x$ADAPTER_VAR([adapter])" != "xno"], [
666 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
668 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
671 AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [
672 AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
674 ADAPTER_VAR([adapter])=no
675 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
677 AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test "x$ADAPTER_VAR([adapter])" != "xno"])
681 PROCESS_ADAPTERS([USB1_ADAPTERS], ["x$use_libusb1" = "xyes"], [libusb-1.x])
682 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], ["x$use_hidapi" = "xyes"], [hidapi])
683 PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libusb1" = "xyes"], [hidapi and libusb-1.x])
684 PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
685 PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
686 PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [libgpiod])
687 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2])
689 AS_IF([test "x$enable_linuxgpiod" != "xno"], [
693 AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enable_nulink" != "xno"], [
694 AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
695 AM_CONDITIONAL([HLADAPTER], [true])
697 AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
698 AM_CONDITIONAL([HLADAPTER], [false])
700 AM_CONDITIONAL([HLADAPTER_STLINK], [test "x$enable_stlink" != "xno"])
701 AM_CONDITIONAL([HLADAPTER_ICDI], [test "x$enable_ti_icdi" != "xno"])
702 AM_CONDITIONAL([HLADAPTER_NULINK], [test "x$enable_nulink" != "xno"])
704 AS_IF([test "x$enable_jlink" != "xno"], [
705 AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
706 AS_IF([test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"], [
707 AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
708 [--enable-subproject-build])
710 AC_MSG_ERROR([Internal libjaylink not found, run 'git submodule init' and 'git submodule update'.])
715 # Presto needs the bitq module
716 AS_IF([test "x$enable_presto" != "xno"], [
720 # esp-usb-jtag also needs the bitq module
721 AS_IF([test "x$enable_esp_usb_jtag" != "xno"], [
725 AM_CONDITIONAL([RELEASE], [test "x$build_release" = "xyes"])
726 AM_CONDITIONAL([PARPORT], [test "x$build_parport" = "xyes"])
727 AM_CONDITIONAL([DUMMY], [test "x$build_dummy" = "xyes"])
728 AM_CONDITIONAL([GIVEIO], [test "x$parport_use_giveio" = "xyes"])
729 AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
730 AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
731 AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
732 AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
733 AM_CONDITIONAL([AM335XGPIO], [test "x$build_am335xgpio" = "xyes"])
734 AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
735 AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes"])
736 AM_CONDITIONAL([VDEBUG], [test "x$build_vdebug" = "xyes"])
737 AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes"])
738 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
739 AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
740 AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
741 AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
742 AM_CONDITIONAL([BUSPIRATE], [test "x$enable_buspirate" != "xno"])
743 AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
744 AM_CONDITIONAL([XLNX_PCIE_XVC], [test "x$build_xlnx_pcie_xvc" = "xyes"])
745 AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
746 AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
747 AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"])
748 AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "xyes"])
749 AM_CONDITIONAL([IS_DARWIN], [test "x$is_darwin" = "xyes"])
750 AM_CONDITIONAL([BITQ], [test "x$build_bitq" = "xyes"])
751 AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
752 AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"])
753 AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"])
754 AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
755 AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
756 AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
758 AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
759 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
761 # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
762 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
763 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
767 ]], [[char **ep = environ;]]
774 # Possibility #2: can environ be found in an available library?
775 AC_MSG_CHECKING([for extern environ])
776 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
777 extern char **environ;
778 ]], [[char **ep = environ;]]
780 AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
785 AC_MSG_RESULT([${has_environ}])
788 AS_IF([test "x${has_environ}" != "xyes" ], [
789 AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
792 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
794 # set default gcc warnings
795 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
796 AS_IF([test "x${gcc_wextra}" = "xyes"], [
797 GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
798 GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
799 GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
800 GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
801 GCC_WARNINGS="${GCC_WARNINGS} -Wpointer-arith"
802 GCC_WARNINGS="${GCC_WARNINGS} -Wundef"
804 AS_IF([test "x${gcc_werror}" = "xyes"], [
805 GCC_WARNINGS="${GCC_WARNINGS} -Werror"
808 # override default gcc cflags
809 AS_IF([test "x$gcc_warnings" = "xyes"], [
810 AC_SUBST([GCC_WARNINGS], [$GCC_WARNINGS])
813 AC_SUBST(EXTRA_DIST_NEWS, ["$(echo $srcdir/NEWS-*)"])
820 AS_IF([test "x$enable_jlink" != "xno"], [
821 AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
822 AC_MSG_WARN([Using the internal libjaylink is deprecated and will not be possible in the future.])
828 echo OpenOCD configuration summary
829 echo --------------------------------------------------
830 m4_foreach([adapter], [USB1_ADAPTERS,
831 HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS,
832 LIBFTDI_USB1_ADAPTERS,
834 LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
836 [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
837 AS_CASE([$ADAPTER_VAR([adapter])],
839 echo "$s"yes '(auto)'