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.
 
 
 
 
 
 

1323 lines
42 KiB

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