2 AC_INIT([openocd], [0.10.0-dev],
3 [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
4 AC_CONFIG_SRCDIR([src/openocd.c])
6 m4_include([config_subdir.m4])dnl
8 # check for makeinfo before calling AM_INIT_AUTOMAKE
9 AC_CHECK_PROG([MAKEINFO], [makeinfo], [makeinfo])
10 if test "x$MAKEINFO" = "x"; then
11 MAKEINFO='echo makeinfo missing; true'
12 AC_MSG_WARN([Info documentation will not be built.])
16 AM_INIT_AUTOMAKE([-Wall -Wno-portability dist-bzip2 dist-zip subdir-objects])
18 AC_CONFIG_HEADERS([config.h])
20 #include <helper/system.h>
21 #include <helper/types.h>
22 #include <helper/replacements.h>
30 PKG_PROG_PKG_CONFIG([0.23])
32 dnl disable checks for C++, Fortran and GNU Java Compiler
33 m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
34 m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
35 m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
38 AC_SUBST([LIBTOOL_DEPS])
40 dnl configure checks required for Jim files (these are obsolete w/ C99)
44 AC_SEARCH_LIBS([ioperm], [ioperm])
45 AC_SEARCH_LIBS([dlopen], [dl])
47 AC_CHECK_HEADERS([sys/socket.h])
48 AC_CHECK_HEADERS([arpa/inet.h], [], [], [dnl
58 #ifdef HAVE_SYS_SOCKET_H
59 # include <sys/socket.h>
62 AC_CHECK_HEADERS([elf.h])
63 AC_CHECK_HEADERS([dirent.h])
64 AC_CHECK_HEADERS([fcntl.h])
65 AC_CHECK_HEADERS([ifaddrs.h], [], [], [dnl
75 #ifdef HAVE_SYS_SOCKET_H
76 # include <sys/socket.h>
79 AC_CHECK_HEADERS([malloc.h])
80 AC_CHECK_HEADERS([netdb.h])
81 AC_CHECK_HEADERS([netinet/in.h], [], [], [dnl
91 #ifdef HAVE_SYS_SOCKET_H
92 # include <sys/socket.h>
95 AC_CHECK_HEADERS([netinet/tcp.h], [], [], [dnl
101 # ifdef HAVE_STDLIB_H
105 #ifdef HAVE_SYS_SOCKET_H
106 # include <sys/socket.h>
109 AC_CHECK_HEADERS([poll.h])
110 AC_CHECK_HEADERS([pthread.h])
111 AC_CHECK_HEADERS([strings.h])
112 AC_CHECK_HEADERS([sys/ioctl.h])
113 AC_CHECK_HEADERS([sys/param.h])
114 AC_CHECK_HEADERS([sys/select.h])
115 AC_CHECK_HEADERS([sys/stat.h])
116 AC_CHECK_HEADERS([sys/time.h])
117 AC_CHECK_HEADERS([sys/types.h])
118 AC_CHECK_HEADERS([unistd.h])
119 AC_CHECK_HEADERS([net/if.h], [], [], [dnl
125 # ifdef HAVE_STDLIB_H
129 #ifdef HAVE_SYS_SOCKET_H
130 # include <sys/socket.h>
140 AC_CHECK_FUNCS([strndup])
141 AC_CHECK_FUNCS([strnlen])
142 AC_CHECK_FUNCS([gettimeofday])
143 AC_CHECK_FUNCS([usleep])
144 AC_CHECK_FUNCS([vasprintf])
153 # guess-rev.sh only exists in the repository, not in the released archives
154 AC_MSG_CHECKING([whether to build a release])
155 if test -x $srcdir/guess-rev.sh ; then
160 AC_MSG_RESULT([$build_release])
163 # 1st column -- configure option
164 # 2nd column -- description
165 # 3rd column -- symbol used for both config.h and automake
166 m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
167 m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
168 m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
169 m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
170 m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
172 m4_define([USB1_ADAPTERS],
173 [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
174 [[stlink], [ST-Link JTAG Programmer], [HLADAPTER_STLINK]],
175 [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
176 [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
177 [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
178 [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]]])
180 m4_define([USB_ADAPTERS],
181 [[[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
182 [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
183 [[aice], [Andes JTAG Programmer], [AICE]]])
185 m4_define([USB0_ADAPTERS],
186 [[[usbprog], [USBProg JTAG Programmer], [USBPROG]],
187 [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
188 [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]]])
190 m4_define([HIDAPI_ADAPTERS],
191 [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP]]])
193 m4_define([LIBJAYLINK_ADAPTERS],
194 [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
197 AC_ARG_ENABLE([doxygen-html],
198 AS_HELP_STRING([--disable-doxygen-html],
199 [Disable building Doxygen manual as HTML.]),
200 [doxygen_as_html=$enableval], [doxygen_as_html=yes])
201 AC_SUBST([doxygen_as_html])
202 AC_MSG_CHECKING([whether to build Doxygen as HTML])
203 AC_MSG_RESULT([$doxygen_as_html])
205 AC_ARG_ENABLE([doxygen-pdf],
206 AS_HELP_STRING([--enable-doxygen-pdf],
207 [Enable building Doxygen manual as PDF.]),
208 [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
209 AC_SUBST([doxygen_as_pdf])
210 AC_MSG_CHECKING([whether to build Doxygen as PDF])
211 AC_MSG_RESULT([$doxygen_as_pdf])
213 AC_ARG_ENABLE([gccwarnings],
214 AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
215 [gcc_warnings=$enableval], [gcc_warnings=yes])
217 AC_ARG_ENABLE([wextra],
218 AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
219 [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
221 AC_ARG_ENABLE([werror],
222 AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
223 [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
225 # set default verbose options, overridden by following options
230 AC_ARG_ENABLE([verbose],
231 AS_HELP_STRING([--enable-verbose],
232 [Enable verbose JTAG I/O messages (for debugging).]),
234 debug_jtag_io=$enableval
235 debug_usb_io=$enableval
236 debug_usb_comms=$enableval
239 AC_ARG_ENABLE([verbose_jtag_io],
240 AS_HELP_STRING([--enable-verbose-jtag-io],
241 [Enable verbose JTAG I/O messages (for debugging).]),
242 [debug_jtag_io=$enableval], [])
244 AC_ARG_ENABLE([verbose_usb_io],
245 AS_HELP_STRING([--enable-verbose-usb-io],
246 [Enable verbose USB I/O messages (for debugging)]),
247 [debug_usb_io=$enableval], [])
249 AC_ARG_ENABLE([verbose_usb_comms],
250 AS_HELP_STRING([--enable-verbose-usb-comms],
251 [Enable verbose USB communication messages (for debugging)]),
252 [debug_usb_comms=$enableval], [])
254 AC_MSG_CHECKING([whether to enable verbose JTAG I/O messages]);
255 AC_MSG_RESULT([$debug_jtag_io])
256 if test $debug_jtag_io = yes; then
257 AC_DEFINE([_DEBUG_JTAG_IO_],[1], [Print verbose JTAG I/O messages])
260 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
261 AC_MSG_RESULT([$debug_usb_io])
262 if test $debug_usb_io = yes; then
263 AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
266 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
267 AC_MSG_RESULT([$debug_usb_comms])
268 if test $debug_usb_comms = yes; then
269 AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
273 AC_ARG_ENABLE([malloc_logging],
274 AS_HELP_STRING([--enable-malloc-logging],
275 [Include free space in logging messages (requires malloc.h).]),
276 [debug_malloc=$enableval], [])
278 AC_MSG_CHECKING([whether to enable malloc free space logging]);
279 AC_MSG_RESULT([$debug_malloc])
280 if test $debug_malloc = yes; then
281 AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
284 AC_ARG_ENABLE([dummy],
285 AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
286 [build_dummy=$enableval], [build_dummy=no])
288 m4_define([AC_ARG_ADAPTERS], [
289 m4_foreach([adapter], [$1],
290 [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
291 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
292 [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
293 [], [ADAPTER_VAR([adapter])=$2])
297 AC_ARG_ADAPTERS([USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS, HIDAPI_ADAPTERS, LIBJAYLINK_ADAPTERS], [auto])
299 AC_ARG_ENABLE([parport],
300 AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
301 [build_parport=$enableval], [build_parport=no])
303 AC_ARG_ENABLE([parport_ppdev],
304 AS_HELP_STRING([--disable-parport-ppdev],
305 [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
306 [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
308 AC_ARG_ENABLE([parport_giveio],
309 AS_HELP_STRING([--enable-parport-giveio],
310 [Enable use of giveio for parport (for CygWin only)]),
311 [parport_use_giveio=$enableval], [parport_use_giveio=])
313 AC_ARG_ENABLE([jtag_vpi],
314 AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
315 [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
317 AC_ARG_ENABLE([usb_blaster_libftdi],
318 AS_HELP_STRING([--enable-usb_blaster_libftdi], [Enable building support for the Altera USB-Blaster using the libftdi driver]),
319 [build_usb_blaster=$enableval], [build_usb_blaster=no])
321 AC_ARG_ENABLE([amtjtagaccel],
322 AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
323 [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
325 AC_ARG_ENABLE([zy1000_master],
326 AS_HELP_STRING([--enable-zy1000-master], [Use ZY1000 JTAG master registers]),
327 [build_zy1000_master=$enableval], [build_zy1000_master=no])
329 AC_ARG_ENABLE([zy1000],
330 AS_HELP_STRING([--enable-zy1000], [Enable ZY1000 interface]),
331 [build_zy1000=$enableval], [build_zy1000=no])
333 AC_ARG_ENABLE([ioutil],
334 AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
335 [build_ioutil=$enableval], [build_ioutil=no])
337 case "${host_cpu}" in
339 AC_ARG_ENABLE([ep93xx],
340 AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
341 [build_ep93xx=$enableval], [build_ep93xx=no])
343 AC_ARG_ENABLE([at91rm9200],
344 AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
345 [build_at91rm9200=$enableval], [build_at91rm9200=no])
347 AC_ARG_ENABLE([bcm2835gpio],
348 AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
349 [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
359 AC_ARG_ENABLE([gw16012],
360 AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
361 [build_gw16012=$enableval], [build_gw16012=no])
363 AC_ARG_ENABLE([presto_libftdi],
364 AS_HELP_STRING([--enable-presto_libftdi], [Enable building support for ASIX Presto Programmer using the libftdi library]),
365 [build_presto=$enableval], [build_presto=no])
367 AC_ARG_ENABLE([openjtag_ftdi],
368 AS_HELP_STRING([--enable-openjtag_ftdi], [Enable building support for the OpenJTAG Programmer with libftdi library]),
369 [build_openjtag=$enableval], [build_openjtag=no])
371 AC_ARG_ENABLE([oocd_trace],
372 AS_HELP_STRING([--enable-oocd_trace],
373 [Enable building support for some prototype OpenOCD+trace ETM capture hardware]),
374 [build_oocd_trace=$enableval], [build_oocd_trace=no])
376 AC_ARG_ENABLE([buspirate],
377 AS_HELP_STRING([--enable-buspirate], [Enable building support for the Buspirate]),
378 [build_buspirate=$enableval], [build_buspirate=no])
380 AC_ARG_ENABLE([sysfsgpio],
381 AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
382 [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
384 AC_ARG_ENABLE([minidriver_dummy],
385 AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
386 [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
388 AC_ARG_ENABLE([internal-jimtcl],
389 AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
390 [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
392 AC_ARG_ENABLE([internal-libjaylink],
393 AS_HELP_STRING([--disable-internal-libjaylink],
394 [Disable building internal libjaylink]),
395 [use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
398 AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
399 if test $build_zy1000 = yes; then
400 if test $build_minidriver = yes; then
401 AC_MSG_ERROR([Multiple minidriver options have been enabled.])
403 AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
404 [Define to 1 if you have the <jtag_minidriver.h> header file.])
407 AC_MSG_RESULT([$build_zy1000])
409 AC_ARG_ENABLE([remote-bitbang],
410 AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
411 [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
413 AC_MSG_CHECKING([whether to enable dummy minidriver])
414 if test $build_minidriver_dummy = yes; then
415 if test $build_minidriver = yes; then
416 AC_MSG_ERROR([Multiple minidriver options have been enabled.])
419 AC_DEFINE([BUILD_MINIDRIVER_DUMMY], [1], [Use the dummy minidriver.])
420 AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
421 [Define to 1 if you have the <jtag_minidriver.h> header file.])
423 AC_MSG_RESULT([$build_minidriver_dummy])
425 AC_MSG_CHECKING([whether standard drivers can be built])
426 if test "$build_minidriver" = yes; then
428 AC_MSG_WARN([Using the minidriver disables all other drivers.])
434 case "${host_cpu}" in
438 if test x$parport_use_ppdev = xno; then
439 AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
441 parport_use_ppdev=yes
450 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
451 [is_mingw=yes],[is_mingw=no])
452 if test $is_mingw = yes; then
453 AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
454 if test x$parport_use_giveio = xno; then
455 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
457 parport_use_giveio=yes
461 AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
462 # sys/io.h needed under cygwin for parport access
463 if test $build_parport = yes; then
464 AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
468 AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
469 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
476 if test x$parport_use_giveio = xno; then
477 AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
479 parport_use_giveio=yes
481 if test x$build_buspirate = xyes; then
482 AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
485 CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
487 AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
488 AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
489 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
494 if test x$parport_use_giveio = xyes; then
495 AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
497 parport_use_giveio=no
499 AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
500 AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
501 AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
504 if test x$parport_use_giveio = xyes; then
505 AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
507 parport_use_giveio=no
508 AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
509 AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
510 AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
514 if test $is_win32 = yes; then
515 AC_DEFINE([WIN32_LEAN_AND_MEAN], [1], [1 to exclude old conflicting definitions when building on Windows])
518 if test $build_parport = yes; then
520 AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
522 AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
525 if test $build_dummy = yes; then
527 AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
529 AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
532 if test $build_ep93xx = yes; then
534 AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
536 AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
539 if test $build_zy1000 = yes; then
540 AC_DEFINE([BUILD_ZY1000], [1], [1 if you want ZY1000.])
542 AC_DEFINE([BUILD_ZY1000], [0], [0 if you don't want ZY1000.])
545 if test $build_zy1000_master = yes; then
546 AC_DEFINE([BUILD_ZY1000_MASTER], [1], [1 if you want ZY1000 JTAG master registers.])
548 AC_DEFINE([BUILD_ZY1000_MASTER], [0], [0 if you don't want ZY1000 JTAG master registers.])
551 if test $build_at91rm9200 = yes; then
553 AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
555 AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
558 if test $build_bcm2835gpio = yes; then
560 AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
562 AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
565 if test x$parport_use_ppdev = xyes; then
566 AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
568 AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
571 if test x$parport_use_giveio = xyes; then
572 AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
574 AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
577 if test $build_bitbang = yes; then
578 AC_DEFINE([BUILD_BITBANG], [1], [1 if you want a bitbang interface.])
580 AC_DEFINE([BUILD_BITBANG], [0], [0 if you don't want a bitbang interface.])
583 if test $build_usb_blaster = yes; then
584 AC_DEFINE([BUILD_USB_BLASTER], [1], [1 if you want libftdi usb_blaster.])
586 AC_DEFINE([BUILD_USB_BLASTER], [0], [0 if you don't want libftdi usb_blaster.])
589 if test $build_jtag_vpi = yes; then
590 AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
592 AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
595 if test $build_amtjtagaccel = yes; then
596 AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
598 AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
601 if test $build_gw16012 = yes; then
602 AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
604 AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
607 if test $build_presto = yes; then
609 AC_DEFINE([BUILD_PRESTO], [1], [1 if you want the ASIX PRESTO driver using libftdi.])
611 AC_DEFINE([BUILD_PRESTO], [0], [0 if you don't want the ASIX PRESTO driver using libftdi.])
614 if test $build_bitq = yes; then
615 AC_DEFINE([BUILD_BITQ], [1], [1 if you want a bitq interface.])
617 AC_DEFINE([BUILD_BITQ], [0], [0 if you don't want a bitq interface.])
621 if test $build_openjtag = yes; then
622 AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG driver.])
624 AC_DEFINE([BUILD_OPENJTAG], [0], [0 if you don't want the OpenJTAG driver.])
627 if test $build_oocd_trace = yes; then
628 AC_DEFINE([BUILD_OOCD_TRACE], [1], [1 if you want the OpenOCD+trace ETM capture driver.])
630 AC_DEFINE([BUILD_OOCD_TRACE], [0], [0 if you don't want the OpenOCD+trace ETM capture driver.])
633 if test $build_buspirate = yes; then
634 AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
636 AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
639 if test $use_internal_jimtcl = yes; then
640 if test -f "$srcdir/jimtcl/configure.ac"; then
641 AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
643 AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
647 if test $build_remote_bitbang = yes; then
649 AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
651 AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
654 if test $build_sysfsgpio = yes; then
656 AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
658 AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
661 if test $build_usb_blaster = yes -o $build_openjtag = yes -o $build_presto = yes; then
663 # we can have libftdi or libftdi1, so check it and use the latest one
664 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [use_libftdi=no])
665 if test $use_libftdi = no; then
666 PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
668 if test $use_libftdi = no; then
669 AC_MSG_ERROR([The libftdi driver is not present on your system.])
673 # Try to build a small program.
674 AC_MSG_CHECKING([Build & Link with libftdi...])
676 LDFLAGS_SAVE=$LDFLAGS
679 _LDFLAGS=`eval echo $LDFLAGS`
680 _CFLAGS=`eval echo $CFLAGS`
681 _LIBS=`eval echo $LIBS`
683 CFLAGS="$_CFLAGS $LIBFTDI_CFLAGS"
684 LIBS="$_LIBS $LIBFTDI_LIBS"
686 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
690 struct ftdi_context *p;
695 fprintf( stderr, "calling ftdi_new() failed\n");
699 AC_MSG_RESULT([Success])
701 AC_MSG_ERROR([Cannot build & run test program using libftdi])
703 AC_MSG_RESULT([Skipping as we are cross-compiling, trying build only])
704 AC_SEARCH_LIBS([ftdi_new], [], [], [AC_MSG_ERROR([Cannot link with libftdi])])
707 AC_MSG_CHECKING([for libftdi FT232H device support])
708 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
712 enum ftdi_chip_type x = TYPE_232H;
714 AC_DEFINE([HAS_ENUM_FT232H], [1],
715 [Support FT232H with libftdi.])
720 AC_MSG_RESULT([$has_enum_ft232h])
722 if test $has_enum_ft232h = no; then
723 AC_MSG_WARN([You need a newer libftdi version (0.20 or later).])
726 # Restore the 'unexpanded ldflags'
727 LDFLAGS=$LDFLAGS_SAVE
732 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
734 AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
735 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
736 [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
737 [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
738 LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
739 AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
740 PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
741 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
744 AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
747 PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
749 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
750 PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
758 PKG_CHECK_MODULES([libjaylink], [libjaylink >= 0.1],
759 [HAVE_LIBJAYLINK=yes], [HAVE_LIBJAYLINK=no])
761 m4_define([PROCESS_ADAPTERS], [
762 m4_foreach([adapter], [$1], [
764 if test $ADAPTER_VAR([adapter]) != no; then
765 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
767 AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
770 if test $ADAPTER_VAR([adapter]) = yes; then
771 AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
773 ADAPTER_VAR([adapter])=no
775 AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test $ADAPTER_VAR([adapter]) != no])
779 PROCESS_ADAPTERS([USB1_ADAPTERS], [$use_libusb1 = yes], [libusb-1.x])
780 PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o $use_libusb0 = yes], [libusb-1.x or libusb-0.1])
781 PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], [libusb-0.1])
782 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], [$use_hidapi = yes], [hidapi])
783 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], [$use_libusb1 = yes -a $use_internal_libjaylink = yes -o $HAVE_LIBJAYLINK = yes], [libusb-1.x or libjaylink-0.1])
785 if test $enable_stlink != no -o $enable_ti_icdi != no; then
786 AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
788 AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
790 AM_CONDITIONAL([HLADAPTER], [test $enable_stlink != no -o $enable_ti_icdi != no])
792 if test $enable_jlink != no; then
793 if test $use_internal_libjaylink = yes; then
794 if test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"; then
795 AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
796 [--enable-subproject-build])
798 AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
803 AM_CONDITIONAL([RELEASE], [test $build_release = yes])
804 AM_CONDITIONAL([PARPORT], [test $build_parport = yes])
805 AM_CONDITIONAL([DUMMY], [test $build_dummy = yes])
806 AM_CONDITIONAL([GIVEIO], [test x$parport_use_giveio = xyes])
807 AM_CONDITIONAL([EP93XX], [test $build_ep93xx = yes])
808 AM_CONDITIONAL([ZY1000], [test $build_zy1000 = yes])
809 AM_CONDITIONAL([ZY1000_MASTER], [test $build_zy1000_master = yes])
810 AM_CONDITIONAL([IOUTIL], [test $build_ioutil = yes])
811 AM_CONDITIONAL([AT91RM9200], [test $build_at91rm9200 = yes])
812 AM_CONDITIONAL([BCM2835GPIO], [test $build_bcm2835gpio = yes])
813 AM_CONDITIONAL([BITBANG], [test $build_bitbang = yes])
814 AM_CONDITIONAL([JTAG_VPI], [test $build_jtag_vpi = yes -o $build_jtag_vpi = yes])
815 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test $build_usb_blaster = yes -o $enable_usb_blaster_2 != no])
816 AM_CONDITIONAL([USB_BLASTER], [test $build_usb_blaster = yes])
817 AM_CONDITIONAL([AMTJTAGACCEL], [test $build_amtjtagaccel = yes])
818 AM_CONDITIONAL([GW16012], [test $build_gw16012 = yes])
819 AM_CONDITIONAL([PRESTO], [test $build_presto = yes])
820 AM_CONDITIONAL([OPENJTAG], [test $build_openjtag = yes])
821 AM_CONDITIONAL([OOCD_TRACE], [test $build_oocd_trace = yes])
822 AM_CONDITIONAL([REMOTE_BITBANG], [test $build_remote_bitbang = yes])
823 AM_CONDITIONAL([BUSPIRATE], [test $build_buspirate = yes])
824 AM_CONDITIONAL([SYSFSGPIO], [test $build_sysfsgpio = yes])
825 AM_CONDITIONAL([USE_LIBUSB0], [test $use_libusb0 = yes])
826 AM_CONDITIONAL([USE_LIBUSB1], [test $use_libusb1 = yes])
827 AM_CONDITIONAL([IS_CYGWIN], [test $is_cygwin = yes])
828 AM_CONDITIONAL([IS_MINGW], [test $is_mingw = yes])
829 AM_CONDITIONAL([IS_WIN32], [test $is_win32 = yes])
830 AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = yes])
831 AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
832 AM_CONDITIONAL([CMSIS_DAP], [test $use_hidapi = yes])
834 AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
835 AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
837 AM_CONDITIONAL([INTERNAL_JIMTCL], [test $use_internal_jimtcl = yes])
838 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test $use_internal_libjaylink = yes])
840 # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
841 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
842 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
846 ]], [[char **ep = environ;]]
853 # Possibility #2: can environ be found in an available library?
854 AC_MSG_CHECKING([for extern environ])
855 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
856 extern char **environ;
857 ]], [[char **ep = environ;]]
859 AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
864 AC_MSG_RESULT([${has_environ}])
867 if test "${has_environ}" != "yes" ; then
868 AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
871 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
873 # set default gcc warnings
874 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
875 if test "${gcc_wextra}" = yes; then
876 GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
877 GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
878 GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
879 GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
881 if test "${gcc_werror}" = yes; then
882 GCC_WARNINGS="${GCC_WARNINGS} -Werror"
885 # overide default gcc cflags
886 if test $gcc_warnings = yes; then
887 CFLAGS="$CFLAGS $GCC_WARNINGS"
895 src/jtag/drivers/Makefile
896 src/jtag/drivers/usb_blaster/Makefile
897 src/jtag/hla/Makefile
898 src/jtag/aice/Makefile
899 src/transport/Makefile
900 src/target/openrisc/Makefile
907 src/flash/nor/Makefile
908 src/flash/nand/Makefile
916 echo OpenOCD configuration summary
917 echo --------------------------------------------------
918 m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS,
919 HIDAPI_ADAPTERS, LIBJAYLINK_ADAPTERS],
920 [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
921 case $ADAPTER_VAR([adapter]) in
923 echo "$s"yes '(auto)'