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.
 
 
 
 
 
 

1388 lines
44 KiB

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