]> git.sur5r.net Git - openocd/blob - configure.ac
configure: Use same case for libjaylink as for other libs
[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 AS_IF([test "x$MAKEINFO" = "x"], [
11   MAKEINFO='echo makeinfo missing; true'
12   AC_MSG_WARN([Info documentation will not be built.])
13 ])
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 # guess-rev.sh only exists in the repository, not in the released archives
147 AC_MSG_CHECKING([whether to build a release])
148 AS_IF([test -x "$srcdir/guess-rev.sh"], [
149   build_release=no
150 ], [
151   build_release=yes
152 ])
153 AC_MSG_RESULT([$build_release])
154
155 # Adapter drivers
156 # 1st column -- configure option
157 # 2nd column -- description
158 # 3rd column -- symbol used for both config.h and automake
159 m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
160 m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
161 m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
162 m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
163 m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
164
165 m4_define([USB1_ADAPTERS],
166         [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
167         [[stlink], [ST-Link JTAG Programmer], [HLADAPTER_STLINK]],
168         [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
169         [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
170         [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
171         [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]]])
172
173 m4_define([USB_ADAPTERS],
174         [[[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
175         [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
176         [[aice], [Andes JTAG Programmer], [AICE]]])
177
178 m4_define([USB0_ADAPTERS],
179         [[[usbprog], [USBProg JTAG Programmer], [USBPROG]],
180         [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
181         [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]]])
182
183 m4_define([HIDAPI_ADAPTERS],
184         [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP]]])
185
186 m4_define([LIBFTDI_ADAPTERS],
187         [[[usb_blaster], [Altera USB-Blaster Compatible], [USB_BLASTER]],
188         [[presto], [ASIX Presto Adapter], [PRESTO]],
189         [[openjtag], [OpenJTAG Adapter], [OPENJTAG]]])
190
191 m4_define([LIBJAYLINK_ADAPTERS],
192         [[[jlink], [SEGGER J-Link Programmer], [JLINK]]])
193
194
195 AC_ARG_ENABLE([doxygen-html],
196   AS_HELP_STRING([--disable-doxygen-html],
197     [Disable building Doxygen manual as HTML.]),
198   [doxygen_as_html=$enableval], [doxygen_as_html=yes])
199 AC_SUBST([doxygen_as_html])
200 AC_MSG_CHECKING([whether to build Doxygen as HTML])
201 AC_MSG_RESULT([$doxygen_as_html])
202
203 AC_ARG_ENABLE([doxygen-pdf],
204   AS_HELP_STRING([--enable-doxygen-pdf],
205     [Enable building Doxygen manual as PDF.]),
206   [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
207 AC_SUBST([doxygen_as_pdf])
208 AC_MSG_CHECKING([whether to build Doxygen as PDF])
209 AC_MSG_RESULT([$doxygen_as_pdf])
210
211 AC_ARG_ENABLE([gccwarnings],
212   AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
213   [gcc_warnings=$enableval], [gcc_warnings=yes])
214
215 AC_ARG_ENABLE([wextra],
216   AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
217   [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
218
219 AC_ARG_ENABLE([werror],
220   AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
221   [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
222
223 # set default verbose options, overridden by following options
224 debug_jtag_io=no
225 debug_usb_io=no
226 debug_usb_comms=no
227
228 AC_ARG_ENABLE([verbose],
229   AS_HELP_STRING([--enable-verbose],
230       [Enable verbose JTAG I/O messages (for debugging).]),
231   [
232   debug_jtag_io=$enableval
233   debug_usb_io=$enableval
234   debug_usb_comms=$enableval
235   ], [])
236
237 AC_ARG_ENABLE([verbose_jtag_io],
238   AS_HELP_STRING([--enable-verbose-jtag-io],
239       [Enable verbose JTAG I/O messages (for debugging).]),
240   [debug_jtag_io=$enableval], [])
241
242 AC_ARG_ENABLE([verbose_usb_io],
243   AS_HELP_STRING([--enable-verbose-usb-io],
244       [Enable verbose USB I/O messages (for debugging)]),
245   [debug_usb_io=$enableval], [])
246
247 AC_ARG_ENABLE([verbose_usb_comms],
248   AS_HELP_STRING([--enable-verbose-usb-comms],
249       [Enable verbose USB communication messages (for debugging)]),
250   [debug_usb_comms=$enableval], [])
251
252 AC_MSG_CHECKING([whether to enable verbose JTAG I/O messages]);
253 AC_MSG_RESULT([$debug_jtag_io])
254 AS_IF([test "x$debug_jtag_io" = "xyes"], [
255   AC_DEFINE([_DEBUG_JTAG_IO_],[1], [Print verbose JTAG I/O messages])
256 ])
257
258 AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
259 AC_MSG_RESULT([$debug_usb_io])
260 AS_IF([test "x$debug_usb_io" = "xyes"], [
261   AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
262 ])
263
264 AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
265 AC_MSG_RESULT([$debug_usb_comms])
266 AS_IF([test "x$debug_usb_comms" = "xyes"], [
267   AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
268 ])
269
270 debug_malloc=no
271 AC_ARG_ENABLE([malloc_logging],
272   AS_HELP_STRING([--enable-malloc-logging],
273       [Include free space in logging messages (requires malloc.h).]),
274   [debug_malloc=$enableval], [])
275
276 AC_MSG_CHECKING([whether to enable malloc free space logging]);
277 AC_MSG_RESULT([$debug_malloc])
278 AS_IF([test "x$debug_malloc" = "xyes"], [
279   AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
280 ])
281
282 AC_ARG_ENABLE([dummy],
283   AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
284   [build_dummy=$enableval], [build_dummy=no])
285
286 m4_define([AC_ARG_ADAPTERS], [
287   m4_foreach([adapter], [$1],
288         [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
289                 AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
290                         [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
291                 [], [ADAPTER_VAR([adapter])=$2])
292   ])
293 ])
294
295 AC_ARG_ADAPTERS([
296   USB1_ADAPTERS,
297   USB_ADAPTERS,
298   USB0_ADAPTERS,
299   HIDAPI_ADAPTERS,
300   LIBFTDI_ADAPTERS,
301   LIBJAYLINK_ADAPTERS
302   ],[auto])
303
304 AC_ARG_ENABLE([parport],
305   AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
306   [build_parport=$enableval], [build_parport=no])
307
308 AC_ARG_ENABLE([parport_ppdev],
309   AS_HELP_STRING([--disable-parport-ppdev],
310       [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
311     [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
312
313 AC_ARG_ENABLE([parport_giveio],
314     AS_HELP_STRING([--enable-parport-giveio],
315       [Enable use of giveio for parport (for CygWin only)]),
316     [parport_use_giveio=$enableval], [parport_use_giveio=])
317
318 AC_ARG_ENABLE([jtag_vpi],
319   AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
320   [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
321
322 AC_ARG_ENABLE([amtjtagaccel],
323   AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
324   [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
325
326 AC_ARG_ENABLE([zy1000_master],
327   AS_HELP_STRING([--enable-zy1000-master], [Use ZY1000 JTAG master registers]),
328   [build_zy1000_master=$enableval], [build_zy1000_master=no])
329
330 AC_ARG_ENABLE([zy1000],
331   AS_HELP_STRING([--enable-zy1000], [Enable ZY1000 interface]),
332   [build_zy1000=$enableval], [build_zy1000=no])
333
334 AC_ARG_ENABLE([ioutil],
335   AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
336   [build_ioutil=$enableval], [build_ioutil=no])
337
338 AS_CASE(["${host_cpu}"],
339   [arm*], [
340     AC_ARG_ENABLE([ep93xx],
341       AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
342       [build_ep93xx=$enableval], [build_ep93xx=no])
343
344     AC_ARG_ENABLE([at91rm9200],
345       AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
346       [build_at91rm9200=$enableval], [build_at91rm9200=no])
347
348     AC_ARG_ENABLE([bcm2835gpio],
349       AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
350       [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
351   ],
352   [
353     build_ep93xx=no
354     build_at91rm9200=no
355     build_bcm2835gpio=no
356 ])
357
358 AC_ARG_ENABLE([gw16012],
359   AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
360   [build_gw16012=$enableval], [build_gw16012=no])
361
362 AC_ARG_ENABLE([oocd_trace],
363   AS_HELP_STRING([--enable-oocd_trace],
364   [Enable building support for some prototype OpenOCD+trace ETM capture hardware]),
365   [build_oocd_trace=$enableval], [build_oocd_trace=no])
366
367 AC_ARG_ENABLE([buspirate],
368   AS_HELP_STRING([--enable-buspirate], [Enable building support for the Buspirate]),
369   [build_buspirate=$enableval], [build_buspirate=no])
370
371 AC_ARG_ENABLE([sysfsgpio],
372   AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
373   [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
374
375 AC_ARG_ENABLE([minidriver_dummy],
376   AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
377   [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
378
379 AC_ARG_ENABLE([internal-jimtcl],
380   AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
381   [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
382
383 AC_ARG_ENABLE([internal-libjaylink],
384   AS_HELP_STRING([--disable-internal-libjaylink],
385   [Disable building internal libjaylink]),
386   [use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
387
388 build_minidriver=no
389 AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
390 AS_IF([test "x$build_zy1000" = "xyes"], [
391   AS_IF([test "x$build_minidriver" = "xyes"], [
392     AC_MSG_ERROR([Multiple minidriver options have been enabled.])
393   ])
394   AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
395       [Define to 1 if you have the <jtag_minidriver.h> header file.])
396   build_minidriver=yes
397 ])
398 AC_MSG_RESULT([$build_zy1000])
399
400 AC_ARG_ENABLE([remote-bitbang],
401   AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
402   [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
403
404 AC_MSG_CHECKING([whether to enable dummy minidriver])
405 AS_IF([test "x$build_minidriver_dummy" = "xyes"], [
406   AS_IF([test "x$build_minidriver" = "xyes"], [
407     AC_MSG_ERROR([Multiple minidriver options have been enabled.])
408   ])
409   build_minidriver=yes
410   AC_DEFINE([BUILD_MINIDRIVER_DUMMY], [1], [Use the dummy minidriver.])
411   AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
412       [Define to 1 if you have the <jtag_minidriver.h> header file.])
413 ])
414 AC_MSG_RESULT([$build_minidriver_dummy])
415
416 AC_MSG_CHECKING([whether standard drivers can be built])
417 AS_IF([test "x$build_minidriver" = "xyes"], [
418   AC_MSG_RESULT([no])
419   AC_MSG_WARN([Using the minidriver disables all other drivers.])
420   sleep 2
421 ], [
422   AC_MSG_RESULT([yes])
423 ])
424
425 AS_CASE(["${host_cpu}"],
426   [i?86|x86*], [],
427   [
428     AS_IF([test "x$parport_use_ppdev" = "xno"], [
429       AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
430     ])
431     parport_use_ppdev=yes
432 ])
433
434 AS_CASE([$host],
435   [*-cygwin*], [
436     is_win32=yes
437     parport_use_ppdev=no
438
439     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
440       [is_mingw=yes],[is_mingw=no])
441     AS_IF([test "x$is_mingw" = "xyes"], [
442       AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
443       AS_IF([test "x$parport_use_giveio" = "xno"], [
444         AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
445       ])
446       parport_use_giveio=yes
447       is_cygwin=no
448     ], [
449       is_cygwin=yes
450       AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
451       # sys/io.h needed under cygwin for parport access
452       AS_IF([test "x$build_parport" = "xyes"], [
453         AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
454       ])
455     ])
456
457     AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
458     AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
459   ],
460   [*-mingw* | *-msys*], [
461     is_mingw=yes
462     is_win32=yes
463     parport_use_ppdev=no
464
465     AS_IF([test "x$parport_use_giveio" = "xno"], [
466       AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
467     ])
468     parport_use_giveio=yes
469
470     AS_IF([test "x$build_buspirate" = "xyes"], [
471       AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
472     ])
473
474     CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
475
476     AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
477     AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
478     AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
479   ],
480   [*darwin*], [
481     is_darwin=yes
482
483     AS_IF([test "x$parport_use_giveio" = "xyes"], [
484       AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
485     ])
486     parport_use_giveio=no
487
488     AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
489     AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
490     AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
491   ],
492   [
493     AS_IF([test "x$parport_use_giveio" = "xyes"], [
494       AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
495     ])
496     parport_use_giveio=no
497     AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
498     AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
499     AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
500 ])
501
502 AS_IF([test "x$is_win32" = "xyes"], [
503     AC_DEFINE([WIN32_LEAN_AND_MEAN], [1], [1 to exclude old conflicting definitions when building on Windows])
504 ])
505
506 AS_IF([test "x$build_parport" = "xyes"], [
507   build_bitbang=yes
508   AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
509 ], [
510   AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
511 ])
512
513 AS_IF([test "x$build_dummy" = "xyes"], [
514   build_bitbang=yes
515   AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
516 ], [
517   AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
518 ])
519
520 AS_IF([test "x$build_ep93xx" = "xyes"], [
521   build_bitbang=yes
522   AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
523 ], [
524   AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
525 ])
526
527 AS_IF([test "x$build_zy1000" = "xyes"], [
528   AC_DEFINE([BUILD_ZY1000], [1], [1 if you want ZY1000.])
529 ], [
530   AC_DEFINE([BUILD_ZY1000], [0], [0 if you don't want ZY1000.])
531 ])
532
533 AS_IF([test "x$build_zy1000_master" = "xyes"], [
534   AC_DEFINE([BUILD_ZY1000_MASTER], [1], [1 if you want ZY1000 JTAG master registers.])
535 ], [
536   AC_DEFINE([BUILD_ZY1000_MASTER], [0], [0 if you don't want ZY1000 JTAG master registers.])
537 ])
538
539 AS_IF([test "x$build_at91rm9200" = "xyes"], [
540   build_bitbang=yes
541   AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
542 ], [
543   AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
544 ])
545
546 AS_IF([test "x$build_bcm2835gpio" = "xyes"], [
547   build_bitbang=yes
548   AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
549 ], [
550   AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
551 ])
552
553 AS_IF([test "x$parport_use_ppdev" = "xyes"], [
554   AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
555 ], [
556   AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
557 ])
558
559 AS_IF([test "x$parport_use_giveio" = "xyes"], [
560   AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
561 ], [
562   AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
563 ])
564
565 AS_IF([test "x$build_jtag_vpi" = "xyes"], [
566   AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
567 ], [
568   AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
569 ])
570
571 AS_IF([test "x$build_amtjtagaccel" = "xyes"], [
572   AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
573 ], [
574   AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
575 ])
576
577 AS_IF([test "x$build_gw16012" = "xyes"], [
578   AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
579 ], [
580   AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
581 ])
582
583 AS_IF([test "x$build_oocd_trace" = "xyes"], [
584   AC_DEFINE([BUILD_OOCD_TRACE], [1], [1 if you want the OpenOCD+trace ETM capture driver.])
585 ], [
586   AC_DEFINE([BUILD_OOCD_TRACE], [0], [0 if you don't want the OpenOCD+trace ETM capture driver.])
587 ])
588
589 AS_IF([test "x$build_buspirate" = "xyes"], [
590   AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
591 ], [
592   AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
593 ])
594
595 AS_IF([test "x$use_internal_jimtcl" = "xyes"], [
596   AS_IF([test -f "$srcdir/jimtcl/configure.ac"], [
597     AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
598   ], [
599     AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
600   ])
601 ])
602
603 AS_IF([test "x$build_remote_bitbang" = "xyes"], [
604   build_bitbang=yes
605   AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
606 ], [
607   AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
608 ])
609
610 AS_IF([test "x$build_sysfsgpio" = "xyes"], [
611   build_bitbang=yes
612   AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
613 ], [
614   AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
615 ])
616
617 PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
618         use_libusb1=yes
619         AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
620         PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
621                 [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
622                 [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
623         LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
624         AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
625         PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.16],
626                 [AC_DEFINE([HAVE_LIBUSB_GET_PORT_NUMBERS], [1], [Define if your libusb has libusb_get_port_numbers()])])
627   ], [
628         use_libusb1=no
629         AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
630 ])
631
632 PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
633
634 for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
635         PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
636                 use_hidapi=yes
637                 break
638         ],[
639                 use_hidapi=no
640         ])
641 done
642
643 PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [
644         PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
645 ])
646
647 PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.1],
648         [use_libjaylink=yes], [use_libjaylink=no])
649
650 m4_define([PROCESS_ADAPTERS], [
651   m4_foreach([adapter], [$1], [
652         AS_IF([test $2], [
653                 AS_IF([test "x$ADAPTER_VAR([adapter])" != "xno"], [
654                         AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
655                 ], [
656                         AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
657                 ])
658         ], [
659                 AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [
660                         AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
661                 ])
662                 ADAPTER_VAR([adapter])=no
663         ])
664         AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test "x$ADAPTER_VAR([adapter])" != "xno"])
665   ])
666 ])
667
668 PROCESS_ADAPTERS([USB1_ADAPTERS], ["x$use_libusb1" = "xyes"], [libusb-1.x])
669 PROCESS_ADAPTERS([USB_ADAPTERS], ["x$use_libusb1" = "xyes" -o "x$use_libusb0" = "xyes"], [libusb-1.x or libusb-0.1])
670 PROCESS_ADAPTERS([USB0_ADAPTERS], ["x$use_libusb0" = "xyes"], [libusb-0.1])
671 PROCESS_ADAPTERS([HIDAPI_ADAPTERS], ["x$use_hidapi" = "xyes"], [hidapi])
672 PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
673 PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_libusb1" = "xyes" -a "x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libusb-1.x or libjaylink-0.1])
674
675 AS_IF([test "x$build_openjtag" = "xyes"], [
676   AS_IF([test "x$use_libusb1" != "xyes" -a "x$use_libusb0" != "xyes"], [
677     AC_MSG_ERROR([libusb-1.x or libusb-0.1 is required for the OpenJTAG Programmer])
678     build_openjtag=no
679   ])
680 ])
681
682 AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno"], [
683         AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
684 ], [
685         AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
686 ])
687 AM_CONDITIONAL([HLADAPTER], [test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno"])
688
689 AS_IF([test "x$enable_jlink" != "xno"], [
690   AS_IF([test "x$use_internal_libjaylink" = "xyes"], [
691     AS_IF([test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"], [
692       AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
693                 [--enable-subproject-build])
694     ], [
695       AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
696     ])
697   ])
698 ])
699
700 # Presto needs the bitq module
701 AS_IF([test "x$enable_presto" != "xno"], [
702   build_bitq=yes
703 ])
704
705 AM_CONDITIONAL([RELEASE], [test "x$build_release" = "xyes"])
706 AM_CONDITIONAL([PARPORT], [test "x$build_parport" = "xyes"])
707 AM_CONDITIONAL([DUMMY], [test "x$build_dummy" = "xyes"])
708 AM_CONDITIONAL([GIVEIO], [test "x$parport_use_giveio" = "xyes"])
709 AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
710 AM_CONDITIONAL([ZY1000], [test "x$build_zy1000" = "xyes"])
711 AM_CONDITIONAL([ZY1000_MASTER], [test "x$build_zy1000_master" = "xyes"])
712 AM_CONDITIONAL([IOUTIL], [test "x$build_ioutil" = "xyes"])
713 AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
714 AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
715 AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
716 AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes" -o "x$build_jtag_vpi" = "xyes"])
717 AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
718 AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
719 AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
720 AM_CONDITIONAL([OOCD_TRACE], [test "x$build_oocd_trace" = "xyes"])
721 AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
722 AM_CONDITIONAL([BUSPIRATE], [test "x$build_buspirate" = "xyes"])
723 AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
724 AM_CONDITIONAL([USE_LIBUSB0], [test "x$use_libusb0" = "xyes"])
725 AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
726 AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
727 AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"])
728 AM_CONDITIONAL([IS_WIN32], [test "x$is_win32" = "xyes"])
729 AM_CONDITIONAL([IS_DARWIN], [test "x$is_darwin" = "xyes"])
730 AM_CONDITIONAL([BITQ], [test "x$build_bitq" = "xyes"])
731 AM_CONDITIONAL([USE_LIBFTDI], [test "x$use_libftdi" = "xyes"])
732
733 AM_CONDITIONAL([MINIDRIVER], [test "x$build_minidriver" = "xyes"])
734 AM_CONDITIONAL([MINIDRIVER_DUMMY], [test "x$build_minidriver_dummy" = "xyes"])
735
736 AM_CONDITIONAL([INTERNAL_JIMTCL], [test "x$use_internal_jimtcl" = "xyes"])
737 AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test "x$use_internal_libjaylink" = "xyes"])
738
739 # Look for environ alternatives.  Possibility #1: is environ in unistd.h or stdlib.h?
740 AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
741 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
742 #define _GNU_SOURCE
743 #include <unistd.h>
744 #include <stdlib.h>
745   ]], [[char **ep = environ;]]
746   )], [
747     AC_MSG_RESULT([yes])
748     has_environ=yes
749   ], [
750     AC_MSG_RESULT([no])
751
752     # Possibility #2: can environ be found in an available library?
753     AC_MSG_CHECKING([for extern environ])
754     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
755     extern char **environ;
756     ]], [[char **ep = environ;]]
757       )], [
758         AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
759         has_environ=yes
760       ], [
761         has_environ=no
762       ])
763     AC_MSG_RESULT([${has_environ}])
764   ])
765
766 AS_IF([test "x${has_environ}" != "xyes" ], [
767   AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
768 ])
769
770 AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
771
772 # set default gcc warnings
773 GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
774 AS_IF([test "x${gcc_wextra}" = "xyes"], [
775   GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
776   GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
777   GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
778   GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
779 ])
780 AS_IF([test "x${gcc_werror}" = "xyes"], [
781   GCC_WARNINGS="${GCC_WARNINGS} -Werror"
782 ])
783
784 # overide default gcc cflags
785 AS_IF([test "x$gcc_warnings" = "xyes"], [
786   CFLAGS="$CFLAGS $GCC_WARNINGS"
787 ])
788
789 AC_CONFIG_FILES([
790   Makefile
791   src/Makefile
792   src/helper/Makefile
793   src/jtag/Makefile
794   src/jtag/drivers/Makefile
795   src/jtag/drivers/usb_blaster/Makefile
796   src/jtag/hla/Makefile
797   src/jtag/aice/Makefile
798   src/transport/Makefile
799   src/target/openrisc/Makefile
800   src/xsvf/Makefile
801   src/svf/Makefile
802   src/target/Makefile
803   src/rtos/Makefile
804   src/server/Makefile
805   src/flash/Makefile
806   src/flash/nor/Makefile
807   src/flash/nand/Makefile
808   src/pld/Makefile
809   doc/Makefile
810 ])
811 AC_OUTPUT
812
813 echo
814 echo
815 echo OpenOCD configuration summary
816 echo --------------------------------------------------
817 m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS,
818         HIDAPI_ADAPTERS, LIBFTDI_ADAPTERS, LIBJAYLINK_ADAPTERS],
819         [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
820         AS_CASE([$ADAPTER_VAR([adapter])],
821                 [auto], [
822                         echo "$s"yes '(auto)'
823                 ],
824                 [yes], [
825                         echo "$s"yes
826                 ],
827                 [no], [
828                         echo "$s"no
829         ])
830 ])
831 echo