]> git.sur5r.net Git - openocd/blob - configure.ac
configure: Remove conflicting CMSIS_DAP conditional
[openocd] / configure.ac
1 AC_PREREQ(2.64)
2 AC_INIT([openocd], [0.10.0-dev],
3   [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
4 AC_CONFIG_SRCDIR([src/openocd.c])
5
6 m4_include([config_subdir.m4])dnl
7
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.])
13 fi
14 AC_SUBST([MAKEINFO])
15
16 AM_INIT_AUTOMAKE([-Wall -Wno-portability dist-bzip2 dist-zip subdir-objects])
17
18 AC_CONFIG_HEADERS([config.h])
19 AH_BOTTOM([
20 #include <helper/system.h>
21 #include <helper/types.h>
22 #include <helper/replacements.h>
23 ])
24
25 AC_LANG_C
26 AC_PROG_CC
27 AC_PROG_CC_C99
28 AM_PROG_CC_C_O
29 AC_PROG_RANLIB
30 PKG_PROG_PKG_CONFIG([0.23])
31
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], [:])
36 AC_DISABLE_SHARED
37 AC_PROG_LIBTOOL
38 AC_SUBST([LIBTOOL_DEPS])
39
40 dnl configure checks required for Jim files (these are obsolete w/ C99)
41 AC_C_CONST
42 AC_TYPE_LONG_LONG_INT
43
44 AC_SEARCH_LIBS([ioperm], [ioperm])
45 AC_SEARCH_LIBS([dlopen], [dl])
46
47 AC_CHECK_HEADERS([sys/socket.h])
48 AC_CHECK_HEADERS([arpa/inet.h], [], [], [dnl
49 #include <stdio.h>
50 #ifdef STDC_HEADERS
51 # include <stdlib.h>
52 # include <stddef.h>
53 #else
54 # ifdef HAVE_STDLIB_H
55 #  include <stdlib.h>
56 # endif
57 #endif
58 #ifdef HAVE_SYS_SOCKET_H
59 # include <sys/socket.h>
60 #endif
61 ])
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
66 #include <stdio.h>
67 #ifdef STDC_HEADERS
68 # include <stdlib.h>
69 # include <stddef.h>
70 #else
71 # ifdef HAVE_STDLIB_H
72 #  include <stdlib.h>
73 # endif
74 #endif
75 #ifdef HAVE_SYS_SOCKET_H
76 # include <sys/socket.h>
77 #endif
78 ])
79 AC_CHECK_HEADERS([malloc.h])
80 AC_CHECK_HEADERS([netdb.h])
81 AC_CHECK_HEADERS([netinet/in.h], [], [], [dnl
82 #include <stdio.h>
83 #ifdef STDC_HEADERS
84 # include <stdlib.h>
85 # include <stddef.h>
86 #else
87 # ifdef HAVE_STDLIB_H
88 #  include <stdlib.h>
89 # endif
90 #endif
91 #ifdef HAVE_SYS_SOCKET_H
92 # include <sys/socket.h>
93 #endif
94 ])
95 AC_CHECK_HEADERS([netinet/tcp.h], [], [], [dnl
96 #include <stdio.h>
97 #ifdef STDC_HEADERS
98 # include <stdlib.h>
99 # include <stddef.h>
100 #else
101 # ifdef HAVE_STDLIB_H
102 #  include <stdlib.h>
103 # endif
104 #endif
105 #ifdef HAVE_SYS_SOCKET_H
106 # include <sys/socket.h>
107 #endif
108 ])
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
120 #include <stdio.h>
121 #ifdef STDC_HEADERS
122 # include <stdlib.h>
123 # include <stddef.h>
124 #else
125 # ifdef HAVE_STDLIB_H
126 #  include <stdlib.h>
127 # endif
128 #endif
129 #ifdef HAVE_SYS_SOCKET_H
130 # include <sys/socket.h>
131 #endif
132 ])
133
134 AC_HEADER_ASSERT
135 AC_HEADER_STDBOOL
136 AC_HEADER_TIME
137
138 AC_C_BIGENDIAN
139
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])
145
146 build_bitbang=no
147 build_bitq=no
148 is_cygwin=no
149 is_mingw=no
150 is_win32=no
151 is_darwin=no
152
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
156   build_release=no
157 else
158   build_release=yes
159 fi
160 AC_MSG_RESULT([$build_release])
161
162 # Adapter drivers
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), [_], [-])])
171
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]]])
179
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]]])
184
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]]])
189
190 m4_define([HIDAPI_ADAPTERS],
191         [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP]]])
192
193 m4_define([LIBFTDI_ADAPTERS],
194         [[[usb_blaster], [Altera USB-Blaster Compatible], [USB_BLASTER]],
195         [[presto], [ASIX Presto Adapter], [PRESTO]],
196         [[openjtag], [OpenJTAG Adapter], [OPENJTAG]]])
197
198 m4_define([LIBJAYLINK_ADAPTERS],
199         [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
200
201
202 AC_ARG_ENABLE([doxygen-html],
203   AS_HELP_STRING([--disable-doxygen-html],
204     [Disable building Doxygen manual as HTML.]),
205   [doxygen_as_html=$enableval], [doxygen_as_html=yes])
206 AC_SUBST([doxygen_as_html])
207 AC_MSG_CHECKING([whether to build Doxygen as HTML])
208 AC_MSG_RESULT([$doxygen_as_html])
209
210 AC_ARG_ENABLE([doxygen-pdf],
211   AS_HELP_STRING([--enable-doxygen-pdf],
212     [Enable building Doxygen manual as PDF.]),
213   [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
214 AC_SUBST([doxygen_as_pdf])
215 AC_MSG_CHECKING([whether to build Doxygen as PDF])
216 AC_MSG_RESULT([$doxygen_as_pdf])
217
218 AC_ARG_ENABLE([gccwarnings],
219   AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
220   [gcc_warnings=$enableval], [gcc_warnings=yes])
221
222 AC_ARG_ENABLE([wextra],
223   AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
224   [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
225
226 AC_ARG_ENABLE([werror],
227   AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
228   [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
229
230 # set default verbose options, overridden by following options
231 debug_jtag_io=no
232 debug_usb_io=no
233 debug_usb_comms=no
234
235 AC_ARG_ENABLE([verbose],
236   AS_HELP_STRING([--enable-verbose],
237       [Enable verbose JTAG I/O messages (for debugging).]),
238   [
239   debug_jtag_io=$enableval
240   debug_usb_io=$enableval
241   debug_usb_comms=$enableval
242   ], [])
243
244 AC_ARG_ENABLE([verbose_jtag_io],
245   AS_HELP_STRING([--enable-verbose-jtag-io],
246       [Enable verbose JTAG I/O messages (for debugging).]),
247   [debug_jtag_io=$enableval], [])
248
249 AC_ARG_ENABLE([verbose_usb_io],
250   AS_HELP_STRING([--enable-verbose-usb-io],
251       [Enable verbose USB I/O messages (for debugging)]),
252   [debug_usb_io=$enableval], [])
253
254 AC_ARG_ENABLE([verbose_usb_comms],
255   AS_HELP_STRING([--enable-verbose-usb-comms],
256       [Enable verbose USB communication messages (for debugging)]),
257   [debug_usb_comms=$enableval], [])
258
259 AC_MSG_CHECKING([whether to enable verbose JTAG I/O messages]);
260 AC_MSG_RESULT([$debug_jtag_io])
261 if test $debug_jtag_io = yes; then
262   AC_DEFINE([_DEBUG_JTAG_IO_],[1], [Print verbose JTAG I/O messages])
263 fi
264
265 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
266 AC_MSG_RESULT([$debug_usb_io])
267 if test $debug_usb_io = yes; then
268   AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
269 fi
270
271 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
272 AC_MSG_RESULT([$debug_usb_comms])
273 if test $debug_usb_comms = yes; then
274   AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
275 fi
276
277 debug_malloc=no
278 AC_ARG_ENABLE([malloc_logging],
279   AS_HELP_STRING([--enable-malloc-logging],
280       [Include free space in logging messages (requires malloc.h).]),
281   [debug_malloc=$enableval], [])
282
283 AC_MSG_CHECKING([whether to enable malloc free space logging]);
284 AC_MSG_RESULT([$debug_malloc])
285 if test $debug_malloc = yes; then
286   AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
287 fi
288
289 AC_ARG_ENABLE([dummy],
290   AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
291   [build_dummy=$enableval], [build_dummy=no])
292
293 m4_define([AC_ARG_ADAPTERS], [
294   m4_foreach([adapter], [$1],
295         [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
296                 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
297                         [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
298                 [], [ADAPTER_VAR([adapter])=$2])
299   ])
300 ])
301
302 AC_ARG_ADAPTERS([
303   USB1_ADAPTERS,
304   USB_ADAPTERS,
305   USB0_ADAPTERS,
306   HIDAPI_ADAPTERS,
307   LIBFTDI_ADAPTERS,
308   LIBJAYLINK_ADAPTERS
309   ],[auto])
310
311 AC_ARG_ENABLE([parport],
312   AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
313   [build_parport=$enableval], [build_parport=no])
314
315 AC_ARG_ENABLE([parport_ppdev],
316   AS_HELP_STRING([--disable-parport-ppdev],
317       [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
318     [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
319
320 AC_ARG_ENABLE([parport_giveio],
321     AS_HELP_STRING([--enable-parport-giveio],
322       [Enable use of giveio for parport (for CygWin only)]),
323     [parport_use_giveio=$enableval], [parport_use_giveio=])
324
325 AC_ARG_ENABLE([jtag_vpi],
326   AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
327   [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
328
329 AC_ARG_ENABLE([amtjtagaccel],
330   AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
331   [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
332
333 AC_ARG_ENABLE([zy1000_master],
334   AS_HELP_STRING([--enable-zy1000-master], [Use ZY1000 JTAG master registers]),
335   [build_zy1000_master=$enableval], [build_zy1000_master=no])
336
337 AC_ARG_ENABLE([zy1000],
338   AS_HELP_STRING([--enable-zy1000], [Enable ZY1000 interface]),
339   [build_zy1000=$enableval], [build_zy1000=no])
340
341 AC_ARG_ENABLE([ioutil],
342   AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
343   [build_ioutil=$enableval], [build_ioutil=no])
344
345 case "${host_cpu}" in
346   arm*)
347     AC_ARG_ENABLE([ep93xx],
348       AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
349       [build_ep93xx=$enableval], [build_ep93xx=no])
350
351     AC_ARG_ENABLE([at91rm9200],
352       AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
353       [build_at91rm9200=$enableval], [build_at91rm9200=no])
354
355     AC_ARG_ENABLE([bcm2835gpio],
356       AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
357       [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
358     ;;
359
360   *)
361     build_ep93xx=no
362     build_at91rm9200=no
363     build_bcm2835gpio=no
364     ;;
365 esac
366
367 AC_ARG_ENABLE([gw16012],
368   AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
369   [build_gw16012=$enableval], [build_gw16012=no])
370
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])
375
376 AC_ARG_ENABLE([buspirate],
377   AS_HELP_STRING([--enable-buspirate], [Enable building support for the Buspirate]),
378   [build_buspirate=$enableval], [build_buspirate=no])
379
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])
383
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])
387
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])
391
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])
396
397 build_minidriver=no
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.])
402   fi
403   AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
404       [Define to 1 if you have the <jtag_minidriver.h> header file.])
405   build_minidriver=yes
406 fi
407 AC_MSG_RESULT([$build_zy1000])
408
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])
412
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.])
417   fi
418   build_minidriver=yes
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.])
422 fi
423 AC_MSG_RESULT([$build_minidriver_dummy])
424
425 AC_MSG_CHECKING([whether standard drivers can be built])
426 if test "$build_minidriver" = yes; then
427   AC_MSG_RESULT([no])
428   AC_MSG_WARN([Using the minidriver disables all other drivers.])
429   sleep 2
430 else
431   AC_MSG_RESULT([yes])
432 fi
433
434 case "${host_cpu}" in
435   i?86|x86*)
436     ;;
437   *)
438     if test x$parport_use_ppdev = xno; then
439       AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
440     fi
441     parport_use_ppdev=yes
442     ;;
443 esac
444
445 case $host in
446   *-cygwin*)
447     is_win32=yes
448     parport_use_ppdev=no
449
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])
456       fi
457       parport_use_giveio=yes
458       is_cygwin=no
459     else
460       is_cygwin=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]))
465       fi
466     fi
467
468     AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
469     AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
470     ;;
471   *-mingw* | *-msys*)
472     is_mingw=yes
473     is_win32=yes
474     parport_use_ppdev=no
475
476     if test x$parport_use_giveio = xno; then
477       AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
478     fi
479     parport_use_giveio=yes
480
481     if test x$build_buspirate = xyes; then
482       AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
483     fi
484
485     CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
486
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.])
490     ;;
491   *darwin*)
492     is_darwin=yes
493
494     if test x$parport_use_giveio = xyes; then
495       AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
496     fi
497     parport_use_giveio=no
498
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.])
502     ;;
503   *)
504     if test x$parport_use_giveio = xyes; then
505       AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
506     fi
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.])
511     ;;
512 esac
513
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])
516 fi
517
518 if test $build_parport = yes; then
519   build_bitbang=yes
520   AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
521 else
522   AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
523 fi
524
525 if test $build_dummy = yes; then
526   build_bitbang=yes
527   AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
528 else
529   AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
530 fi
531
532 if test $build_ep93xx = yes; then
533   build_bitbang=yes
534   AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
535 else
536   AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
537 fi
538
539 if test $build_zy1000 = yes; then
540   AC_DEFINE([BUILD_ZY1000], [1], [1 if you want ZY1000.])
541 else
542   AC_DEFINE([BUILD_ZY1000], [0], [0 if you don't want ZY1000.])
543 fi
544
545 if test $build_zy1000_master = yes; then
546   AC_DEFINE([BUILD_ZY1000_MASTER], [1], [1 if you want ZY1000 JTAG master registers.])
547 else
548   AC_DEFINE([BUILD_ZY1000_MASTER], [0], [0 if you don't want ZY1000 JTAG master registers.])
549 fi
550
551 if test $build_at91rm9200 = yes; then
552   build_bitbang=yes
553   AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
554 else
555   AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
556 fi
557
558 if test $build_bcm2835gpio = yes; then
559   build_bitbang=yes
560   AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
561 else
562   AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
563 fi
564
565 if test x$parport_use_ppdev = xyes; then
566   AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
567 else
568   AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
569 fi
570
571 if test x$parport_use_giveio = xyes; then
572   AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
573 else
574   AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
575 fi
576
577 if test $build_bitbang = yes; then
578   AC_DEFINE([BUILD_BITBANG], [1], [1 if you want a bitbang interface.])
579 else
580   AC_DEFINE([BUILD_BITBANG], [0], [0 if you don't want a bitbang interface.])
581 fi
582
583 if test $build_jtag_vpi = yes; then
584   AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
585 else
586   AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
587 fi
588
589 if test $build_amtjtagaccel = yes; then
590   AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
591 else
592   AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
593 fi
594
595 if test $build_gw16012 = yes; then
596   AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
597 else
598   AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
599 fi
600
601 if test $build_bitq = yes; then
602   AC_DEFINE([BUILD_BITQ], [1], [1 if you want a bitq interface.])
603 else
604   AC_DEFINE([BUILD_BITQ], [0], [0 if you don't want a bitq interface.])
605 fi
606
607 if test $build_oocd_trace = yes; then
608   AC_DEFINE([BUILD_OOCD_TRACE], [1], [1 if you want the OpenOCD+trace ETM capture driver.])
609 else
610   AC_DEFINE([BUILD_OOCD_TRACE], [0], [0 if you don't want the OpenOCD+trace ETM capture driver.])
611 fi
612
613 if test $build_buspirate = yes; then
614   AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
615 else
616   AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
617 fi
618
619 if test $use_internal_jimtcl = yes; then
620   if test -f "$srcdir/jimtcl/configure.ac"; then
621     AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
622   else
623     AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
624   fi
625 fi
626
627 if test $build_remote_bitbang = yes; then
628   build_bitbang=yes
629   AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
630 else
631   AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
632 fi
633
634 if test $build_sysfsgpio = yes; then
635   build_bitbang=yes
636   AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
637 else
638   AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
639 fi
640
641 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
642         use_libusb1=yes
643         AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
644         PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
645                 [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
646                 [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
647         LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
648         AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
649         PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
650                 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
651   ], [
652         use_libusb1=no
653         AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
654 ])
655
656 PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
657
658 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
659         PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
660                 use_hidapi=yes
661                 break
662         ],[
663                 use_hidapi=no
664         ])
665 done
666
667 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [
668         PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
669 ])
670
671 PKG_CHECK_MODULES([libjaylink], [libjaylink >= 0.1],
672         [HAVE_LIBJAYLINK=yes], [HAVE_LIBJAYLINK=no])
673
674 m4_define([PROCESS_ADAPTERS], [
675   m4_foreach([adapter], [$1], [
676         if test $2; then
677                 if test $ADAPTER_VAR([adapter]) != no; then
678                         AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
679                 else
680                         AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
681                 fi
682         else
683                 if test $ADAPTER_VAR([adapter]) = yes; then
684                         AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
685                 fi
686                 ADAPTER_VAR([adapter])=no
687         fi
688         AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test $ADAPTER_VAR([adapter]) != no])
689   ])
690 ])
691
692 PROCESS_ADAPTERS([USB1_ADAPTERS], [$use_libusb1 = yes], [libusb-1.x])
693 PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o $use_libusb0 = yes], [libusb-1.x or libusb-0.1])
694 PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], [libusb-0.1])
695 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], [$use_hidapi = yes], [hidapi])
696 PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], [$use_libftdi = yes], [libftdi])
697 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], [$use_libusb1 = yes -a $use_internal_libjaylink = yes -o $HAVE_LIBJAYLINK = yes], [libusb-1.x or libjaylink-0.1])
698
699 if test $build_openjtag = yes; then
700         if test $use_libusb1 != yes -a $use_libusb0 != yes; then
701                 AC_MSG_ERROR([libusb-1.x or libusb-0.1 is required for the OpenJTAG Programmer])
702                 build_openjtag=no
703         fi
704 fi
705
706 if test $enable_stlink != no -o $enable_ti_icdi != no; then
707         AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
708 else
709         AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
710 fi
711 AM_CONDITIONAL([HLADAPTER], [test $enable_stlink != no -o $enable_ti_icdi != no])
712
713 if test $enable_jlink != no; then
714   if test $use_internal_libjaylink = yes; then
715     if test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"; then
716       AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
717                 [--enable-subproject-build])
718     else
719       AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
720     fi
721   fi
722 fi
723
724 # Presto needs the bitq module
725 if test $enable_presto != no; then
726   build_bitq=yes
727 fi
728
729 AM_CONDITIONAL([RELEASE], [test $build_release = yes])
730 AM_CONDITIONAL([PARPORT], [test $build_parport = yes])
731 AM_CONDITIONAL([DUMMY], [test $build_dummy = yes])
732 AM_CONDITIONAL([GIVEIO], [test x$parport_use_giveio = xyes])
733 AM_CONDITIONAL([EP93XX], [test $build_ep93xx = yes])
734 AM_CONDITIONAL([ZY1000], [test $build_zy1000 = yes])
735 AM_CONDITIONAL([ZY1000_MASTER], [test $build_zy1000_master = yes])
736 AM_CONDITIONAL([IOUTIL], [test $build_ioutil = yes])
737 AM_CONDITIONAL([AT91RM9200], [test $build_at91rm9200 = yes])
738 AM_CONDITIONAL([BCM2835GPIO], [test $build_bcm2835gpio = yes])
739 AM_CONDITIONAL([BITBANG], [test $build_bitbang = yes])
740 AM_CONDITIONAL([JTAG_VPI], [test $build_jtag_vpi = yes -o $build_jtag_vpi = yes])
741 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test $enable_usb_blaster != no -o $enable_usb_blaster_2 != no])
742 AM_CONDITIONAL([AMTJTAGACCEL], [test $build_amtjtagaccel = yes])
743 AM_CONDITIONAL([GW16012], [test $build_gw16012 = yes])
744 AM_CONDITIONAL([OOCD_TRACE], [test $build_oocd_trace = yes])
745 AM_CONDITIONAL([REMOTE_BITBANG], [test $build_remote_bitbang = yes])
746 AM_CONDITIONAL([BUSPIRATE], [test $build_buspirate = yes])
747 AM_CONDITIONAL([SYSFSGPIO], [test $build_sysfsgpio = yes])
748 AM_CONDITIONAL([USE_LIBUSB0], [test $use_libusb0 = yes])
749 AM_CONDITIONAL([USE_LIBUSB1], [test $use_libusb1 = yes])
750 AM_CONDITIONAL([IS_CYGWIN], [test $is_cygwin = yes])
751 AM_CONDITIONAL([IS_MINGW], [test $is_mingw = yes])
752 AM_CONDITIONAL([IS_WIN32], [test $is_win32 = yes])
753 AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = yes])
754 AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
755 AM_CONDITIONAL([USE_LIBFTDI], [test $use_libftdi = yes])
756
757 AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
758 AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
759
760 AM_CONDITIONAL([INTERNAL_JIMTCL], [test $use_internal_jimtcl = yes])
761 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test $use_internal_libjaylink = yes])
762
763 # Look for environ alternatives.  Possibility #1: is environ in unistd.h or stdlib.h?
764 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
766 #define _GNU_SOURCE
767 #include <unistd.h>
768 #include <stdlib.h>
769   ]], [[char **ep = environ;]]
770   )], [
771     AC_MSG_RESULT([yes])
772     has_environ=yes
773   ], [
774     AC_MSG_RESULT([no])
775
776     # Possibility #2: can environ be found in an available library?
777     AC_MSG_CHECKING([for extern environ])
778     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
779     extern char **environ;
780     ]], [[char **ep = environ;]]
781       )], [
782         AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
783         has_environ=yes
784       ], [
785         has_environ=no
786       ])
787     AC_MSG_RESULT([${has_environ}])
788   ])
789
790 if test "${has_environ}" != "yes" ; then
791   AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
792 fi
793
794 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
795
796 # set default gcc warnings
797 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
798 if test "${gcc_wextra}" = yes; then
799   GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
800   GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
801   GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
802   GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
803 fi
804 if test "${gcc_werror}" = yes; then
805   GCC_WARNINGS="${GCC_WARNINGS} -Werror"
806 fi
807
808 # overide default gcc cflags
809 if test $gcc_warnings = yes; then
810   CFLAGS="$CFLAGS $GCC_WARNINGS"
811 fi
812
813 AC_CONFIG_FILES([
814   Makefile
815   src/Makefile
816   src/helper/Makefile
817   src/jtag/Makefile
818   src/jtag/drivers/Makefile
819   src/jtag/drivers/usb_blaster/Makefile
820   src/jtag/hla/Makefile
821   src/jtag/aice/Makefile
822   src/transport/Makefile
823   src/target/openrisc/Makefile
824   src/xsvf/Makefile
825   src/svf/Makefile
826   src/target/Makefile
827   src/rtos/Makefile
828   src/server/Makefile
829   src/flash/Makefile
830   src/flash/nor/Makefile
831   src/flash/nand/Makefile
832   src/pld/Makefile
833   doc/Makefile
834 ])
835 AC_OUTPUT
836
837 echo
838 echo
839 echo OpenOCD configuration summary
840 echo --------------------------------------------------
841 m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS,
842         HIDAPI_ADAPTERS, LIBFTDI_ADAPTERS, LIBJAYLINK_ADAPTERS],
843         [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
844         case $ADAPTER_VAR([adapter]) in
845                 auto)
846                         echo "$s"yes '(auto)'
847                         ;;
848                 yes)
849                         echo "$s"yes
850                         ;;
851                 no)
852                         echo "$s"no
853                         ;;
854         esac
855 ])
856 echo