2 AC_INIT([openocd], [0.11.0+dev],
3 [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
4 AC_CONFIG_SRCDIR([src/openocd.c])
5 AC_CONFIG_AUX_DIR([build-aux])
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])
23 # autoconf 2.70 obsoletes AC_PROG_CC_C99 and includes it in AC_PROG_CC
24 m4_version_prereq([2.70],[],[AC_PROG_CC_C99])
27 PKG_PROG_PKG_CONFIG([0.23])
29 dnl disable checks for C++, Fortran and GNU Java Compiler
30 m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
31 m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
32 m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
35 AC_SUBST([LIBTOOL_DEPS])
37 dnl configure checks required for Jim files (these are obsolete w/ C99)
41 AC_SEARCH_LIBS([ioperm], [ioperm])
42 AC_SEARCH_LIBS([dlopen], [dl])
43 AC_SEARCH_LIBS([openpty], [util])
45 AC_CHECK_HEADERS([sys/socket.h])
46 AC_CHECK_HEADERS([elf.h])
47 AC_EGREP_HEADER(Elf64_Ehdr, [elf.h], [
48 AC_DEFINE([HAVE_ELF64], [1], [Define to 1 if the system has the type `Elf64_Ehdr'.])
50 AC_CHECK_HEADERS([dirent.h])
51 AC_CHECK_HEADERS([fcntl.h])
52 AC_CHECK_HEADERS([malloc.h])
53 AC_CHECK_HEADERS([netdb.h])
54 AC_CHECK_HEADERS([poll.h])
55 AC_CHECK_HEADERS([pthread.h])
56 AC_CHECK_HEADERS([strings.h])
57 AC_CHECK_HEADERS([sys/ioctl.h])
58 AC_CHECK_HEADERS([sys/param.h])
59 AC_CHECK_HEADERS([sys/select.h])
60 AC_CHECK_HEADERS([sys/stat.h])
61 AC_CHECK_HEADERS([sys/sysctl.h])
62 AC_CHECK_HEADERS([sys/time.h])
63 AC_CHECK_HEADERS([sys/types.h])
64 AC_CHECK_HEADERS([unistd.h])
65 AC_CHECK_HEADERS([arpa/inet.h ifaddrs.h netinet/in.h netinet/tcp.h net/if.h], [], [], [dnl
75 #ifdef HAVE_SYS_SOCKET_H
76 # include <sys/socket.h>
85 AC_CHECK_FUNCS([strndup])
86 AC_CHECK_FUNCS([strnlen])
87 AC_CHECK_FUNCS([gettimeofday])
88 AC_CHECK_FUNCS([usleep])
89 AC_CHECK_FUNCS([vasprintf])
90 AC_CHECK_FUNCS([realpath])
92 # guess-rev.sh only exists in the repository, not in the released archives
93 AC_MSG_CHECKING([whether to build a release])
94 AS_IF([test -x "$srcdir/guess-rev.sh"], [
99 AC_MSG_RESULT([$build_release])
102 # 1st column -- configure option
103 # 2nd column -- description
104 # 3rd column -- symbol used for both config.h and automake
105 m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
106 m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
107 m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
108 m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
109 m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
111 m4_define([USB1_ADAPTERS],
112 [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
113 [[stlink], [ST-Link Programmer], [HLADAPTER_STLINK]],
114 [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
115 [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
116 [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
117 [[ft232r], [Bitbang mode of FT232R based devices], [FT232R]],
118 [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]],
119 [[xds110], [TI XDS110 Debug Probe], [XDS110]],
120 [[cmsis_dap_v2], [CMSIS-DAP v2 Compliant Debugger], [CMSIS_DAP_USB]],
121 [[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
122 [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
123 [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]],
124 [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
125 [[usbprog], [USBProg JTAG Programmer], [USBPROG]],
126 [[aice], [Andes JTAG Programmer], [AICE]]])
128 m4_define([HIDAPI_ADAPTERS],
129 [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP_HID]],
130 [[nulink], [Nu-Link Programmer], [HLADAPTER_NULINK]]])
132 m4_define([HIDAPI_USB1_ADAPTERS],
133 [[[kitprog], [Cypress KitProg Programmer], [KITPROG]]])
135 m4_define([LIBFTDI_ADAPTERS],
136 [[[usb_blaster], [Altera USB-Blaster Compatible], [USB_BLASTER]],
137 [[presto], [ASIX Presto Adapter], [PRESTO]]])
139 m4_define([LIBFTDI_USB1_ADAPTERS],
140 [[[openjtag], [OpenJTAG Adapter], [OPENJTAG]]])
142 m4_define([LIBGPIOD_ADAPTERS],
143 [[[linuxgpiod], [Linux GPIO bitbang through libgpiod], [LINUXGPIOD]]])
145 m4_define([LIBJAYLINK_ADAPTERS],
146 [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
148 m4_define([PCIE_ADAPTERS],
149 [[[xlnx_pcie_xvc], [Xilinx XVC/PCIe], [XLNX_PCIE_XVC]]])
151 m4_define([SERIAL_PORT_ADAPTERS],
152 [[[buspirate], [Bus Pirate], [BUS_PIRATE]]])
154 m4_define([OPTIONAL_LIBRARIES],
155 [[[capstone], [Use Capstone disassembly framework], []]])
157 AC_ARG_ENABLE([doxygen-html],
158 AS_HELP_STRING([--disable-doxygen-html],
159 [Disable building Doxygen manual as HTML.]),
160 [doxygen_as_html=$enableval], [doxygen_as_html=yes])
161 AC_SUBST([doxygen_as_html])
162 AC_MSG_CHECKING([whether to build Doxygen as HTML])
163 AC_MSG_RESULT([$doxygen_as_html])
165 AC_ARG_ENABLE([doxygen-pdf],
166 AS_HELP_STRING([--enable-doxygen-pdf],
167 [Enable building Doxygen manual as PDF.]),
168 [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
169 AC_SUBST([doxygen_as_pdf])
170 AC_MSG_CHECKING([whether to build Doxygen as PDF])
171 AC_MSG_RESULT([$doxygen_as_pdf])
173 AC_ARG_ENABLE([gccwarnings],
174 AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
175 [gcc_warnings=$enableval], [gcc_warnings=yes])
177 AC_ARG_ENABLE([wextra],
178 AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
179 [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
181 AC_ARG_ENABLE([werror],
182 AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
183 [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
185 # set default verbose options, overridden by following options
189 AC_ARG_ENABLE([verbose],
190 AS_HELP_STRING([--enable-verbose],
191 [Enable verbose JTAG I/O messages (for debugging).]),
193 debug_usb_io=$enableval
194 debug_usb_comms=$enableval
197 AC_ARG_ENABLE([verbose_usb_io],
198 AS_HELP_STRING([--enable-verbose-usb-io],
199 [Enable verbose USB I/O messages (for debugging)]),
200 [debug_usb_io=$enableval], [])
202 AC_ARG_ENABLE([verbose_usb_comms],
203 AS_HELP_STRING([--enable-verbose-usb-comms],
204 [Enable verbose USB communication messages (for debugging)]),
205 [debug_usb_comms=$enableval], [])
207 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
208 AC_MSG_RESULT([$debug_usb_io])
209 AS_IF([test "x$debug_usb_io" = "xyes"], [
210 AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
213 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
214 AC_MSG_RESULT([$debug_usb_comms])
215 AS_IF([test "x$debug_usb_comms" = "xyes"], [
216 AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
220 AC_ARG_ENABLE([malloc_logging],
221 AS_HELP_STRING([--enable-malloc-logging],
222 [Include free space in logging messages (requires malloc.h).]),
223 [debug_malloc=$enableval], [])
225 AC_MSG_CHECKING([whether to enable malloc free space logging]);
226 AC_MSG_RESULT([$debug_malloc])
227 AS_IF([test "x$debug_malloc" = "xyes"], [
228 AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
231 AC_ARG_ENABLE([dummy],
232 AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
233 [build_dummy=$enableval], [build_dummy=no])
235 AC_ARG_ENABLE([rshim],
236 AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
237 [build_rshim=$enableval], [build_rshim=no])
239 m4_define([AC_ARG_ADAPTERS], [
240 m4_foreach([adapter], [$1],
241 [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
242 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
243 [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
244 [], [ADAPTER_VAR([adapter])=$2])
251 HIDAPI_USB1_ADAPTERS,
253 LIBFTDI_USB1_ADAPTERS
255 SERIAL_PORT_ADAPTERS,
259 AC_ARG_ENABLE([parport],
260 AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
261 [build_parport=$enableval], [build_parport=no])
263 AC_ARG_ENABLE([parport_ppdev],
264 AS_HELP_STRING([--disable-parport-ppdev],
265 [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
266 [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
268 AC_ARG_ENABLE([parport_giveio],
269 AS_HELP_STRING([--enable-parport-giveio],
270 [Enable use of giveio for parport (for CygWin only)]),
271 [parport_use_giveio=$enableval], [parport_use_giveio=])
273 AC_ARG_ENABLE([jtag_vpi],
274 AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
275 [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
277 AC_ARG_ENABLE([jtag_dpi],
278 AS_HELP_STRING([--enable-jtag_dpi], [Enable building support for JTAG DPI]),
279 [build_jtag_dpi=$enableval], [build_jtag_dpi=no])
281 AC_ARG_ENABLE([amtjtagaccel],
282 AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
283 [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
285 AS_CASE(["${host_cpu}"],
287 AC_ARG_ENABLE([bcm2835gpio],
288 AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
289 [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
290 AC_ARG_ENABLE([imx_gpio],
291 AS_HELP_STRING([--enable-imx_gpio], [Enable building support for bitbanging on NXP IMX processors]),
292 [build_imx_gpio=$enableval], [build_imx_gpio=no])
299 AS_CASE(["${host_cpu}"],
301 AC_ARG_ENABLE([ep93xx],
302 AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
303 [build_ep93xx=$enableval], [build_ep93xx=no])
305 AC_ARG_ENABLE([at91rm9200],
306 AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
307 [build_at91rm9200=$enableval], [build_at91rm9200=no])
314 AC_ARG_ENABLE([gw16012],
315 AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
316 [build_gw16012=$enableval], [build_gw16012=no])
318 AC_ARG_ENABLE([sysfsgpio],
319 AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
320 [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
322 AC_ARG_ENABLE([xlnx_pcie_xvc],
323 AS_HELP_STRING([--enable-xlnx-pcie-xvc], [Enable building support for Xilinx XVC/PCIe.]),
324 [build_xlnx_pcie_xvc=$enableval], [build_xlnx_pcie_xvc=no])
329 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
330 AC_MSG_ERROR([sysfsgpio is only available on linux])
333 AS_IF([test "x$enable_linuxgpiod" = "xyes"], [
334 AC_MSG_ERROR([linuxgpiod is only available on linux])
337 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
338 AC_MSG_ERROR([xlnx_pcie_xvc is only available on linux])
341 AS_CASE([$host_os], [freebsd*], [],
343 AS_IF([test "x$build_rshim" = "xyes"], [
344 AC_MSG_ERROR([build_rshim is only available on linux or freebsd])
349 AC_ARG_ENABLE([internal-jimtcl],
350 AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
351 [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
353 AC_ARG_ENABLE([internal-libjaylink],
354 AS_HELP_STRING([--disable-internal-libjaylink],
355 [Disable building internal libjaylink]),
356 [use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
358 AC_ARG_ENABLE([remote-bitbang],
359 AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
360 [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
362 AS_CASE(["${host_cpu}"],
365 AS_IF([test "x$parport_use_ppdev" = "xno"], [
366 AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
368 parport_use_ppdev=yes
376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
377 [is_mingw=yes],[is_mingw=no])
378 AS_IF([test "x$is_mingw" = "xyes"], [
379 AS_IF([test "x$parport_use_giveio" = "xno"], [
380 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
382 parport_use_giveio=yes
386 # sys/io.h needed under cygwin for parport access
387 AS_IF([test "x$build_parport" = "xyes"], [
388 AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
392 [*-mingw* | *-msys*], [
397 AS_IF([test "x$parport_use_giveio" = "xno"], [
398 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
400 parport_use_giveio=yes
402 AS_IF([test "x$enable_buspirate" = "xyes"], [
403 AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
406 # In case enable_buspirate=auto, make sure it will not be built.
409 AC_SUBST([HOST_CPPFLAGS], [-D__USE_MINGW_ANSI_STDIO])
414 AS_IF([test "x$parport_use_giveio" = "xyes"], [
415 AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
417 parport_use_giveio=no
420 AS_IF([test "x$parport_use_giveio" = "xyes"], [
421 AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
423 parport_use_giveio=no
426 AS_IF([test "x$is_cygwin" = "xyes"], [
427 AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
429 AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
432 AS_IF([test "x$is_mingw" = "xyes"], [
433 AC_DEFINE([IS_MINGW], [1], [1 if building for Mingw.])
435 AC_DEFINE([IS_MINGW], [0], [0 if not building for Mingw.])
438 AS_IF([test "x$is_win32" = "xyes"], [
439 AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
441 AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
444 AS_IF([test "x$is_darwin" = "xyes"], [
445 AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
447 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
450 AS_IF([test "x$build_parport" = "xyes"], [
452 AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
454 AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
457 AS_IF([test "x$build_rshim" = "xyes"], [
458 AC_DEFINE([BUILD_RSHIM], [1], [1 if you want to debug BlueField SoC via rshim.])
460 AC_DEFINE([BUILD_RSHIM], [0], [0 if you don't want to debug BlueField SoC via rshim.])
463 AS_IF([test "x$build_dummy" = "xyes"], [
465 AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
467 AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
470 AS_IF([test "x$build_ep93xx" = "xyes"], [
472 AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
474 AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
477 AS_IF([test "x$build_at91rm9200" = "xyes"], [
479 AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
481 AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
484 AS_IF([test "x$build_bcm2835gpio" = "xyes"], [
486 AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
488 AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
491 AS_IF([test "x$build_imx_gpio" = "xyes"], [
493 AC_DEFINE([BUILD_IMX_GPIO], [1], [1 if you want imx_gpio.])
495 AC_DEFINE([BUILD_IMX_GPIO], [0], [0 if you don't want imx_gpio.])
498 AS_IF([test "x$parport_use_ppdev" = "xyes"], [
499 AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
501 AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
504 AS_IF([test "x$parport_use_giveio" = "xyes"], [
505 AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
507 AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
510 AS_IF([test "x$build_jtag_vpi" = "xyes"], [
511 AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
513 AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
516 AS_IF([test "x$build_jtag_dpi" = "xyes"], [
517 AC_DEFINE([BUILD_JTAG_DPI], [1], [1 if you want JTAG DPI.])
519 AC_DEFINE([BUILD_JTAG_DPI], [0], [0 if you don't want JTAG DPI.])
523 AS_IF([test "x$build_amtjtagaccel" = "xyes"], [
524 AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
526 AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
529 AS_IF([test "x$build_gw16012" = "xyes"], [
530 AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
532 AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
535 AS_IF([test "x$enable_buspirate" != "xno"], [
536 AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
538 AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
541 AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
542 AS_IF([test -f "$srcdir/jimtcl/configure.ac"], [
543 AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
545 AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
549 AS_IF([test "x$build_remote_bitbang" = "xyes"], [
551 AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
553 AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
556 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
558 AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
560 AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
563 AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
564 build_xlnx_pcie_xvc=yes
565 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [1], [1 if you want the Xilinx XVC/PCIe driver.])
567 AC_DEFINE([BUILD_XLNX_PCIE_XVC], [0], [0 if you don't want Xilinx XVC/PCIe driver.])
570 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
572 AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
573 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
574 [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
575 [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
576 LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
577 AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
578 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
579 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
582 AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
585 AC_ARG_WITH([capstone],
586 AS_HELP_STRING([--with-capstone], [Use Capstone disassembly library (default=auto)])
588 enable_capstone=$withval
593 AS_IF([test "x$enable_capstone" != xno], [
594 PKG_CHECK_MODULES([CAPSTONE], [capstone], [
595 AC_DEFINE([HAVE_CAPSTONE], [1], [1 if you have Capstone disassembly framework.])
597 AC_DEFINE([HAVE_CAPSTONE], [0], [0 if you don't have Capstone disassembly framework.])
598 if test "x$enable_capstone" != xauto; then
599 AC_MSG_ERROR([--with-capstone was given, but test for Capstone failed])
605 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
606 PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
614 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [
616 PKG_CHECK_EXISTS([libftdi1 >= 1.5],
617 [AC_DEFINE([HAVE_LIBFTDI_TCIOFLUSH], [1], [Define if your libftdi has ftdi_tcioflush()])])
619 PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
622 PKG_CHECK_MODULES([LIBGPIOD], [libgpiod], [use_libgpiod=yes], [use_libgpiod=no])
624 PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2],
625 [use_libjaylink=yes], [use_libjaylink=no])
627 m4_define([PROCESS_ADAPTERS], [
628 m4_foreach([adapter], [$1], [
630 AS_IF([test "x$ADAPTER_VAR([adapter])" != "xno"], [
631 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
633 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
636 AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [
637 AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
639 ADAPTER_VAR([adapter])=no
640 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
642 AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test "x$ADAPTER_VAR([adapter])" != "xno"])
646 PROCESS_ADAPTERS([USB1_ADAPTERS], ["x$use_libusb1" = "xyes"], [libusb-1.x])
647 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], ["x$use_hidapi" = "xyes"], [hidapi])
648 PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libusb1" = "xyes"], [hidapi and libusb-1.x])
649 PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
650 PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
651 PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [libgpiod])
652 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2])
654 AS_IF([test "x$enable_linuxgpiod" != "xno"], [
658 AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enable_nulink" != "xno"], [
659 AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
660 AM_CONDITIONAL([HLADAPTER], [true])
662 AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
663 AM_CONDITIONAL([HLADAPTER], [false])
665 AM_CONDITIONAL([HLADAPTER_STLINK], [test "x$enable_stlink" != "xno"])
666 AM_CONDITIONAL([HLADAPTER_ICDI], [test "x$enable_ti_icdi" != "xno"])
667 AM_CONDITIONAL([HLADAPTER_NULINK], [test "x$enable_nulink" != "xno"])
669 AS_IF([test "x$enable_jlink" != "xno"], [
670 AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
671 AS_IF([test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"], [
672 AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
673 [--enable-subproject-build])
675 AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
680 # Presto needs the bitq module
681 AS_IF([test "x$enable_presto" != "xno"], [
685 AM_CONDITIONAL([RELEASE], [test "x$build_release" = "xyes"])
686 AM_CONDITIONAL([PARPORT], [test "x$build_parport" = "xyes"])
687 AM_CONDITIONAL([DUMMY], [test "x$build_dummy" = "xyes"])
688 AM_CONDITIONAL([GIVEIO], [test "x$parport_use_giveio" = "xyes"])
689 AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
690 AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
691 AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
692 AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
693 AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
694 AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes" -o "x$build_jtag_vpi" = "xyes"])
695 AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes" -o "x$build_jtag_dpi" = "xyes"])
696 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
697 AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
698 AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
699 AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
700 AM_CONDITIONAL([BUSPIRATE], [test "x$enable_buspirate" != "xno"])
701 AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
702 AM_CONDITIONAL([XLNX_PCIE_XVC], [test "x$build_xlnx_pcie_xvc" = "xyes"])
703 AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
704 AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
705 AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"])
706 AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "xyes"])
707 AM_CONDITIONAL([IS_DARWIN], [test "x$is_darwin" = "xyes"])
708 AM_CONDITIONAL([BITQ], [test "x$build_bitq" = "xyes"])
709 AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
710 AM_CONDITIONAL([USE_LIBGPIOD], [test "x$use_libgpiod" = "xyes"])
711 AM_CONDITIONAL([USE_HIDAPI], [test "x$use_hidapi" = "xyes"])
712 AM_CONDITIONAL([USE_LIBJAYLINK], [test "x$use_libjaylink" = "xyes"])
713 AM_CONDITIONAL([RSHIM], [test "x$build_rshim" = "xyes"])
714 AM_CONDITIONAL([HAVE_CAPSTONE], [test "x$enable_capstone" != "xno"])
716 AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
717 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
719 # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
720 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
721 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
725 ]], [[char **ep = environ;]]
732 # Possibility #2: can environ be found in an available library?
733 AC_MSG_CHECKING([for extern environ])
734 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
735 extern char **environ;
736 ]], [[char **ep = environ;]]
738 AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
743 AC_MSG_RESULT([${has_environ}])
746 AS_IF([test "x${has_environ}" != "xyes" ], [
747 AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
750 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
752 # set default gcc warnings
753 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
754 AS_IF([test "x${gcc_wextra}" = "xyes"], [
755 GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
756 GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
757 GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
758 GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
759 GCC_WARNINGS="${GCC_WARNINGS} -Wpointer-arith"
760 GCC_WARNINGS="${GCC_WARNINGS} -Wundef"
761 GCC_WARNINGS="${GCC_WARNINGS} -Wno-error=deprecated-declarations"
763 AS_IF([test "x${gcc_werror}" = "xyes"], [
764 GCC_WARNINGS="${GCC_WARNINGS} -Werror"
767 # override default gcc cflags
768 AS_IF([test "x$gcc_warnings" = "xyes"], [
769 AC_SUBST([GCC_WARNINGS], [$GCC_WARNINGS])
772 AC_SUBST(EXTRA_DIST_NEWS, ["$(echo $srcdir/NEWS-*)"])
781 echo OpenOCD configuration summary
782 echo --------------------------------------------------
783 m4_foreach([adapter], [USB1_ADAPTERS,
784 HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS,
785 LIBFTDI_USB1_ADAPTERS,
787 LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
789 [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
790 AS_CASE([$ADAPTER_VAR([adapter])],
792 echo "$s"yes '(auto)'