You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1344 lines
43 KiB

  1. AC_PREREQ(2.64)
  2. AC_INIT([openocd], [0.8.0-rc2-dev],
  3. [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
  4. AC_CONFIG_SRCDIR([src/openocd.c])
  5. m4_include([config_subdir.m4])dnl
  6. AM_INIT_AUTOMAKE([-Wall -Wno-portability dist-bzip2 dist-zip subdir-objects])
  7. AC_CONFIG_HEADERS([config.h])
  8. AH_BOTTOM([
  9. #include <helper/system.h>
  10. #include <helper/types.h>
  11. #include <helper/replacements.h>
  12. ])
  13. AC_LANG_C
  14. AC_PROG_CC
  15. AC_PROG_CC_C99
  16. AM_PROG_CC_C_O
  17. AC_PROG_RANLIB
  18. PKG_PROG_PKG_CONFIG([0.23])
  19. dnl disable checks for C++, Fortran and GNU Java Compiler
  20. m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
  21. m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
  22. m4_defun([_LT_AC_LANG_GCJ_CONFIG], [:])
  23. AC_DISABLE_SHARED
  24. AC_PROG_LIBTOOL
  25. AC_SUBST([LIBTOOL_DEPS])
  26. dnl configure checks required for Jim files (these are obsolete w/ C99)
  27. AC_C_CONST
  28. AC_TYPE_LONG_LONG_INT
  29. AC_SEARCH_LIBS([ioperm], [ioperm])
  30. AC_SEARCH_LIBS([dlopen], [dl])
  31. AC_CHECK_HEADERS([sys/socket.h])
  32. AC_CHECK_HEADERS([arpa/inet.h], [], [], [dnl
  33. #include <stdio.h>
  34. #ifdef STDC_HEADERS
  35. # include <stdlib.h>
  36. # include <stddef.h>
  37. #else
  38. # ifdef HAVE_STDLIB_H
  39. # include <stdlib.h>
  40. # endif
  41. #endif
  42. #ifdef HAVE_SYS_SOCKET_H
  43. # include <sys/socket.h>
  44. #endif
  45. ])
  46. AC_CHECK_HEADERS([elf.h])
  47. AC_CHECK_HEADERS([dirent.h])
  48. AC_CHECK_HEADERS([fcntl.h])
  49. AC_CHECK_HEADERS([ifaddrs.h], [], [], [dnl
  50. #include <stdio.h>
  51. #ifdef STDC_HEADERS
  52. # include <stdlib.h>
  53. # include <stddef.h>
  54. #else
  55. # ifdef HAVE_STDLIB_H
  56. # include <stdlib.h>
  57. # endif
  58. #endif
  59. #ifdef HAVE_SYS_SOCKET_H
  60. # include <sys/socket.h>
  61. #endif
  62. ])
  63. AC_CHECK_HEADERS([malloc.h])
  64. AC_CHECK_HEADERS([netdb.h])
  65. AC_CHECK_HEADERS([netinet/in.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([netinet/tcp.h], [], [], [dnl
  80. #include <stdio.h>
  81. #ifdef STDC_HEADERS
  82. # include <stdlib.h>
  83. # include <stddef.h>
  84. #else
  85. # ifdef HAVE_STDLIB_H
  86. # include <stdlib.h>
  87. # endif
  88. #endif
  89. #ifdef HAVE_SYS_SOCKET_H
  90. # include <sys/socket.h>
  91. #endif
  92. ])
  93. AC_CHECK_HEADERS([pthread.h])
  94. AC_CHECK_HEADERS([strings.h])
  95. AC_CHECK_HEADERS([sys/ioctl.h])
  96. AC_CHECK_HEADERS([sys/param.h])
  97. AC_CHECK_HEADERS([sys/poll.h])
  98. AC_CHECK_HEADERS([sys/select.h])
  99. AC_CHECK_HEADERS([sys/stat.h])
  100. AC_CHECK_HEADERS([sys/time.h])
  101. AC_CHECK_HEADERS([sys/types.h])
  102. AC_CHECK_HEADERS([unistd.h])
  103. AC_CHECK_HEADERS([net/if.h], [], [], [dnl
  104. #include <stdio.h>
  105. #ifdef STDC_HEADERS
  106. # include <stdlib.h>
  107. # include <stddef.h>
  108. #else
  109. # ifdef HAVE_STDLIB_H
  110. # include <stdlib.h>
  111. # endif
  112. #endif
  113. #ifdef HAVE_SYS_SOCKET_H
  114. # include <sys/socket.h>
  115. #endif
  116. ])
  117. AC_HEADER_ASSERT
  118. AC_HEADER_STDBOOL
  119. AC_HEADER_TIME
  120. AC_C_BIGENDIAN
  121. AC_CHECK_FUNCS([strndup])
  122. AC_CHECK_FUNCS([strnlen])
  123. AC_CHECK_FUNCS([gettimeofday])
  124. AC_CHECK_FUNCS([usleep])
  125. AC_CHECK_FUNCS([vasprintf])
  126. build_bitbang=no
  127. build_bitq=no
  128. is_cygwin=no
  129. is_mingw=no
  130. is_win32=no
  131. is_darwin=no
  132. # guess-rev.sh only exists in the repository, not in the released archives
  133. AC_MSG_CHECKING([whether to build a release])
  134. if test -x $srcdir/guess-rev.sh ; then
  135. build_release=no
  136. else
  137. build_release=yes
  138. fi
  139. AC_MSG_RESULT([$build_release])
  140. AC_ARG_WITH(ftd2xx,
  141. AS_HELP_STRING([--with-ftd2xx=<PATH>],[This option has been removed.]),
  142. [
  143. # Option Given.
  144. cat << __EOF__
  145. The option: --with-ftd2xx=<PATH> has been removed.
  146. On Linux, the new option is:
  147. --with-ftd2xx-linux-tardir=/path/to/files
  148. Where <path> is the path the the directory where the "tar.gz" file
  149. from FTDICHIP.COM was unpacked, for example:
  150. --with-ftd2xx-linux-tardir=${HOME}/libftd2xx0.4.16
  151. On Cygwin/MingW32, the new option is:
  152. --with-ftd2xx-win32-zipdir=/path/to/files
  153. Where <path> is the path to the directory where the "zip" file from
  154. FTDICHIP.COM was unpacked, for example:
  155. --with-ftd2xx-win32-zipdir=${HOME}/ftd2xx.cdm.files
  156. __EOF__
  157. AC_MSG_ERROR([Sorry Cannot continue])
  158. ], [true])
  159. # Adapter drivers
  160. # 1st column -- configure option
  161. # 2nd column -- description
  162. # 3rd column -- symbol used for both config.h and automake
  163. m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
  164. m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
  165. m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
  166. m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
  167. m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])
  168. m4_define([USB1_ADAPTERS],
  169. [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]],
  170. [[stlink], [ST-Link JTAG Programmer], [HLADAPTER_STLINK]],
  171. [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
  172. [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
  173. [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]]])
  174. m4_define([USB_ADAPTERS],
  175. [[[jlink], [Segger J-Link JTAG Programmer], [JLINK]],
  176. [[osbdm], [OSBDM (JTAG only) Programmer], [OSBDM]],
  177. [[opendous], [eStick/opendous JTAG Programmer], [OPENDOUS]],
  178. [[aice], [Andes JTAG Programmer], [AICE]]])
  179. m4_define([USB0_ADAPTERS],
  180. [[[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]],
  181. [[usbprog], [USBProg JTAG Programmer], [USBPROG]],
  182. [[rlink], [Raisonance RLink JTAG Programmer], [RLINK]],
  183. [[armjtagew], [Olimex ARM-JTAG-EW Programmer], [ARMJTAGEW]]])
  184. m4_define([HIDAPI_ADAPTERS],
  185. [[[cmsis_dap], [CMSIS-DAP Compliant Debugger], [CMSIS_DAP]]])
  186. #========================================
  187. # FTD2XXX support comes in 4 forms.
  188. # (1) win32 - via a zip file
  189. # (2) linux - via a tar file
  190. # (3) linux/cygwin/mingw - via libftdi
  191. # (4) darwin - installed under /usr/local
  192. #
  193. # In case (1) and (2) we need to know where the package was unpacked.
  194. AC_ARG_WITH(ftd2xx-win32-zipdir,
  195. AS_HELP_STRING([--with-ftd2xx-win32-zipdir],[Where (CYGWIN/MINGW) the zip file from ftdichip.com was unpacked (default=search)]),
  196. [
  197. # option present
  198. if test -d $with_ftd2xx_win32_zipdir
  199. then
  200. with_ftd2xx_win32_zipdir=`cd $with_ftd2xx_win32_zipdir && pwd`
  201. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_win32_zipdir])
  202. else
  203. AC_MSG_ERROR([Parameter to --with-ftd2xx-win32-zipdir is not a dir: $with_ftd2xx_win32_zipdir])
  204. fi
  205. ], [true])
  206. AC_ARG_WITH(ftd2xx-linux-tardir,
  207. AS_HELP_STRING([--with-ftd2xx-linux-tardir], [Where (Linux/Unix) the tar file from ftdichip.com was unpacked (default=search)]),
  208. [
  209. # Option present
  210. if test $is_win32 = yes ; then
  211. AC_MSG_ERROR([The option: --with-ftd2xx-linux-tardir is only usable on linux])
  212. fi
  213. if test -d $with_ftd2xx_linux_tardir
  214. then
  215. with_ftd2xx_linux_tardir=`cd $with_ftd2xx_linux_tardir && pwd`
  216. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_linux_tardir])
  217. else
  218. AC_MSG_ERROR([Parameter to --with-ftd2xx-linux-tardir is not a dir: $with_ftd2xx_linux_tardir])
  219. fi
  220. ], [true])
  221. AC_ARG_WITH(ftd2xx-lib,
  222. AS_HELP_STRING([--with-ftd2xx-lib],
  223. [Use static or shared ftd2xx libs (default=static)]),
  224. [
  225. case "$withval" in
  226. static)
  227. with_ftd2xx_lib=$withval
  228. ;;
  229. shared)
  230. with_ftd2xx_lib=$withval
  231. ;;
  232. *)
  233. AC_MSG_ERROR([Option: --with-ftd2xx-lib=static or --with-ftd2xx-lib=shared not, $withval])
  234. ;;
  235. esac
  236. ], [
  237. # Default is static - it is simpler :-(
  238. with_ftd2xx_lib=static
  239. ])
  240. AC_ARG_ENABLE([doxygen-html],
  241. AS_HELP_STRING([--disable-doxygen-html],
  242. [Disable building Doxygen manual as HTML.]),
  243. [doxygen_as_html=$enableval], [doxygen_as_html=yes])
  244. AC_SUBST([doxygen_as_html])
  245. AC_MSG_CHECKING([whether to build Doxygen as HTML])
  246. AC_MSG_RESULT([$doxygen_as_html])
  247. AC_ARG_ENABLE([doxygen-pdf],
  248. AS_HELP_STRING([--enable-doxygen-pdf],
  249. [Enable building Doxygen manual as PDF.]),
  250. [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no])
  251. AC_SUBST([doxygen_as_pdf])
  252. AC_MSG_CHECKING([whether to build Doxygen as PDF])
  253. AC_MSG_RESULT([$doxygen_as_pdf])
  254. AC_ARG_ENABLE([gccwarnings],
  255. AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
  256. [gcc_warnings=$enableval], [gcc_warnings=yes])
  257. AC_ARG_ENABLE([wextra],
  258. AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
  259. [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
  260. AC_ARG_ENABLE([werror],
  261. AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
  262. [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
  263. # set default verbose options, overridden by following options
  264. debug_jtag_io=no
  265. debug_usb_io=no
  266. debug_usb_comms=no
  267. AC_ARG_ENABLE([verbose],
  268. AS_HELP_STRING([--enable-verbose],
  269. [Enable verbose JTAG I/O messages (for debugging).]),
  270. [
  271. debug_jtag_io=$enableval
  272. debug_usb_io=$enableval
  273. debug_usb_comms=$enableval
  274. ], [])
  275. AC_ARG_ENABLE([verbose_jtag_io],
  276. AS_HELP_STRING([--enable-verbose-jtag-io],
  277. [Enable verbose JTAG I/O messages (for debugging).]),
  278. [debug_jtag_io=$enableval], [])
  279. AC_ARG_ENABLE([verbose_usb_io],
  280. AS_HELP_STRING([--enable-verbose-usb-io],
  281. [Enable verbose USB I/O messages (for debugging)]),
  282. [debug_usb_io=$enableval], [])
  283. AC_ARG_ENABLE([verbose_usb_comms],
  284. AS_HELP_STRING([--enable-verbose-usb-comms],
  285. [Enable verbose USB communication messages (for debugging)]),
  286. [debug_usb_comms=$enableval], [])
  287. AC_MSG_CHECKING([whether to enable verbose JTAG I/O messages]);
  288. AC_MSG_RESULT([$debug_jtag_io])
  289. if test $debug_jtag_io = yes; then
  290. AC_DEFINE([_DEBUG_JTAG_IO_],[1], [Print verbose JTAG I/O messages])
  291. fi
  292. AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
  293. AC_MSG_RESULT([$debug_usb_io])
  294. if test $debug_usb_io = yes; then
  295. AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
  296. fi
  297. AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
  298. AC_MSG_RESULT([$debug_usb_comms])
  299. if test $debug_usb_comms = yes; then
  300. AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
  301. fi
  302. debug_malloc=no
  303. AC_ARG_ENABLE([malloc_logging],
  304. AS_HELP_STRING([--enable-malloc-logging],
  305. [Include free space in logging messages (requires malloc.h).]),
  306. [debug_malloc=$enableval], [])
  307. AC_MSG_CHECKING([whether to enable malloc free space logging]);
  308. AC_MSG_RESULT([$debug_malloc])
  309. if test $debug_malloc = yes; then
  310. AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
  311. fi
  312. AC_ARG_ENABLE([dummy],
  313. AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
  314. [build_dummy=$enableval], [build_dummy=no])
  315. m4_define([AC_ARG_ADAPTERS], [
  316. m4_foreach([adapter], [$1],
  317. [AC_ARG_ENABLE(ADAPTER_OPT([adapter]),
  318. AS_HELP_STRING([--enable-ADAPTER_OPT([adapter])],
  319. [Enable building support for the ]ADAPTER_DESC([adapter])[ (default is $2)]),
  320. [], [ADAPTER_VAR([adapter])=$2])
  321. ])
  322. ])
  323. AC_ARG_ADAPTERS([USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS, HIDAPI_ADAPTERS], [auto])
  324. AC_ARG_ENABLE([parport],
  325. AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
  326. [build_parport=$enableval], [build_parport=no])
  327. AC_ARG_ENABLE([parport_ppdev],
  328. AS_HELP_STRING([--disable-parport-ppdev],
  329. [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
  330. [parport_use_ppdev=$enableval], [parport_use_ppdev=yes])
  331. AC_ARG_ENABLE([parport_giveio],
  332. AS_HELP_STRING([--enable-parport-giveio],
  333. [Enable use of giveio for parport (for CygWin only)]),
  334. [parport_use_giveio=$enableval], [parport_use_giveio=])
  335. AC_ARG_ENABLE([ft2232_libftdi], [], [
  336. if test $enableval = yes; then
  337. AC_MSG_ERROR([The ft2232 driver is deprecated, use --enable-ftdi to build its replacement, or force the old driver with --enable-legacy-ft2232_libftdi])
  338. fi
  339. ])
  340. AC_ARG_ENABLE([ft2232_ftd2xx], [], [
  341. if test $enableval = yes; then
  342. AC_MSG_ERROR([The ft2232 driver is deprecated, use --enable-ftdi to build its replacement, or force the old driver with --enable-legacy-ft2232_ftd2xx])
  343. fi
  344. ])
  345. AC_ARG_ENABLE([legacy-ft2232_libftdi],
  346. AS_HELP_STRING([--enable-legacy-ft2232_libftdi], [(DEPRECATED) Enable building support for FT2232 based devices using the libftdi library]),
  347. [build_ft2232_libftdi=$enableval], [build_ft2232_libftdi=no])
  348. AC_ARG_ENABLE([legacy-ft2232_ftd2xx],
  349. AS_HELP_STRING([--enable-legacy-ft2232_ftd2xx], [(DEPRECATED) Enable building support for FT2232 based devices using the D2XX library from ftdichip.com]),
  350. [build_ft2232_ftd2xx=$enableval], [build_ft2232_ftd2xx=no])
  351. AC_ARG_ENABLE([jtag_vpi],
  352. AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
  353. [build_jtag_vpi=$enableval], [build_jtag_vpi=no])
  354. AC_ARG_ENABLE([usb_blaster_libftdi],
  355. AS_HELP_STRING([--enable-usb_blaster_libftdi], [Enable building support for the Altera USB-Blaster using the libftdi driver, opensource alternate of FTD2XX]),
  356. [build_usb_blaster_libftdi=$enableval], [build_usb_blaster_libftdi=no])
  357. AC_ARG_ENABLE([usb_blaster_ftd2xx],
  358. AS_HELP_STRING([--enable-usb_blaster_ftd2xx], [Enable building support for the Altera USB-Blaster using the FTD2XX driver from ftdichip.com]),
  359. [build_usb_blaster_ftd2xx=$enableval], [build_usb_blaster_ftd2xx=no])
  360. AC_ARG_ENABLE([amtjtagaccel],
  361. AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
  362. [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
  363. AC_ARG_ENABLE([zy1000_master],
  364. AS_HELP_STRING([--enable-zy1000-master], [Use ZY1000 JTAG master registers]),
  365. [build_zy1000_master=$enableval], [build_zy1000_master=no])
  366. AC_ARG_ENABLE([zy1000],
  367. AS_HELP_STRING([--enable-zy1000], [Enable ZY1000 interface]),
  368. [build_zy1000=$enableval], [build_zy1000=no])
  369. AC_ARG_ENABLE([ioutil],
  370. AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
  371. [build_ioutil=$enableval], [build_ioutil=no])
  372. case "${host_cpu}" in
  373. arm*)
  374. AC_ARG_ENABLE([ep93xx],
  375. AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
  376. [build_ep93xx=$enableval], [build_ep93xx=no])
  377. AC_ARG_ENABLE([at91rm9200],
  378. AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
  379. [build_at91rm9200=$enableval], [build_at91rm9200=no])
  380. AC_ARG_ENABLE([bcm2835gpio],
  381. AS_HELP_STRING([--enable-bcm2835gpio], [Enable building support for bitbanging on BCM2835 (as found in Raspberry Pi)]),
  382. [build_bcm2835gpio=$enableval], [build_bcm2835gpio=no])
  383. ;;
  384. *)
  385. build_ep93xx=no
  386. build_at91rm9200=no
  387. build_bcm2835gpio=no
  388. ;;
  389. esac
  390. AC_ARG_ENABLE([gw16012],
  391. AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
  392. [build_gw16012=$enableval], [build_gw16012=no])
  393. AC_ARG_ENABLE([presto_libftdi],
  394. AS_HELP_STRING([--enable-presto_libftdi], [Enable building support for ASIX Presto Programmer using the libftdi driver]),
  395. [build_presto_libftdi=$enableval], [build_presto_libftdi=no])
  396. AC_ARG_ENABLE([presto_ftd2xx],
  397. AS_HELP_STRING([--enable-presto_ftd2xx], [Enable building support for ASIX Presto Programmer using the FTD2XX driver]),
  398. [build_presto_ftd2xx=$enableval], [build_presto_ftd2xx=no])
  399. AC_ARG_ENABLE([openjtag_ftd2xx],
  400. AS_HELP_STRING([--enable-openjtag_ftd2xx], [Enable building support for the OpenJTAG Programmer with ftd2xx driver]),
  401. [build_openjtag_ftd2xx=$enableval], [build_openjtag_ftd2xx=no])
  402. AC_ARG_ENABLE([openjtag_ftdi],
  403. AS_HELP_STRING([--enable-openjtag_ftdi], [Enable building support for the OpenJTAG Programmer with ftdi driver]),
  404. [build_openjtag_ftdi=$enableval], [build_openjtag_ftdi=no])
  405. AC_ARG_ENABLE([oocd_trace],
  406. AS_HELP_STRING([--enable-oocd_trace],
  407. [Enable building support for some prototype OpenOCD+trace ETM capture hardware]),
  408. [build_oocd_trace=$enableval], [build_oocd_trace=no])
  409. AC_ARG_ENABLE([buspirate],
  410. AS_HELP_STRING([--enable-buspirate], [Enable building support for the Buspirate]),
  411. [build_buspirate=$enableval], [build_buspirate=no])
  412. AC_ARG_ENABLE([sysfsgpio],
  413. AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
  414. [build_sysfsgpio=$enableval], [build_sysfsgpio=no])
  415. AC_ARG_ENABLE([minidriver_dummy],
  416. AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
  417. [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
  418. AC_ARG_ENABLE([internal-jimtcl],
  419. AS_HELP_STRING([--disable-internal-jimtcl], [Disable building internal jimtcl]),
  420. [use_internal_jimtcl=$enableval], [use_internal_jimtcl=yes])
  421. build_minidriver=no
  422. AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
  423. if test $build_zy1000 = yes; then
  424. if test $build_minidriver = yes; then
  425. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  426. fi
  427. AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
  428. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  429. build_minidriver=yes
  430. fi
  431. AC_MSG_RESULT([$build_zy1000])
  432. AC_ARG_ENABLE([remote-bitbang],
  433. AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
  434. [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
  435. AC_MSG_CHECKING([whether to enable dummy minidriver])
  436. if test $build_minidriver_dummy = yes; then
  437. if test $build_minidriver = yes; then
  438. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  439. fi
  440. build_minidriver=yes
  441. AC_DEFINE([BUILD_MINIDRIVER_DUMMY], [1], [Use the dummy minidriver.])
  442. AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
  443. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  444. fi
  445. AC_MSG_RESULT([$build_minidriver_dummy])
  446. AC_MSG_CHECKING([whether standard drivers can be built])
  447. if test "$build_minidriver" = yes; then
  448. AC_MSG_RESULT([no])
  449. AC_MSG_WARN([Using the minidriver disables all other drivers.])
  450. sleep 2
  451. else
  452. AC_MSG_RESULT([yes])
  453. fi
  454. case "${host_cpu}" in
  455. i?86|x86*)
  456. ;;
  457. *)
  458. if test x$parport_use_ppdev = xno; then
  459. AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
  460. fi
  461. parport_use_ppdev=yes
  462. ;;
  463. esac
  464. case $host in
  465. *-cygwin*)
  466. is_win32=yes
  467. parport_use_ppdev=no
  468. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
  469. [is_mingw=yes],[is_mingw=no])
  470. if test $is_mingw = yes; then
  471. AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
  472. if test x$parport_use_giveio = xno; then
  473. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  474. fi
  475. parport_use_giveio=yes
  476. is_cygwin=no
  477. else
  478. is_cygwin=yes
  479. AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
  480. # sys/io.h needed under cygwin for parport access
  481. if test $build_parport = yes; then
  482. AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
  483. fi
  484. fi
  485. AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
  486. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  487. ;;
  488. *-mingw*)
  489. is_mingw=yes
  490. is_win32=yes
  491. parport_use_ppdev=no
  492. if test x$parport_use_giveio = xno; then
  493. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  494. fi
  495. parport_use_giveio=yes
  496. if test x$build_buspirate = xyes; then
  497. AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
  498. fi
  499. CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
  500. AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
  501. AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
  502. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  503. ;;
  504. *darwin*)
  505. is_darwin=yes
  506. if test x$parport_use_giveio = xyes; then
  507. AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
  508. fi
  509. parport_use_giveio=no
  510. AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
  511. AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
  512. AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
  513. ;;
  514. *)
  515. if test x$parport_use_giveio = xyes; then
  516. AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
  517. fi
  518. parport_use_giveio=no
  519. AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
  520. AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
  521. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  522. ;;
  523. esac
  524. if test $build_parport = yes; then
  525. build_bitbang=yes
  526. AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
  527. else
  528. AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
  529. fi
  530. if test $build_dummy = yes; then
  531. build_bitbang=yes
  532. AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
  533. else
  534. AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
  535. fi
  536. if test $build_ep93xx = yes; then
  537. build_bitbang=yes
  538. AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
  539. else
  540. AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
  541. fi
  542. if test $build_zy1000 = yes; then
  543. AC_DEFINE([BUILD_ZY1000], [1], [1 if you want ZY1000.])
  544. else
  545. AC_DEFINE([BUILD_ZY1000], [0], [0 if you don't want ZY1000.])
  546. fi
  547. if test $build_zy1000_master = yes; then
  548. AC_DEFINE([BUILD_ZY1000_MASTER], [1], [1 if you want ZY1000 JTAG master registers.])
  549. else
  550. AC_DEFINE([BUILD_ZY1000_MASTER], [0], [0 if you don't want ZY1000 JTAG master registers.])
  551. fi
  552. if test $build_at91rm9200 = yes; then
  553. build_bitbang=yes
  554. AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
  555. else
  556. AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
  557. fi
  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. if test x$parport_use_ppdev = xyes; then
  565. AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
  566. else
  567. AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
  568. fi
  569. if test x$parport_use_giveio = xyes; then
  570. AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
  571. else
  572. AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
  573. fi
  574. if test $build_bitbang = yes; then
  575. AC_DEFINE([BUILD_BITBANG], [1], [1 if you want a bitbang interface.])
  576. else
  577. AC_DEFINE([BUILD_BITBANG], [0], [0 if you don't want a bitbang interface.])
  578. fi
  579. if test $build_ft2232_libftdi = yes; then
  580. AC_DEFINE([BUILD_FT2232_LIBFTDI], [1], [1 if you want libftdi ft2232.])
  581. else
  582. AC_DEFINE([BUILD_FT2232_LIBFTDI], [0], [0 if you don't want libftdi ft2232.])
  583. fi
  584. if test $build_ft2232_ftd2xx = yes; then
  585. AC_DEFINE([BUILD_FT2232_FTD2XX], [1], [1 if you want ftd2xx ft2232.])
  586. else
  587. AC_DEFINE([BUILD_FT2232_FTD2XX], [0], [0 if you don't want ftd2xx ft2232.])
  588. fi
  589. if test $build_usb_blaster_libftdi = yes; then
  590. AC_DEFINE([BUILD_USB_BLASTER_LIBFTDI], [1], [1 if you want libftdi usb_blaster.])
  591. else
  592. AC_DEFINE([BUILD_USB_BLASTER_LIBFTDI], [0], [0 if you don't want libftdi usb_blaster.])
  593. fi
  594. if test $build_jtag_vpi = yes; then
  595. AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
  596. else
  597. AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
  598. fi
  599. if test $build_usb_blaster_ftd2xx = yes; then
  600. AC_DEFINE([BUILD_USB_BLASTER_FTD2XX], [1], [1 if you want ftd2xx usb_blaster.])
  601. else
  602. AC_DEFINE([BUILD_USB_BLASTER_FTD2XX], [0], [0 if you don't want ftd2xx usb_blaster.])
  603. fi
  604. if test $build_amtjtagaccel = yes; then
  605. AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
  606. else
  607. AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
  608. fi
  609. if test $build_gw16012 = yes; then
  610. AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
  611. else
  612. AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
  613. fi
  614. if test $build_presto_libftdi = yes; then
  615. build_bitq=yes
  616. AC_DEFINE([BUILD_PRESTO_LIBFTDI], [1], [1 if you want the ASIX PRESTO driver using libftdi.])
  617. else
  618. AC_DEFINE([BUILD_PRESTO_LIBFTDI], [0], [0 if you don't want the ASIX PRESTO driver using libftdi.])
  619. fi
  620. if test $build_presto_ftd2xx = yes; then
  621. build_bitq=yes
  622. AC_DEFINE([BUILD_PRESTO_FTD2XX], [1], [1 if you want the ASIX PRESTO driver using FTD2XX.])
  623. else
  624. AC_DEFINE([BUILD_PRESTO_FTD2XX], [0], [0 if you don't want the ASIX PRESTO driver using FTD2XX.])
  625. fi
  626. if test $build_bitq = yes; then
  627. AC_DEFINE([BUILD_BITQ], [1], [1 if you want a bitq interface.])
  628. else
  629. AC_DEFINE([BUILD_BITQ], [0], [0 if you don't want a bitq interface.])
  630. fi
  631. AC_DEFINE([BUILD_OPENJTAG], [0], [0 if you don't want the OpenJTAG driver.])
  632. AC_DEFINE([BUILD_OPENJTAG_FTD2XX], [0], [0 if you don't want the OpenJTAG driver with FTD2XX driver.])
  633. AC_DEFINE([BUILD_OPENJTAG_LIBFTDI], [0], [0 if you don't want to build OpenJTAG driver with libftdi.])
  634. if test $build_openjtag_ftd2xx = yes; then
  635. AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG driver.])
  636. AC_DEFINE([BUILD_OPENJTAG_FTD2XX], [1], [1 if you want the OpenJTAG driver with FTD2XX driver.])
  637. fi
  638. if test $build_openjtag_ftdi = yes; then
  639. AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG drvier.])
  640. AC_DEFINE([BUILD_OPENJTAG_LIBFTDI], [1], [1 if you want to build OpenJTAG with FTDI driver.])
  641. fi
  642. if test $build_oocd_trace = yes; then
  643. AC_DEFINE([BUILD_OOCD_TRACE], [1], [1 if you want the OpenOCD+trace ETM capture driver.])
  644. else
  645. AC_DEFINE([BUILD_OOCD_TRACE], [0], [0 if you don't want the OpenOCD+trace ETM capture driver.])
  646. fi
  647. if test $build_buspirate = yes; then
  648. AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
  649. else
  650. AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
  651. fi
  652. if test $use_internal_jimtcl = yes; then
  653. if test -f "$srcdir/jimtcl/configure.ac"; then
  654. AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
  655. else
  656. AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
  657. fi
  658. fi
  659. if test $build_remote_bitbang = yes; then
  660. build_bitbang=yes
  661. AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
  662. else
  663. AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
  664. fi
  665. if test $build_sysfsgpio = yes; then
  666. build_bitbang=yes
  667. AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
  668. else
  669. AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
  670. fi
  671. #-- Deal with MingW/Cygwin FTD2XX issues
  672. if test $is_win32 = yes; then
  673. if test "${with_ftd2xx_linux_tardir+set}" = set
  674. then
  675. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  676. fi
  677. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes -o $build_openjtag_ftd2xx = yes; then
  678. AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
  679. # if we are given a zipdir...
  680. if test "${with_ftd2xx_win32_zipdir+set}" = set
  681. then
  682. # Set the CFLAGS for "ftd2xx.h"
  683. f=$with_ftd2xx_win32_zipdir/ftd2xx.h
  684. if test ! -f $f ; then
  685. AC_MSG_ERROR([File: $f cannot be found])
  686. fi
  687. CFLAGS="$CFLAGS -I$with_ftd2xx_win32_zipdir"
  688. # And calculate the LDFLAGS for the machine
  689. case "$host_cpu" in
  690. i?86|x86_32)
  691. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/i386"
  692. LIBS="$LIBS -lftd2xx"
  693. f=$with_ftd2xx_win32_zipdir/i386/ftd2xx.lib
  694. ;;
  695. amd64|x86_64)
  696. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/amd64"
  697. LIBS="$LIBS -lftd2xx"
  698. f=$with_ftd2xx_win32_zipdir/amd64/ftd2xx.lib
  699. ;;
  700. *)
  701. AC_MSG_ERROR([Unknown Win32 host cpu: $host_cpu])
  702. ;;
  703. esac
  704. if test ! -f $f ; then
  705. AC_MSG_ERROR([Library: $f not found])
  706. fi
  707. else
  708. LIBS="$LIBS -lftd2xx"
  709. AC_MSG_WARN([ASSUMPTION: The (win32) FTDICHIP.COM files: ftd2xx.h and ftd2xx.lib are in a proper place])
  710. fi
  711. fi
  712. fi # win32
  713. if test $is_darwin = yes ; then
  714. if test "${with_ftd2xx_win32_zipdir+set}" = set
  715. then
  716. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  717. fi
  718. if test "${with_ftd2xx_linux_tardir+set}" = set
  719. then
  720. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  721. fi
  722. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes ; then
  723. AC_MSG_CHECKING([for libftd2xx.a (darwin)])
  724. if test ! -f /usr/local/include/ftd2xx.h ; then
  725. AC_MSG_ERROR([ftd2xx library from FTDICHIP.com seems to be missing, cannot find: /usr/local/include/ftd2xx.h])
  726. fi
  727. CFLAGS="$CFLAGS -I/usr/local/include"
  728. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  729. LIBS="$LIBS -lftd2xx"
  730. AC_MSG_RESULT([-L/usr/local/lib -lftd2xx])
  731. fi
  732. fi # darwin
  733. if test $is_win32 = no && test $is_darwin = no ; then
  734. if test "${with_ftd2xx_win32_zipdir+set}" = set
  735. then
  736. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  737. fi
  738. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes -o $build_openjtag_ftd2xx = yes; then
  739. # Must be linux
  740. if test $host_os != linux-gnu && test $host_os != linux ; then
  741. AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
  742. fi
  743. # Are we given a TAR directory?
  744. if test "${with_ftd2xx_linux_tardir+set}" = set
  745. then
  746. AC_MSG_CHECKING([uninstalled ftd2xx distribution])
  747. # The .H file is simple..
  748. FTD2XX_H=$with_ftd2xx_linux_tardir/ftd2xx.h
  749. if test ! -f "${FTD2XX_H}"; then
  750. AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: ${FTD2XX_H}])
  751. fi
  752. CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir"
  753. if test $with_ftd2xx_lib = shared; then
  754. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir"
  755. FTD2XX_LIB="-lftd2xx"
  756. else
  757. # Test #1 - v1.0.x
  758. case "$host_cpu" in
  759. i?86|x86_32)
  760. dir=build/i386;;
  761. amd64|x86_64)
  762. dir=build/x86_64;;
  763. *)
  764. dir=none;;
  765. esac
  766. if test -f "$with_ftd2xx_linux_tardir/$dir/libftd2xx.a"; then
  767. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir/$dir"
  768. # Also needs -lrt
  769. FTD2XX_LIB="-lftd2xx -lrt"
  770. else
  771. # Test Number2.
  772. # Grr.. perhaps it exists as a version number?
  773. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*"
  774. count=`ls ${FTD2XX_LIB} | wc -l`
  775. if test $count -gt 1 ; then
  776. AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet])
  777. fi
  778. if test $count -ne 1 ; then
  779. AC_MSG_ERROR([Not found: $f, option: --with-ftd2xx-linux-tardir appears to be wrong])
  780. fi
  781. # Because the "-l" rules do not understand version numbers...
  782. # we will just stuff the absolute path onto the LIBS variable
  783. FTD2XX_LIB="`ls ${FTD2XX_LIB}` -lpthread"
  784. FTD2XX_LDFLAGS=""
  785. fi
  786. fi
  787. LDFLAGS="${LDFLAGS} ${FTD2XX_LDFLAGS}"
  788. LIBS="${FTD2XX_LIB} ${LIBS}"
  789. AC_MSG_RESULT([${FTD2XX_LDFLAGS} ${FTD2XX_LIB}])
  790. else
  791. AC_CHECK_HEADER([ftd2xx.h],[],[
  792. AC_MSG_ERROR([You seem to be missing the FTD2xx driver header file.])
  793. ])
  794. AC_SEARCH_LIBS([FT_GetLibraryVersion],[ftd2xx],,[
  795. AC_MSG_ERROR([You appear to be missing the FTD2xx driver library.])
  796. ],[-lrt -lusb-1.0])
  797. fi
  798. fi
  799. fi # linux
  800. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes ; then
  801. # Before we go any further - make sure we can *BUILD* and *RUN*
  802. # a simple app with the "ftd2xx.lib" file - in what ever form we where given
  803. # We should be able to compile, link and run this test program now
  804. AC_MSG_CHECKING([whether ftd2xx library works])
  805. #
  806. # Save the LDFLAGS for later..
  807. LDFLAGS_SAVE=$LDFLAGS
  808. CFLAGS_SAVE=$CFLAGS
  809. _LDFLAGS=`eval echo $LDFLAGS`
  810. _CFLAGS=`eval echo $CFLAGS`
  811. LDFLAGS=$_LDFLAGS
  812. CFLAGS=$_CFLAGS
  813. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  814. #include "confdefs.h"
  815. #if IS_WIN32
  816. #include "windows.h"
  817. #endif
  818. #include <stdio.h>
  819. #include <ftd2xx.h>
  820. ]], [[
  821. DWORD x;
  822. FT_GetLibraryVersion( &x );
  823. ]])], [
  824. AC_MSG_RESULT([Success!])
  825. ], [
  826. AC_MSG_ERROR([Cannot build & run test program using ftd2xx.lib])
  827. ], [
  828. AC_MSG_RESULT([Skipping as we are cross-compiling])
  829. ])
  830. AC_MSG_CHECKING([for ftd2xx highspeed device support])
  831. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  832. #include "confdefs.h"
  833. #if IS_WIN32
  834. #include "windows.h"
  835. #endif
  836. #include <stdio.h>
  837. #include <ftd2xx.h>
  838. DWORD x = FT_DEVICE_4232H;
  839. ]], [])], [
  840. AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
  841. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  842. build_ft2232_highspeed=yes
  843. ], [
  844. build_ft2232_highspeed=no
  845. ])
  846. AC_MSG_RESULT([$build_ft2232_highspeed])
  847. if test $build_ft2232_highspeed = no; then
  848. AC_MSG_WARN([You need a newer FTD2XX driver (version 2.04.16 or later).])
  849. fi
  850. AC_MSG_CHECKING([for ftd2xx FT232H device support])
  851. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  852. #include "confdefs.h"
  853. #if IS_WIN32
  854. #include "windows.h"
  855. #endif
  856. #include <stdio.h>
  857. #include <ftd2xx.h>
  858. DWORD x = FT_DEVICE_232H;
  859. ]], [])], [
  860. AC_DEFINE([HAS_ENUM_FT232H], [1],
  861. [Support FT232H with FTD2XX or libftdi.])
  862. has_enum_ft232h=yes
  863. ], [
  864. has_enum_ft232h=no
  865. ])
  866. AC_MSG_RESULT([$has_enum_ft232h])
  867. if test $has_enum_ft232h = no; then
  868. AC_MSG_WARN([You need a newer FTD2XX driver (version 2.08.12 or later).])
  869. fi
  870. LDFLAGS=$LDFLAGS_SAVE
  871. CFLAGS=$CFLAGS_SAVE
  872. fi
  873. if test $build_ft2232_libftdi = yes -o $build_usb_blaster_libftdi = yes -o \
  874. $build_openjtag_ftdi = yes -o $build_presto_libftdi = yes; then
  875. # we can have libftdi or libftdi1, so check it and use the latest one
  876. PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [use_libftdi=no])
  877. if test $use_libftdi = no; then
  878. PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
  879. fi
  880. if test $use_libftdi = no; then
  881. AC_MSG_ERROR([The libftdi driver is not present on your system.])
  882. fi
  883. #
  884. # Try to build a small program.
  885. AC_MSG_CHECKING([Build & Link with libftdi...])
  886. LDFLAGS_SAVE=$LDFLAGS
  887. CFLAGS_SAVE=$CFLAGS
  888. LIBS_SAVE=$LIBS
  889. _LDFLAGS=`eval echo $LDFLAGS`
  890. _CFLAGS=`eval echo $CFLAGS`
  891. _LIBS=`eval echo $LIBS`
  892. LDFLAGS=$_LDFLAGS
  893. CFLAGS="$_CFLAGS $LIBFTDI_CFLAGS"
  894. LIBS="$_LIBS $LIBFTDI_LIBS"
  895. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  896. #include <stdio.h>
  897. #include <ftdi.h>
  898. ]], [[
  899. struct ftdi_context *p;
  900. p = ftdi_new();
  901. if( p != NULL ){
  902. return 0;
  903. } else {
  904. fprintf( stderr, "calling ftdi_new() failed\n");
  905. return 1;
  906. }
  907. ]])], [
  908. AC_MSG_RESULT([Success])
  909. ], [
  910. AC_MSG_ERROR([Cannot build & run test program using libftdi])
  911. ], [
  912. AC_MSG_RESULT([Skipping as we are cross-compiling, trying build only])
  913. AC_SEARCH_LIBS([ftdi_new], [], [], [AC_MSG_ERROR([Cannot link with libftdi])])
  914. ])
  915. AC_MSG_CHECKING([for libftdi highspeed device support])
  916. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  917. #include <stdio.h>
  918. #include <ftdi.h>
  919. ]], [[
  920. enum ftdi_chip_type x = TYPE_2232H;
  921. ]])], [
  922. AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
  923. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  924. build_ft2232_highspeed=yes
  925. ], [
  926. build_ft2232_highspeed=no
  927. ])
  928. AC_MSG_RESULT([$build_ft2232_highspeed])
  929. if test $build_ft2232_highspeed = no; then
  930. AC_MSG_WARN([You need a newer libftdi version (0.16 or later).])
  931. fi
  932. AC_MSG_CHECKING([for libftdi FT232H device support])
  933. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  934. #include <stdio.h>
  935. #include <ftdi.h>
  936. ]], [[
  937. enum ftdi_chip_type x = TYPE_232H;
  938. ]])], [
  939. AC_DEFINE([HAS_ENUM_FT232H], [1],
  940. [Support FT232H with FTD2XX or libftdi.])
  941. has_enum_ft232h=yes
  942. ], [
  943. has_enum_ft232h=no
  944. ])
  945. AC_MSG_RESULT([$has_enum_ft232h])
  946. if test $has_enum_ft232h = no; then
  947. AC_MSG_WARN([You need a newer libftdi version (0.20 or later).])
  948. fi
  949. # Restore the 'unexpanded ldflags'
  950. LDFLAGS=$LDFLAGS_SAVE
  951. CFLAGS=$CFLAGS_SAVE
  952. LIBS=$LIBS_SAVE
  953. fi
  954. PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
  955. use_libusb1=yes
  956. AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
  957. PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
  958. [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
  959. [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
  960. LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
  961. AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
  962. ], [
  963. use_libusb1=no
  964. AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
  965. ])
  966. PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
  967. for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
  968. PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
  969. use_hidapi=yes
  970. break
  971. ],[
  972. use_hidapi=no
  973. ])
  974. done
  975. m4_define([PROCESS_ADAPTERS], [
  976. m4_foreach([adapter], [$1], [
  977. if test $2; then
  978. if test $ADAPTER_VAR([adapter]) != no; then
  979. AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
  980. else
  981. AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
  982. fi
  983. else
  984. if test $ADAPTER_VAR([adapter]) = yes; then
  985. AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
  986. fi
  987. ADAPTER_VAR([adapter])=no
  988. fi
  989. AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test $ADAPTER_VAR([adapter]) != no])
  990. ])
  991. ])
  992. PROCESS_ADAPTERS([USB1_ADAPTERS], [$use_libusb1 = yes], [libusb-1.x])
  993. PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o $use_libusb0 = yes], [libusb-1.x or libusb-0.1])
  994. PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], [libusb-0.1])
  995. PROCESS_ADAPTERS([HIDAPI_ADAPTERS], [$use_hidapi = yes], [hidapi])
  996. if test $enable_stlink != no -o $enable_ti_icdi != no; then
  997. AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
  998. else
  999. AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
  1000. fi
  1001. AM_CONDITIONAL([HLADAPTER], [test $enable_stlink != no -o $enable_ti_icdi != no])
  1002. AM_CONDITIONAL([RELEASE], [test $build_release = yes])
  1003. AM_CONDITIONAL([PARPORT], [test $build_parport = yes])
  1004. AM_CONDITIONAL([DUMMY], [test $build_dummy = yes])
  1005. AM_CONDITIONAL([GIVEIO], [test x$parport_use_giveio = xyes])
  1006. AM_CONDITIONAL([EP93XX], [test $build_ep93xx = yes])
  1007. AM_CONDITIONAL([ZY1000], [test $build_zy1000 = yes])
  1008. AM_CONDITIONAL([ZY1000_MASTER], [test $build_zy1000_master = yes])
  1009. AM_CONDITIONAL([IOUTIL], [test $build_ioutil = yes])
  1010. AM_CONDITIONAL([AT91RM9200], [test $build_at91rm9200 = yes])
  1011. AM_CONDITIONAL([BCM2835GPIO], [test $build_bcm2835gpio = yes])
  1012. AM_CONDITIONAL([BITBANG], [test $build_bitbang = yes])
  1013. AM_CONDITIONAL([FT2232_LIBFTDI], [test $build_ft2232_libftdi = yes])
  1014. AM_CONDITIONAL([FT2232_DRIVER], [test $build_ft2232_ftd2xx = yes -o $build_ft2232_libftdi = yes])
  1015. AM_CONDITIONAL([USB_BLASTER_LIBFTDI], [test $build_usb_blaster_libftdi = yes])
  1016. AM_CONDITIONAL([USB_BLASTER_FTD2XX], [test $build_usb_blaster_ftd2xx = yes])
  1017. AM_CONDITIONAL([JTAG_VPI], [test $build_jtag_vpi = yes -o $build_jtag_vpi = yes])
  1018. AM_CONDITIONAL([USB_BLASTER_DRIVER], [test $build_usb_blaster_ftd2xx = yes -o $build_usb_blaster_libftdi = yes -o $use_libusb1 = yes])
  1019. AM_CONDITIONAL([AMTJTAGACCEL], [test $build_amtjtagaccel = yes])
  1020. AM_CONDITIONAL([GW16012], [test $build_gw16012 = yes])
  1021. AM_CONDITIONAL([PRESTO_LIBFTDI], [test $build_presto_libftdi = yes])
  1022. AM_CONDITIONAL([PRESTO_DRIVER], [test $build_presto_ftd2xx = yes -o $build_presto_libftdi = yes])
  1023. AM_CONDITIONAL([OPENJTAG], [test $build_openjtag_ftd2xx = yes -o $build_openjtag_ftdi = yes])
  1024. AM_CONDITIONAL([OOCD_TRACE], [test $build_oocd_trace = yes])
  1025. AM_CONDITIONAL([REMOTE_BITBANG], [test $build_remote_bitbang = yes])
  1026. AM_CONDITIONAL([BUSPIRATE], [test $build_buspirate = yes])
  1027. AM_CONDITIONAL([SYSFSGPIO], [test $build_sysfsgpio = yes])
  1028. AM_CONDITIONAL([USE_LIBUSB0], [test $use_libusb0 = yes])
  1029. AM_CONDITIONAL([USE_LIBUSB1], [test $use_libusb1 = yes])
  1030. AM_CONDITIONAL([IS_CYGWIN], [test $is_cygwin = yes])
  1031. AM_CONDITIONAL([IS_MINGW], [test $is_mingw = yes])
  1032. AM_CONDITIONAL([IS_WIN32], [test $is_win32 = yes])
  1033. AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = yes])
  1034. AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
  1035. AM_CONDITIONAL([CMSIS_DAP], [test $use_hidapi = yes])
  1036. AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
  1037. AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
  1038. AM_CONDITIONAL([INTERNAL_JIMTCL], [test $use_internal_jimtcl = yes])
  1039. # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
  1040. AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
  1041. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1042. #define _GNU_SOURCE
  1043. #include <unistd.h>
  1044. #include <stdlib.h>
  1045. ]], [[char **ep = environ;]]
  1046. )], [
  1047. AC_MSG_RESULT([yes])
  1048. has_environ=yes
  1049. ], [
  1050. AC_MSG_RESULT([no])
  1051. # Possibility #2: can environ be found in an available library?
  1052. AC_MSG_CHECKING([for extern environ])
  1053. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1054. extern char **environ;
  1055. ]], [[char **ep = environ;]]
  1056. )], [
  1057. AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
  1058. has_environ=yes
  1059. ], [
  1060. has_environ=no
  1061. ])
  1062. AC_MSG_RESULT([${has_environ}])
  1063. ])
  1064. if test "${has_environ}" != "yes" ; then
  1065. AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
  1066. fi
  1067. AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
  1068. # set default gcc warnings
  1069. GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
  1070. if test "${gcc_wextra}" = yes; then
  1071. GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
  1072. GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
  1073. GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
  1074. GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
  1075. fi
  1076. if test "${gcc_werror}" = yes; then
  1077. GCC_WARNINGS="${GCC_WARNINGS} -Werror"
  1078. fi
  1079. # overide default gcc cflags
  1080. if test $gcc_warnings = yes; then
  1081. CFLAGS="$CFLAGS $GCC_WARNINGS"
  1082. fi
  1083. # Setup for compiling build tools
  1084. AC_MSG_CHECKING([for a C compiler for build tools])
  1085. if test $cross_compiling = yes; then
  1086. AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
  1087. CFLAGS_FOR_BUILD="-g -O2 $GCC_WARNINGS"
  1088. else
  1089. CC_FOR_BUILD=$CC
  1090. CFLAGS_FOR_BUILD=$CFLAGS
  1091. fi
  1092. AC_MSG_RESULT([$CC_FOR_BUILD])
  1093. AC_SUBST([CC_FOR_BUILD])
  1094. AC_SUBST([CFLAGS_FOR_BUILD])
  1095. AC_MSG_CHECKING([for suffix of executable build tools])
  1096. if test $cross_compiling = yes; then
  1097. cat >conftest.c <<\_______EOF
  1098. int main ()
  1099. {
  1100. exit (0);
  1101. }
  1102. _______EOF
  1103. for i in .exe ""; do
  1104. compile="$CC_FOR_BUILD conftest.c -o conftest$i"
  1105. if AC_TRY_EVAL(compile); then
  1106. if (./conftest) 2>&AC_FD_CC; then
  1107. EXEEXT_FOR_BUILD=$i
  1108. break
  1109. fi
  1110. fi
  1111. done
  1112. rm -f conftest*
  1113. if test "${EXEEXT_FOR_BUILD+set}" != set; then
  1114. AC_MSG_ERROR([Cannot determine suffix of executable build tools])
  1115. fi
  1116. else
  1117. EXEEXT_FOR_BUILD=$EXEEXT
  1118. fi
  1119. AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
  1120. AC_SUBST([EXEEXT_FOR_BUILD])
  1121. AC_CONFIG_FILES([
  1122. Makefile
  1123. src/Makefile
  1124. src/helper/Makefile
  1125. src/jtag/Makefile
  1126. src/jtag/drivers/Makefile
  1127. src/jtag/drivers/usb_blaster/Makefile
  1128. src/jtag/hla/Makefile
  1129. src/jtag/aice/Makefile
  1130. src/transport/Makefile
  1131. src/target/openrisc/Makefile
  1132. src/xsvf/Makefile
  1133. src/svf/Makefile
  1134. src/target/Makefile
  1135. src/rtos/Makefile
  1136. src/server/Makefile
  1137. src/flash/Makefile
  1138. src/flash/nor/Makefile
  1139. src/flash/nand/Makefile
  1140. src/pld/Makefile
  1141. doc/Makefile
  1142. ])
  1143. AC_OUTPUT
  1144. echo
  1145. echo
  1146. echo OpenOCD configuration summary
  1147. echo --------------------------------------------------
  1148. m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS, HIDAPI_ADAPTERS],
  1149. [echo -n m4_format(["%-40s"], ADAPTER_DESC([adapter]))
  1150. case $ADAPTER_VAR([adapter]) in
  1151. auto)
  1152. echo yes '(auto)'
  1153. ;;
  1154. yes)
  1155. echo yes
  1156. ;;
  1157. no)
  1158. echo no
  1159. ;;
  1160. esac
  1161. ])
  1162. echo
  1163. if test $build_ft2232_libftdi = yes -o $build_ft2232_ftd2xx = yes; then
  1164. if test $enable_ftdi = no; then
  1165. AC_MSG_WARN([Building the deprecated 'ft2232' adapter driver but not its replacement!])
  1166. AC_MSG_WARN([Please consider using --enable-ftdi instead.])
  1167. else
  1168. AC_MSG_WARN([Building the deprecated 'ft2232' adapter driver.])
  1169. fi
  1170. fi