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.
 
 
 
 
 
 

1342 lines
43 KiB

  1. AC_PREREQ(2.64)
  2. AC_INIT([openocd], [0.10.0-dev],
  3. [OpenOCD Mailing List <openocd-devel@lists.sourceforge.net>])
  4. AC_CONFIG_SRCDIR([src/openocd.c])
  5. 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([poll.h])
  101. AC_CHECK_HEADERS([pthread.h])
  102. AC_CHECK_HEADERS([strings.h])
  103. AC_CHECK_HEADERS([sys/ioctl.h])
  104. AC_CHECK_HEADERS([sys/param.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. [[jlink], [Segger J-Link JTAG Programmer], [JLINK]],
  178. [[stlink], [ST-Link JTAG Programmer], [HLADAPTER_STLINK]],
  179. [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]],
  180. [[ulink], [Keil ULINK JTAG Programmer], [ULINK]],
  181. [[usb_blaster_2], [Altera USB-Blaster II Compatible], [USB_BLASTER_2]],
  182. [[vsllink], [Versaloon-Link JTAG Programmer], [VSLLINK]]])
  183. m4_define([USB_ADAPTERS],
  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. AC_ARG_ENABLE([internal-libjaylink],
  429. AS_HELP_STRING([--disable-internal-libjaylink],
  430. [Disable building internal libjaylink]),
  431. [use_internal_libjaylink=$enableval], [use_internal_libjaylink=yes])
  432. build_minidriver=no
  433. AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
  434. if test $build_zy1000 = yes; then
  435. if test $build_minidriver = yes; then
  436. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  437. fi
  438. AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
  439. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  440. build_minidriver=yes
  441. fi
  442. AC_MSG_RESULT([$build_zy1000])
  443. AC_ARG_ENABLE([remote-bitbang],
  444. AS_HELP_STRING([--enable-remote-bitbang], [Enable building support for the Remote Bitbang jtag driver]),
  445. [build_remote_bitbang=$enableval], [build_remote_bitbang=no])
  446. AC_MSG_CHECKING([whether to enable dummy minidriver])
  447. if test $build_minidriver_dummy = yes; then
  448. if test $build_minidriver = yes; then
  449. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  450. fi
  451. build_minidriver=yes
  452. AC_DEFINE([BUILD_MINIDRIVER_DUMMY], [1], [Use the dummy minidriver.])
  453. AC_DEFINE([HAVE_JTAG_MINIDRIVER_H], [1],
  454. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  455. fi
  456. AC_MSG_RESULT([$build_minidriver_dummy])
  457. AC_MSG_CHECKING([whether standard drivers can be built])
  458. if test "$build_minidriver" = yes; then
  459. AC_MSG_RESULT([no])
  460. AC_MSG_WARN([Using the minidriver disables all other drivers.])
  461. sleep 2
  462. else
  463. AC_MSG_RESULT([yes])
  464. fi
  465. case "${host_cpu}" in
  466. i?86|x86*)
  467. ;;
  468. *)
  469. if test x$parport_use_ppdev = xno; then
  470. AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
  471. fi
  472. parport_use_ppdev=yes
  473. ;;
  474. esac
  475. case $host in
  476. *-cygwin*)
  477. is_win32=yes
  478. parport_use_ppdev=no
  479. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[return __MINGW32__;]])],
  480. [is_mingw=yes],[is_mingw=no])
  481. if test $is_mingw = yes; then
  482. AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
  483. if test x$parport_use_giveio = xno; then
  484. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  485. fi
  486. parport_use_giveio=yes
  487. is_cygwin=no
  488. else
  489. is_cygwin=yes
  490. AC_DEFINE([IS_CYGWIN], [1], [1 if building for Cygwin.])
  491. # sys/io.h needed under cygwin for parport access
  492. if test $build_parport = yes; then
  493. AC_CHECK_HEADERS([sys/io.h],[],AC_MSG_ERROR([Please install the cygwin ioperm package]))
  494. fi
  495. fi
  496. AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
  497. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  498. ;;
  499. *-mingw*)
  500. is_mingw=yes
  501. is_win32=yes
  502. parport_use_ppdev=no
  503. if test x$parport_use_giveio = xno; then
  504. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  505. fi
  506. parport_use_giveio=yes
  507. if test x$build_buspirate = xyes; then
  508. AC_MSG_ERROR([buspirate currently not supported by MinGW32 hosts])
  509. fi
  510. CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO"
  511. AC_DEFINE([IS_MINGW], [1], [1 if building for MinGW.])
  512. AC_DEFINE([IS_WIN32], [1], [1 if building for Win32.])
  513. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  514. ;;
  515. *darwin*)
  516. is_darwin=yes
  517. if test x$parport_use_giveio = xyes; then
  518. AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
  519. fi
  520. parport_use_giveio=no
  521. AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
  522. AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
  523. AC_DEFINE([IS_DARWIN], [1], [1 if building for Darwin.])
  524. ;;
  525. *)
  526. if test x$parport_use_giveio = xyes; then
  527. AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
  528. fi
  529. parport_use_giveio=no
  530. AC_DEFINE([IS_CYGWIN], [0], [0 if not building for Cygwin.])
  531. AC_DEFINE([IS_WIN32], [0], [0 if not building for Win32.])
  532. AC_DEFINE([IS_DARWIN], [0], [0 if not building for Darwin.])
  533. ;;
  534. esac
  535. if test $is_win32 = yes; then
  536. AC_DEFINE([WIN32_LEAN_AND_MEAN], [1], [1 to exclude old conflicting definitions when building on Windows])
  537. fi
  538. if test $build_parport = yes; then
  539. build_bitbang=yes
  540. AC_DEFINE([BUILD_PARPORT], [1], [1 if you want parport.])
  541. else
  542. AC_DEFINE([BUILD_PARPORT], [0], [0 if you don't want parport.])
  543. fi
  544. if test $build_dummy = yes; then
  545. build_bitbang=yes
  546. AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
  547. else
  548. AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
  549. fi
  550. if test $build_ep93xx = yes; then
  551. build_bitbang=yes
  552. AC_DEFINE([BUILD_EP93XX], [1], [1 if you want ep93xx.])
  553. else
  554. AC_DEFINE([BUILD_EP93XX], [0], [0 if you don't want ep93xx.])
  555. fi
  556. if test $build_zy1000 = yes; then
  557. AC_DEFINE([BUILD_ZY1000], [1], [1 if you want ZY1000.])
  558. else
  559. AC_DEFINE([BUILD_ZY1000], [0], [0 if you don't want ZY1000.])
  560. fi
  561. if test $build_zy1000_master = yes; then
  562. AC_DEFINE([BUILD_ZY1000_MASTER], [1], [1 if you want ZY1000 JTAG master registers.])
  563. else
  564. AC_DEFINE([BUILD_ZY1000_MASTER], [0], [0 if you don't want ZY1000 JTAG master registers.])
  565. fi
  566. if test $build_at91rm9200 = yes; then
  567. build_bitbang=yes
  568. AC_DEFINE([BUILD_AT91RM9200], [1], [1 if you want at91rm9200.])
  569. else
  570. AC_DEFINE([BUILD_AT91RM9200], [0], [0 if you don't want at91rm9200.])
  571. fi
  572. if test $build_bcm2835gpio = yes; then
  573. build_bitbang=yes
  574. AC_DEFINE([BUILD_BCM2835GPIO], [1], [1 if you want bcm2835gpio.])
  575. else
  576. AC_DEFINE([BUILD_BCM2835GPIO], [0], [0 if you don't want bcm2835gpio.])
  577. fi
  578. if test x$parport_use_ppdev = xyes; then
  579. AC_DEFINE([PARPORT_USE_PPDEV], [1], [1 if you want parport to use ppdev.])
  580. else
  581. AC_DEFINE([PARPORT_USE_PPDEV], [0], [0 if you don't want parport to use ppdev.])
  582. fi
  583. if test x$parport_use_giveio = xyes; then
  584. AC_DEFINE([PARPORT_USE_GIVEIO], [1], [1 if you want parport to use giveio.])
  585. else
  586. AC_DEFINE([PARPORT_USE_GIVEIO], [0], [0 if you don't want parport to use giveio.])
  587. fi
  588. if test $build_bitbang = yes; then
  589. AC_DEFINE([BUILD_BITBANG], [1], [1 if you want a bitbang interface.])
  590. else
  591. AC_DEFINE([BUILD_BITBANG], [0], [0 if you don't want a bitbang interface.])
  592. fi
  593. if test $build_ft2232_libftdi = yes; then
  594. AC_DEFINE([BUILD_FT2232_LIBFTDI], [1], [1 if you want libftdi ft2232.])
  595. else
  596. AC_DEFINE([BUILD_FT2232_LIBFTDI], [0], [0 if you don't want libftdi ft2232.])
  597. fi
  598. if test $build_ft2232_ftd2xx = yes; then
  599. AC_DEFINE([BUILD_FT2232_FTD2XX], [1], [1 if you want ftd2xx ft2232.])
  600. else
  601. AC_DEFINE([BUILD_FT2232_FTD2XX], [0], [0 if you don't want ftd2xx ft2232.])
  602. fi
  603. if test $build_usb_blaster_libftdi = yes; then
  604. AC_DEFINE([BUILD_USB_BLASTER_LIBFTDI], [1], [1 if you want libftdi usb_blaster.])
  605. else
  606. AC_DEFINE([BUILD_USB_BLASTER_LIBFTDI], [0], [0 if you don't want libftdi usb_blaster.])
  607. fi
  608. if test $build_jtag_vpi = yes; then
  609. AC_DEFINE([BUILD_JTAG_VPI], [1], [1 if you want JTAG VPI.])
  610. else
  611. AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
  612. fi
  613. if test $build_usb_blaster_ftd2xx = yes; then
  614. AC_DEFINE([BUILD_USB_BLASTER_FTD2XX], [1], [1 if you want ftd2xx usb_blaster.])
  615. else
  616. AC_DEFINE([BUILD_USB_BLASTER_FTD2XX], [0], [0 if you don't want ftd2xx usb_blaster.])
  617. fi
  618. if test $build_amtjtagaccel = yes; then
  619. AC_DEFINE([BUILD_AMTJTAGACCEL], [1], [1 if you want the Amontec JTAG-Accelerator driver.])
  620. else
  621. AC_DEFINE([BUILD_AMTJTAGACCEL], [0], [0 if you don't want the Amontec JTAG-Accelerator driver.])
  622. fi
  623. if test $build_gw16012 = yes; then
  624. AC_DEFINE([BUILD_GW16012], [1], [1 if you want the Gateworks GW16012 driver.])
  625. else
  626. AC_DEFINE([BUILD_GW16012], [0], [0 if you don't want the Gateworks GW16012 driver.])
  627. fi
  628. if test $build_presto_libftdi = yes; then
  629. build_bitq=yes
  630. AC_DEFINE([BUILD_PRESTO_LIBFTDI], [1], [1 if you want the ASIX PRESTO driver using libftdi.])
  631. else
  632. AC_DEFINE([BUILD_PRESTO_LIBFTDI], [0], [0 if you don't want the ASIX PRESTO driver using libftdi.])
  633. fi
  634. if test $build_presto_ftd2xx = yes; then
  635. build_bitq=yes
  636. AC_DEFINE([BUILD_PRESTO_FTD2XX], [1], [1 if you want the ASIX PRESTO driver using FTD2XX.])
  637. else
  638. AC_DEFINE([BUILD_PRESTO_FTD2XX], [0], [0 if you don't want the ASIX PRESTO driver using FTD2XX.])
  639. fi
  640. if test $build_bitq = yes; then
  641. AC_DEFINE([BUILD_BITQ], [1], [1 if you want a bitq interface.])
  642. else
  643. AC_DEFINE([BUILD_BITQ], [0], [0 if you don't want a bitq interface.])
  644. fi
  645. AC_DEFINE([BUILD_OPENJTAG], [0], [0 if you don't want the OpenJTAG driver.])
  646. AC_DEFINE([BUILD_OPENJTAG_FTD2XX], [0], [0 if you don't want the OpenJTAG driver with FTD2XX driver.])
  647. AC_DEFINE([BUILD_OPENJTAG_LIBFTDI], [0], [0 if you don't want to build OpenJTAG driver with libftdi.])
  648. if test $build_openjtag_ftd2xx = yes; then
  649. AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG driver.])
  650. AC_DEFINE([BUILD_OPENJTAG_FTD2XX], [1], [1 if you want the OpenJTAG driver with FTD2XX driver.])
  651. fi
  652. if test $build_openjtag_ftdi = yes; then
  653. AC_DEFINE([BUILD_OPENJTAG], [1], [1 if you want the OpenJTAG drvier.])
  654. AC_DEFINE([BUILD_OPENJTAG_LIBFTDI], [1], [1 if you want to build OpenJTAG with FTDI driver.])
  655. fi
  656. if test $build_oocd_trace = yes; then
  657. AC_DEFINE([BUILD_OOCD_TRACE], [1], [1 if you want the OpenOCD+trace ETM capture driver.])
  658. else
  659. AC_DEFINE([BUILD_OOCD_TRACE], [0], [0 if you don't want the OpenOCD+trace ETM capture driver.])
  660. fi
  661. if test $build_buspirate = yes; then
  662. AC_DEFINE([BUILD_BUSPIRATE], [1], [1 if you want the Buspirate JTAG driver.])
  663. else
  664. AC_DEFINE([BUILD_BUSPIRATE], [0], [0 if you don't want the Buspirate JTAG driver.])
  665. fi
  666. if test $use_internal_jimtcl = yes; then
  667. if test -f "$srcdir/jimtcl/configure.ac"; then
  668. AX_CONFIG_SUBDIR_OPTION([jimtcl], [--disable-install-jim])
  669. else
  670. AC_MSG_ERROR([jimtcl not found, run git submodule init and git submodule update.])
  671. fi
  672. fi
  673. if test $use_internal_libjaylink = yes; then
  674. if test -f "$srcdir/src/jtag/drivers/libjaylink/configure.ac"; then
  675. ( cd $srcdir/src/jtag/drivers/libjaylink/ && ./autogen.sh )
  676. AX_CONFIG_SUBDIR_OPTION([src/jtag/drivers/libjaylink],
  677. [--enable-subproject-build])
  678. else
  679. AC_MSG_ERROR([Internal libjaylink not found, run either 'git submodule init' and 'git submodule update' or disable internal libjaylink with --disable-internal-libjaylink.])
  680. fi
  681. else
  682. PKG_CHECK_MODULES([libjaylink], [libjaylink >= 0.1],
  683. [CFLAGS="$CFLAGS $libjaylink_CFLAGS"; LIBS="$LIBS $libjaylink_LIBS"; HAVE_LIBJAYLINK=yes], [HAVE_LIBJAYLINK=no])
  684. fi
  685. if test $build_remote_bitbang = yes; then
  686. build_bitbang=yes
  687. AC_DEFINE([BUILD_REMOTE_BITBANG], [1], [1 if you want the Remote Bitbang JTAG driver.])
  688. else
  689. AC_DEFINE([BUILD_REMOTE_BITBANG], [0], [0 if you don't want the Remote Bitbang JTAG driver.])
  690. fi
  691. if test $build_sysfsgpio = yes; then
  692. build_bitbang=yes
  693. AC_DEFINE([BUILD_SYSFSGPIO], [1], [1 if you want the SysfsGPIO driver.])
  694. else
  695. AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
  696. fi
  697. #-- Deal with MingW/Cygwin FTD2XX issues
  698. if test $is_win32 = yes; then
  699. if test "${with_ftd2xx_linux_tardir+set}" = set
  700. then
  701. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  702. fi
  703. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes -o $build_openjtag_ftd2xx = yes; then
  704. AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
  705. # if we are given a zipdir...
  706. if test "${with_ftd2xx_win32_zipdir+set}" = set
  707. then
  708. # Set the CFLAGS for "ftd2xx.h"
  709. f=$with_ftd2xx_win32_zipdir/ftd2xx.h
  710. if test ! -f $f ; then
  711. AC_MSG_ERROR([File: $f cannot be found])
  712. fi
  713. CFLAGS="$CFLAGS -I$with_ftd2xx_win32_zipdir"
  714. # And calculate the LDFLAGS for the machine
  715. case "$host_cpu" in
  716. i?86|x86_32)
  717. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/i386"
  718. LIBS="$LIBS -lftd2xx"
  719. f=$with_ftd2xx_win32_zipdir/i386/ftd2xx.lib
  720. ;;
  721. amd64|x86_64)
  722. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/amd64"
  723. LIBS="$LIBS -lftd2xx"
  724. f=$with_ftd2xx_win32_zipdir/amd64/ftd2xx.lib
  725. ;;
  726. *)
  727. AC_MSG_ERROR([Unknown Win32 host cpu: $host_cpu])
  728. ;;
  729. esac
  730. if test ! -f $f ; then
  731. AC_MSG_ERROR([Library: $f not found])
  732. fi
  733. else
  734. LIBS="$LIBS -lftd2xx"
  735. AC_MSG_WARN([ASSUMPTION: The (win32) FTDICHIP.COM files: ftd2xx.h and ftd2xx.lib are in a proper place])
  736. fi
  737. fi
  738. fi # win32
  739. if test $is_darwin = yes ; then
  740. if test "${with_ftd2xx_win32_zipdir+set}" = set
  741. then
  742. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  743. fi
  744. if test "${with_ftd2xx_linux_tardir+set}" = set
  745. then
  746. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  747. fi
  748. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes ; then
  749. AC_MSG_CHECKING([for libftd2xx.a (darwin)])
  750. if test ! -f /usr/local/include/ftd2xx.h ; then
  751. AC_MSG_ERROR([ftd2xx library from FTDICHIP.com seems to be missing, cannot find: /usr/local/include/ftd2xx.h])
  752. fi
  753. CFLAGS="$CFLAGS -I/usr/local/include"
  754. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  755. LIBS="$LIBS -lftd2xx"
  756. AC_MSG_RESULT([-L/usr/local/lib -lftd2xx])
  757. fi
  758. fi # darwin
  759. if test $is_win32 = no && test $is_darwin = no ; then
  760. if test "${with_ftd2xx_win32_zipdir+set}" = set
  761. then
  762. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  763. fi
  764. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes -o $build_openjtag_ftd2xx = yes; then
  765. # Must be linux
  766. if test $host_os != linux-gnu && test $host_os != linux ; then
  767. AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
  768. fi
  769. # Are we given a TAR directory?
  770. if test "${with_ftd2xx_linux_tardir+set}" = set
  771. then
  772. AC_MSG_CHECKING([uninstalled ftd2xx distribution])
  773. # The .H file is simple..
  774. FTD2XX_H=$with_ftd2xx_linux_tardir/ftd2xx.h
  775. if test ! -f "${FTD2XX_H}"; then
  776. AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: ${FTD2XX_H}])
  777. fi
  778. CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir"
  779. if test $with_ftd2xx_lib = shared; then
  780. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir"
  781. FTD2XX_LIB="-lftd2xx"
  782. else
  783. # Test #1 - v1.0.x
  784. case "$host_cpu" in
  785. i?86|x86_32)
  786. dir=build/i386;;
  787. amd64|x86_64)
  788. dir=build/x86_64;;
  789. *)
  790. dir=none;;
  791. esac
  792. if test -f "$with_ftd2xx_linux_tardir/$dir/libftd2xx.a"; then
  793. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir/$dir"
  794. # Also needs -lrt
  795. FTD2XX_LIB="-lftd2xx -lrt"
  796. else
  797. # Test Number2.
  798. # Grr.. perhaps it exists as a version number?
  799. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*"
  800. count=`ls ${FTD2XX_LIB} | wc -l`
  801. if test $count -gt 1 ; then
  802. AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet])
  803. fi
  804. if test $count -ne 1 ; then
  805. AC_MSG_ERROR([Not found: $f, option: --with-ftd2xx-linux-tardir appears to be wrong])
  806. fi
  807. # Because the "-l" rules do not understand version numbers...
  808. # we will just stuff the absolute path onto the LIBS variable
  809. FTD2XX_LIB="`ls ${FTD2XX_LIB}` -lpthread"
  810. FTD2XX_LDFLAGS=""
  811. fi
  812. fi
  813. LDFLAGS="${LDFLAGS} ${FTD2XX_LDFLAGS}"
  814. LIBS="${FTD2XX_LIB} ${LIBS}"
  815. AC_MSG_RESULT([${FTD2XX_LDFLAGS} ${FTD2XX_LIB}])
  816. else
  817. AC_CHECK_HEADER([ftd2xx.h],[],[
  818. AC_MSG_ERROR([You seem to be missing the FTD2xx driver header file.])
  819. ])
  820. AC_SEARCH_LIBS([FT_GetLibraryVersion],[ftd2xx],,[
  821. AC_MSG_ERROR([You appear to be missing the FTD2xx driver library.])
  822. ],[-lrt -lusb-1.0])
  823. fi
  824. fi
  825. fi # linux
  826. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes -o $build_usb_blaster_ftd2xx = yes ; then
  827. # Before we go any further - make sure we can *BUILD* and *RUN*
  828. # a simple app with the "ftd2xx.lib" file - in what ever form we where given
  829. # We should be able to compile, link and run this test program now
  830. AC_MSG_CHECKING([whether ftd2xx library works])
  831. #
  832. # Save the LDFLAGS for later..
  833. LDFLAGS_SAVE=$LDFLAGS
  834. CFLAGS_SAVE=$CFLAGS
  835. _LDFLAGS=`eval echo $LDFLAGS`
  836. _CFLAGS=`eval echo $CFLAGS`
  837. LDFLAGS=$_LDFLAGS
  838. CFLAGS=$_CFLAGS
  839. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  840. #include "confdefs.h"
  841. #if IS_WIN32
  842. #include "windows.h"
  843. #endif
  844. #include <stdio.h>
  845. #include <ftd2xx.h>
  846. ]], [[
  847. DWORD x;
  848. FT_GetLibraryVersion( &x );
  849. ]])], [
  850. AC_MSG_RESULT([Success!])
  851. ], [
  852. AC_MSG_ERROR([Cannot build & run test program using ftd2xx.lib])
  853. ], [
  854. AC_MSG_RESULT([Skipping as we are cross-compiling])
  855. ])
  856. AC_MSG_CHECKING([for ftd2xx highspeed device support])
  857. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  858. #include "confdefs.h"
  859. #if IS_WIN32
  860. #include "windows.h"
  861. #endif
  862. #include <stdio.h>
  863. #include <ftd2xx.h>
  864. DWORD x = FT_DEVICE_4232H;
  865. ]], [])], [
  866. AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
  867. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  868. build_ft2232_highspeed=yes
  869. ], [
  870. build_ft2232_highspeed=no
  871. ])
  872. AC_MSG_RESULT([$build_ft2232_highspeed])
  873. if test $build_ft2232_highspeed = no; then
  874. AC_MSG_WARN([You need a newer FTD2XX driver (version 2.04.16 or later).])
  875. fi
  876. AC_MSG_CHECKING([for ftd2xx FT232H device support])
  877. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  878. #include "confdefs.h"
  879. #if IS_WIN32
  880. #include "windows.h"
  881. #endif
  882. #include <stdio.h>
  883. #include <ftd2xx.h>
  884. DWORD x = FT_DEVICE_232H;
  885. ]], [])], [
  886. AC_DEFINE([HAS_ENUM_FT232H], [1],
  887. [Support FT232H with FTD2XX or libftdi.])
  888. has_enum_ft232h=yes
  889. ], [
  890. has_enum_ft232h=no
  891. ])
  892. AC_MSG_RESULT([$has_enum_ft232h])
  893. if test $has_enum_ft232h = no; then
  894. AC_MSG_WARN([You need a newer FTD2XX driver (version 2.08.12 or later).])
  895. fi
  896. LDFLAGS=$LDFLAGS_SAVE
  897. CFLAGS=$CFLAGS_SAVE
  898. fi
  899. if test $build_ft2232_libftdi = yes -o $build_usb_blaster_libftdi = yes -o \
  900. $build_openjtag_ftdi = yes -o $build_presto_libftdi = yes; then
  901. # we can have libftdi or libftdi1, so check it and use the latest one
  902. PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [use_libftdi=yes], [use_libftdi=no])
  903. if test $use_libftdi = no; then
  904. PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no])
  905. fi
  906. if test $use_libftdi = no; then
  907. AC_MSG_ERROR([The libftdi driver is not present on your system.])
  908. fi
  909. #
  910. # Try to build a small program.
  911. AC_MSG_CHECKING([Build & Link with libftdi...])
  912. LDFLAGS_SAVE=$LDFLAGS
  913. CFLAGS_SAVE=$CFLAGS
  914. LIBS_SAVE=$LIBS
  915. _LDFLAGS=`eval echo $LDFLAGS`
  916. _CFLAGS=`eval echo $CFLAGS`
  917. _LIBS=`eval echo $LIBS`
  918. LDFLAGS=$_LDFLAGS
  919. CFLAGS="$_CFLAGS $LIBFTDI_CFLAGS"
  920. LIBS="$_LIBS $LIBFTDI_LIBS"
  921. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  922. #include <stdio.h>
  923. #include <ftdi.h>
  924. ]], [[
  925. struct ftdi_context *p;
  926. p = ftdi_new();
  927. if( p != NULL ){
  928. return 0;
  929. } else {
  930. fprintf( stderr, "calling ftdi_new() failed\n");
  931. return 1;
  932. }
  933. ]])], [
  934. AC_MSG_RESULT([Success])
  935. ], [
  936. AC_MSG_ERROR([Cannot build & run test program using libftdi])
  937. ], [
  938. AC_MSG_RESULT([Skipping as we are cross-compiling, trying build only])
  939. AC_SEARCH_LIBS([ftdi_new], [], [], [AC_MSG_ERROR([Cannot link with libftdi])])
  940. ])
  941. AC_MSG_CHECKING([for libftdi highspeed device support])
  942. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  943. #include <stdio.h>
  944. #include <ftdi.h>
  945. ]], [[
  946. enum ftdi_chip_type x = TYPE_2232H;
  947. ]])], [
  948. AC_DEFINE([BUILD_FT2232_HIGHSPEED], [1],
  949. [Support FT2232H/FT4232HS with FTD2XX or libftdi.])
  950. build_ft2232_highspeed=yes
  951. ], [
  952. build_ft2232_highspeed=no
  953. ])
  954. AC_MSG_RESULT([$build_ft2232_highspeed])
  955. if test $build_ft2232_highspeed = no; then
  956. AC_MSG_WARN([You need a newer libftdi version (0.16 or later).])
  957. fi
  958. AC_MSG_CHECKING([for libftdi FT232H device support])
  959. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  960. #include <stdio.h>
  961. #include <ftdi.h>
  962. ]], [[
  963. enum ftdi_chip_type x = TYPE_232H;
  964. ]])], [
  965. AC_DEFINE([HAS_ENUM_FT232H], [1],
  966. [Support FT232H with FTD2XX or libftdi.])
  967. has_enum_ft232h=yes
  968. ], [
  969. has_enum_ft232h=no
  970. ])
  971. AC_MSG_RESULT([$has_enum_ft232h])
  972. if test $has_enum_ft232h = no; then
  973. AC_MSG_WARN([You need a newer libftdi version (0.20 or later).])
  974. fi
  975. # Restore the 'unexpanded ldflags'
  976. LDFLAGS=$LDFLAGS_SAVE
  977. CFLAGS=$CFLAGS_SAVE
  978. LIBS=$LIBS_SAVE
  979. fi
  980. PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
  981. use_libusb1=yes
  982. AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
  983. PKG_CHECK_EXISTS([libusb-1.0 >= 1.0.9],
  984. [AC_DEFINE([HAVE_LIBUSB_ERROR_NAME], [1], [Define if your libusb has libusb_error_name()])],
  985. [AC_MSG_WARN([libusb-1.x older than 1.0.9 detected, consider updating])])
  986. LIBUSB1_CFLAGS=`echo $LIBUSB1_CFLAGS | sed 's/-I/-isystem /'`
  987. AC_MSG_NOTICE([libusb-1.0 header bug workaround: LIBUSB1_CFLAGS changed to "$LIBUSB1_CFLAGS"])
  988. ], [
  989. use_libusb1=no
  990. AC_MSG_WARN([libusb-1.x not found, trying legacy libusb-0.1 as a fallback; consider installing libusb-1.x instead])
  991. ])
  992. PKG_CHECK_MODULES([LIBUSB0], [libusb], [use_libusb0=yes], [use_libusb0=no])
  993. for hidapi_lib in hidapi hidapi-hidraw hidapi-libusb; do
  994. PKG_CHECK_MODULES([HIDAPI],[$hidapi_lib],[
  995. use_hidapi=yes
  996. break
  997. ],[
  998. use_hidapi=no
  999. ])
  1000. done
  1001. m4_define([PROCESS_ADAPTERS], [
  1002. m4_foreach([adapter], [$1], [
  1003. if test $2; then
  1004. if test $ADAPTER_VAR([adapter]) != no; then
  1005. AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [1], [1 if you want the ]ADAPTER_DESC([adapter]).)
  1006. else
  1007. AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
  1008. fi
  1009. else
  1010. if test $ADAPTER_VAR([adapter]) = yes; then
  1011. AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
  1012. fi
  1013. ADAPTER_VAR([adapter])=no
  1014. fi
  1015. AM_CONDITIONAL(ADAPTER_SYM([adapter]), [test $ADAPTER_VAR([adapter]) != no])
  1016. ])
  1017. ])
  1018. PROCESS_ADAPTERS([USB1_ADAPTERS], [$use_libusb1 = yes], [libusb-1.x])
  1019. PROCESS_ADAPTERS([USB_ADAPTERS], [$use_libusb1 = yes -o $use_libusb0 = yes], [libusb-1.x or libusb-0.1])
  1020. PROCESS_ADAPTERS([USB0_ADAPTERS], [$use_libusb0 = yes], [libusb-0.1])
  1021. PROCESS_ADAPTERS([HIDAPI_ADAPTERS], [$use_hidapi = yes], [hidapi])
  1022. if test $enable_stlink != no -o $enable_ti_icdi != no; then
  1023. AC_DEFINE([BUILD_HLADAPTER], [1], [1 if you want the High Level JTAG driver.])
  1024. else
  1025. AC_DEFINE([BUILD_HLADAPTER], [0], [0 if you want the High Level JTAG driver.])
  1026. fi
  1027. AM_CONDITIONAL([HLADAPTER], [test $enable_stlink != no -o $enable_ti_icdi != no])
  1028. # Disable J-Link driver if internal libjaylink is disabled and libjaylink was
  1029. # not found by pkg-config.
  1030. if test $enable_jlink != no; then
  1031. if test $use_internal_libjaylink$HAVE_LIBJAYLINK = nono; then
  1032. enable_jlink=no
  1033. fi
  1034. fi
  1035. AM_CONDITIONAL([RELEASE], [test $build_release = yes])
  1036. AM_CONDITIONAL([PARPORT], [test $build_parport = yes])
  1037. AM_CONDITIONAL([DUMMY], [test $build_dummy = yes])
  1038. AM_CONDITIONAL([GIVEIO], [test x$parport_use_giveio = xyes])
  1039. AM_CONDITIONAL([EP93XX], [test $build_ep93xx = yes])
  1040. AM_CONDITIONAL([ZY1000], [test $build_zy1000 = yes])
  1041. AM_CONDITIONAL([ZY1000_MASTER], [test $build_zy1000_master = yes])
  1042. AM_CONDITIONAL([IOUTIL], [test $build_ioutil = yes])
  1043. AM_CONDITIONAL([AT91RM9200], [test $build_at91rm9200 = yes])
  1044. AM_CONDITIONAL([BCM2835GPIO], [test $build_bcm2835gpio = yes])
  1045. AM_CONDITIONAL([BITBANG], [test $build_bitbang = yes])
  1046. AM_CONDITIONAL([FT2232_LIBFTDI], [test $build_ft2232_libftdi = yes])
  1047. AM_CONDITIONAL([FT2232_DRIVER], [test $build_ft2232_ftd2xx = yes -o $build_ft2232_libftdi = yes])
  1048. AM_CONDITIONAL([USB_BLASTER_LIBFTDI], [test $build_usb_blaster_libftdi = yes])
  1049. AM_CONDITIONAL([USB_BLASTER_FTD2XX], [test $build_usb_blaster_ftd2xx = yes])
  1050. AM_CONDITIONAL([JTAG_VPI], [test $build_jtag_vpi = yes -o $build_jtag_vpi = yes])
  1051. AM_CONDITIONAL([USB_BLASTER_DRIVER], [test $build_usb_blaster_ftd2xx = yes -o $build_usb_blaster_libftdi = yes -o $enable_usb_blaster_2 != no])
  1052. AM_CONDITIONAL([AMTJTAGACCEL], [test $build_amtjtagaccel = yes])
  1053. AM_CONDITIONAL([GW16012], [test $build_gw16012 = yes])
  1054. AM_CONDITIONAL([PRESTO_LIBFTDI], [test $build_presto_libftdi = yes])
  1055. AM_CONDITIONAL([PRESTO_DRIVER], [test $build_presto_ftd2xx = yes -o $build_presto_libftdi = yes])
  1056. AM_CONDITIONAL([OPENJTAG], [test $build_openjtag_ftd2xx = yes -o $build_openjtag_ftdi = yes])
  1057. AM_CONDITIONAL([OOCD_TRACE], [test $build_oocd_trace = yes])
  1058. AM_CONDITIONAL([REMOTE_BITBANG], [test $build_remote_bitbang = yes])
  1059. AM_CONDITIONAL([BUSPIRATE], [test $build_buspirate = yes])
  1060. AM_CONDITIONAL([SYSFSGPIO], [test $build_sysfsgpio = yes])
  1061. AM_CONDITIONAL([USE_LIBUSB0], [test $use_libusb0 = yes])
  1062. AM_CONDITIONAL([USE_LIBUSB1], [test $use_libusb1 = yes])
  1063. AM_CONDITIONAL([IS_CYGWIN], [test $is_cygwin = yes])
  1064. AM_CONDITIONAL([IS_MINGW], [test $is_mingw = yes])
  1065. AM_CONDITIONAL([IS_WIN32], [test $is_win32 = yes])
  1066. AM_CONDITIONAL([IS_DARWIN], [test $is_darwin = yes])
  1067. AM_CONDITIONAL([BITQ], [test $build_bitq = yes])
  1068. AM_CONDITIONAL([CMSIS_DAP], [test $use_hidapi = yes])
  1069. AM_CONDITIONAL([MINIDRIVER], [test $build_minidriver = yes])
  1070. AM_CONDITIONAL([MINIDRIVER_DUMMY], [test $build_minidriver_dummy = yes])
  1071. AM_CONDITIONAL([INTERNAL_JIMTCL], [test $use_internal_jimtcl = yes])
  1072. AM_CONDITIONAL([INTERNAL_LIBJAYLINK], [test $use_internal_libjaylink = yes])
  1073. # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
  1074. AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
  1075. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1076. #define _GNU_SOURCE
  1077. #include <unistd.h>
  1078. #include <stdlib.h>
  1079. ]], [[char **ep = environ;]]
  1080. )], [
  1081. AC_MSG_RESULT([yes])
  1082. has_environ=yes
  1083. ], [
  1084. AC_MSG_RESULT([no])
  1085. # Possibility #2: can environ be found in an available library?
  1086. AC_MSG_CHECKING([for extern environ])
  1087. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1088. extern char **environ;
  1089. ]], [[char **ep = environ;]]
  1090. )], [
  1091. AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
  1092. has_environ=yes
  1093. ], [
  1094. has_environ=no
  1095. ])
  1096. AC_MSG_RESULT([${has_environ}])
  1097. ])
  1098. if test "${has_environ}" != "yes" ; then
  1099. AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
  1100. fi
  1101. AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
  1102. # set default gcc warnings
  1103. GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security -Wshadow"
  1104. if test "${gcc_wextra}" = yes; then
  1105. GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
  1106. GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
  1107. GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
  1108. GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
  1109. fi
  1110. if test "${gcc_werror}" = yes; then
  1111. GCC_WARNINGS="${GCC_WARNINGS} -Werror"
  1112. fi
  1113. # overide default gcc cflags
  1114. if test $gcc_warnings = yes; then
  1115. CFLAGS="$CFLAGS $GCC_WARNINGS"
  1116. fi
  1117. AC_CONFIG_FILES([
  1118. Makefile
  1119. src/Makefile
  1120. src/helper/Makefile
  1121. src/jtag/Makefile
  1122. src/jtag/drivers/Makefile
  1123. src/jtag/drivers/usb_blaster/Makefile
  1124. src/jtag/hla/Makefile
  1125. src/jtag/aice/Makefile
  1126. src/transport/Makefile
  1127. src/target/openrisc/Makefile
  1128. src/xsvf/Makefile
  1129. src/svf/Makefile
  1130. src/target/Makefile
  1131. src/rtos/Makefile
  1132. src/server/Makefile
  1133. src/flash/Makefile
  1134. src/flash/nor/Makefile
  1135. src/flash/nand/Makefile
  1136. src/pld/Makefile
  1137. doc/Makefile
  1138. ])
  1139. AC_OUTPUT
  1140. echo
  1141. echo
  1142. echo OpenOCD configuration summary
  1143. echo --------------------------------------------------
  1144. m4_foreach([adapter], [USB1_ADAPTERS, USB_ADAPTERS, USB0_ADAPTERS, HIDAPI_ADAPTERS],
  1145. [s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
  1146. case $ADAPTER_VAR([adapter]) in
  1147. auto)
  1148. echo "$s"yes '(auto)'
  1149. ;;
  1150. yes)
  1151. echo "$s"yes
  1152. ;;
  1153. no)
  1154. echo "$s"no
  1155. ;;
  1156. esac
  1157. ])
  1158. echo
  1159. if test $build_ft2232_libftdi = yes -o $build_ft2232_ftd2xx = yes; then
  1160. if test $enable_ftdi = no; then
  1161. AC_MSG_WARN([Building the deprecated 'ft2232' adapter driver but not its replacement!])
  1162. AC_MSG_WARN([Please consider using --enable-ftdi instead.])
  1163. else
  1164. AC_MSG_WARN([Building the deprecated 'ft2232' adapter driver.])
  1165. fi
  1166. fi