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.
 
 
 
 
 
 

1315 lines
42 KiB

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