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.
 
 
 
 
 
 

1024 lines
31 KiB

  1. AC_PREREQ(2.60)
  2. AC_INIT([openocd], [0.2.0-in-development],
  3. [OpenOCD Mailing List <openocd-development@lists.berlios.de>])
  4. AC_CONFIG_SRCDIR([src/openocd.c])
  5. AC_CANONICAL_HOST
  6. AC_SEARCH_LIBS([ioperm], [ioperm])
  7. AC_SEARCH_LIBS([dlopen], [dl])
  8. AC_CHECK_HEADERS(arpa/inet.h)
  9. AC_CHECK_HEADERS(elf.h)
  10. AC_CHECK_HEADERS(dirent.h)
  11. AC_CHECK_HEADERS(fcntl.h)
  12. AC_CHECK_HEADERS(ifaddrs.h)
  13. AC_CHECK_HEADERS(malloc.h)
  14. AC_CHECK_HEADERS(netdb.h)
  15. AC_CHECK_HEADERS(netinet/in.h)
  16. AC_CHECK_HEADERS(netinet/tcp.h)
  17. AC_CHECK_HEADERS(pthread.h)
  18. AC_CHECK_HEADERS(strings.h)
  19. AC_CHECK_HEADERS(sys/ioctl.h)
  20. AC_CHECK_HEADERS(sys/param.h)
  21. AC_CHECK_HEADERS(sys/poll.h)
  22. AC_CHECK_HEADERS(sys/select.h)
  23. AC_CHECK_HEADERS(sys/socket.h)
  24. AC_CHECK_HEADERS(sys/stat.h)
  25. AC_CHECK_HEADERS(sys/time.h)
  26. AC_CHECK_HEADERS(sys/types.h)
  27. AC_CHECK_HEADERS(unistd.h)
  28. AC_CHECK_HEADERS([net/if.h], [], [], [dnl
  29. #include <stdio.h>
  30. #ifdef STDC_HEADERS
  31. # include <stdlib.h>
  32. # include <stddef.h>
  33. #else
  34. # ifdef HAVE_STDLIB_H
  35. # include <stdlib.h>
  36. # endif
  37. #endif
  38. #ifdef HAVE_SYS_SOCKET_H
  39. # include <sys/socket.h>
  40. #endif
  41. ])
  42. AC_HEADER_ASSERT
  43. AC_HEADER_STDBOOL
  44. AC_HEADER_TIME
  45. AC_C_BIGENDIAN
  46. AC_CHECK_FUNCS(strndup)
  47. AC_CHECK_FUNCS(strnlen)
  48. AC_CHECK_FUNCS(gettimeofday)
  49. AC_CHECK_FUNCS(usleep)
  50. AC_CHECK_FUNCS(vasprintf)
  51. build_bitbang=no
  52. build_bitq=no
  53. is_cygwin=no
  54. is_mingw=no
  55. is_win32=no
  56. is_darwin=no
  57. build_release=yes
  58. AC_ARG_ENABLE(release,
  59. AS_HELP_STRING([--enable-release], [Enable Release Build, default no]),
  60. [build_release=$enableval], [build_release=no])
  61. if test $cross_compiling = no; then
  62. if test $build_release = no; then
  63. # check we can find guess-rev.sh
  64. AC_CHECK_FILE("$srcdir/guess-rev.sh", build_release=no, build_release=yes)
  65. fi
  66. fi
  67. # We are not *ALWAYS* being installed in the standard place.
  68. # We may be installed in a "tool-build" specific location.
  69. # Normally with other packages - as part of a tool distro.
  70. # Thus - we should search that 'libdir' also.
  71. #
  72. # And - if we are being installed there - the odds are
  73. # The libraries unique to what we are are there too.
  74. #
  75. # Expand nd deal with NONE - just like configure will do later
  76. OCDprefix=$prefix
  77. OCDxprefix=$exec_prefix
  78. test x"$OCDprefix" = xNONE && OCDprefix=$ac_default_prefix
  79. # Let make expand exec_prefix.
  80. test x"$OCDxprefix" = xNONE && OCDxprefix="$OCDprefix"
  81. # what matters is the "exec-prefix"
  82. if test "$OCDxprefix" != "$ac_default_prefix"
  83. then
  84. # We are installing in a non-standard place
  85. # Nonstandard --prefix and/or --exec-prefix
  86. # We have an override of some sort.
  87. # use build specific install library dir
  88. LDFLAGS="$LDFLAGS -L$OCDxprefix/lib"
  89. # RPATH becomes an issue on Linux only
  90. if test $host_os = linux-gnu || test $host_os = linux ; then
  91. LDFLAGS="$LDFLAGS -Wl,-rpath,$OCDxprefix/lib"
  92. fi
  93. # The "INCDIR" is also usable
  94. CFLAGS="$CFLAGS -I$includedir"
  95. fi
  96. AC_ARG_WITH(ftd2xx,
  97. AS_HELP_STRING([--with-ftd2xx=<PATH>],[This option has been removed.]),
  98. [
  99. # Option Given.
  100. cat << __EOF__
  101. The option: --with-ftd2xx=<PATH> has been removed.
  102. On Linux, the new option is:
  103. --with-ftd2xx-linux-tardir=/path/to/files
  104. Where <path> is the path the the directory where the "tar.gz" file
  105. from FTDICHIP.COM was unpacked, for example:
  106. --with-ftd2xx-linux-tardir=/home/duane/libftd2xx-linux-tardir=/home/duane/libftd2xx0.4.16
  107. On Cygwin/MingW32, the new option is:
  108. --with-ftd2xx-win32-zipdir=/path/to/files
  109. Where <path> is the path to the directory where the "zip" file from
  110. FTDICHIP.COM was unpacked, for example:
  111. --with-ftd2xx-win32-zipdir=/home/duane/ftd2xx.cdm.files
  112. __EOF__
  113. AC_MSG_ERROR([Sorry Cannot continue])
  114. ],
  115. [
  116. # Option not given
  117. true
  118. ]
  119. )
  120. #========================================
  121. # FTD2XXX support comes in 4 forms.
  122. # (1) win32 - via a zip file
  123. # (2) linux - via a tar file
  124. # (3) linux/cygwin/mingw - via libftdi
  125. # (4) darwin - installed under /usr/local
  126. #
  127. # In case (1) and (2) we need to know where the package was unpacked.
  128. AC_ARG_WITH(ftd2xx-win32-zipdir,
  129. AS_HELP_STRING([--with-ftd2xx-win32-zipdir],[Where (CYGWIN/MINGW) the zip file from ftdichip.com was unpacked <default=search>]),
  130. [
  131. # option present
  132. if test -d $with_ftd2xx_win32_zipdir
  133. then
  134. with_ftd2xx_win32_zipdir=`cd $with_ftd2xx_win32_zipdir && pwd`
  135. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_win32_zipdir])
  136. else
  137. AC_MSG_ERROR([Parameter to --with-ftd2xx-win32-zipdir is not a dir: $with_ftd2xx_win32_zipdir])
  138. fi
  139. ],
  140. [
  141. # not given
  142. true
  143. ]
  144. )
  145. AC_ARG_WITH(ftd2xx-linux-tardir,
  146. AS_HELP_STRING([--with-ftd2xx-linux-tardir], [Where (Linux/Unix) the tar file from ftdichip.com was unpacked <default=search>]),
  147. [
  148. # Option present
  149. if test $is_win32 = yes ; then
  150. AC_MSG_ERROR([The option: --with-ftd2xx-linux-tardir is only usable on linux])
  151. fi
  152. if test -d $with_ftd2xx_linux_tardir
  153. then
  154. with_ftd2xx_linux_tardir=`cd $with_ftd2xx_linux_tardir && pwd`
  155. AC_MSG_NOTICE([Using: ftdichip.com library: $with_ftd2xx_linux_tardir])
  156. else
  157. AC_MSG_ERROR([Parameter to --with-ftd2xx-linux-tardir is not a dir: $with_ftd2xx_linux_tardir])
  158. fi
  159. ],
  160. [
  161. # Not given
  162. true
  163. ]
  164. )
  165. AC_ARG_WITH(ftd2xx-lib,
  166. AS_HELP_STRING([--with-ftd2xx-lib], [Use static or shared ftd2xx libs on default static]),
  167. [
  168. case "$withval" in
  169. static)
  170. with_ftd2xx_lib=$withval
  171. ;;
  172. shared)
  173. with_ftd2xx_lib=$withval
  174. ;;
  175. *)
  176. AC_MSG_ERROR([Option: --with-ftd2xx-lib=static or --with-ftd2xx-lib=shared not, $withval])
  177. ;;
  178. esac
  179. ],
  180. [
  181. # Default is static - it is simpler :-(
  182. with_ftd2xx_lib=static
  183. ]
  184. )
  185. AC_ARG_ENABLE(gccwarnings,
  186. AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]),
  187. [gcc_warnings=$enableval], [gcc_warnings=yes])
  188. AC_ARG_ENABLE(wextra,
  189. AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]),
  190. [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings])
  191. AC_ARG_ENABLE(werror,
  192. AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]),
  193. [gcc_werror=$enableval], [gcc_werror=$gcc_warnings])
  194. # set default verbose options, overridden by following options
  195. debug_jtag_io=no
  196. debug_usb_io=no
  197. debug_usb_comms=no
  198. AC_ARG_ENABLE(verbose,
  199. AS_HELP_STRING([--enable-verbose],
  200. [Enable verbose JTAG I/O messages (for debugging).]),
  201. [
  202. debug_jtag_io=$enableval
  203. debug_usb_io=$enableval
  204. debug_usb_comms=$enableval
  205. ], [])
  206. AC_ARG_ENABLE(verbose_jtag_io,
  207. AS_HELP_STRING([--enable-verbose-jtag-io],
  208. [Enable verbose JTAG I/O messages (for debugging).]),
  209. [debug_jtag_io=$enableval], [])
  210. AC_ARG_ENABLE(verbose_usb_io,
  211. AS_HELP_STRING([--enable-verbose-usb-io],
  212. [Enable verbose USB I/O messages (for debugging)]),
  213. [debug_usb_io=$enableval], [])
  214. AC_ARG_ENABLE(verbose_usb_comms,
  215. AS_HELP_STRING([--enable-verbose-usb-comms],
  216. [Enable verbose USB communication messages (for debugging)]),
  217. [debug_usb_comms=$enableval], [])
  218. AC_MSG_CHECKING([whether to enable verbose JTAG I/O messages]);
  219. AC_MSG_RESULT($debug_jtag_io)
  220. if test $debug_jtag_io = yes; then
  221. AC_DEFINE([_DEBUG_JTAG_IO_],[1], [Print verbose JTAG I/O messages])
  222. fi
  223. AC_MSG_CHECKING([whether to enable verbose USB I/O messages]);
  224. AC_MSG_RESULT($debug_usb_io)
  225. if test $debug_usb_io = yes; then
  226. AC_DEFINE([_DEBUG_USB_IO_],[1], [Print verbose USB I/O messages])
  227. fi
  228. AC_MSG_CHECKING([whether to enable verbose USB communication messages]);
  229. AC_MSG_RESULT($debug_usb_comms)
  230. if test $debug_usb_comms = yes; then
  231. AC_DEFINE([_DEBUG_USB_COMMS_],[1], [Print verbose USB communication messages])
  232. fi
  233. debug_malloc=no
  234. AC_ARG_ENABLE(malloc_logging,
  235. AS_HELP_STRING([--enable-malloc-logging],
  236. [Include free space in logging messages (requires malloc.h).]),
  237. [debug_malloc=$enableval], [])
  238. AC_MSG_CHECKING([whether to enable malloc free space logging]);
  239. AC_MSG_RESULT($debug_malloc)
  240. if test $debug_malloc = yes; then
  241. AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
  242. fi
  243. AC_ARG_ENABLE(dummy,
  244. AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
  245. [build_dummy=$enableval], [build_dummy=no])
  246. AC_ARG_ENABLE(parport,
  247. AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
  248. [build_parport=$enableval], [build_parport=no])
  249. AC_ARG_ENABLE(parport_ppdev,
  250. AS_HELP_STRING([--disable-parport-ppdev],
  251. [Disable use of ppdev (/dev/parportN) for parport (for x86 only)]),
  252. [parport_use_ppdev=$enableval], [parport_use_ppdev=])
  253. AC_ARG_ENABLE(parport_giveio,
  254. AS_HELP_STRING([--enable-parport-giveio],
  255. [Enable use of giveio for parport (for CygWin only)]),
  256. [parport_use_giveio=$enableval], [parport_use_giveio=])
  257. AC_ARG_ENABLE(ft2232_libftdi,
  258. AS_HELP_STRING([--enable-ft2232_libftdi], [Enable building support for FT2232 based devices using the libftdi driver, opensource alternate of FTD2XX]),
  259. [build_ft2232_libftdi=$enableval], [build_ft2232_libftdi=no])
  260. AC_ARG_ENABLE(ft2232_ftd2xx,
  261. AS_HELP_STRING([--enable-ft2232_ftd2xx], [Enable building support for FT2232 based devices using the FTD2XX driver from ftdichip.com]),
  262. [build_ft2232_ftd2xx=$enableval], [build_ft2232_ftd2xx=no])
  263. AC_ARG_ENABLE(ftd2xx_highspeed,
  264. AS_HELP_STRING([--enable-ftd2xx-highspeed], [Enable building support for FT2232H and FT4232H-based devices (requires >=libftd2xx-0.4.16)]),
  265. [want_ftd2xx_highspeed=$enableval], [want_ftd2xx_highspeed=maybe])
  266. AC_ARG_ENABLE(amtjtagaccel,
  267. AS_HELP_STRING([--enable-amtjtagaccel], [Enable building the Amontec JTAG-Accelerator driver]),
  268. [build_amtjtagaccel=$enableval], [build_amtjtagaccel=no])
  269. AC_ARG_ENABLE(ecosboard,
  270. AS_HELP_STRING([--enable-ecosboard], [Enable building support for eCosBoard based JTAG debugger]),
  271. [build_ecosboard=$enableval], [build_ecosboard=no])
  272. AC_ARG_ENABLE(ioutil,
  273. AS_HELP_STRING([--enable-ioutil], [Enable ioutil functions - useful for standalone OpenOCD implementations]),
  274. [build_ioutil=$enableval], [build_ioutil=no])
  275. AC_ARG_ENABLE(httpd,
  276. AS_HELP_STRING([--enable-httpd], [Enable builtin httpd server - useful for standalone OpenOCD implementations]),
  277. [build_httpd=$enableval], [build_httpd=no])
  278. case "${host_cpu}" in
  279. arm*)
  280. AC_ARG_ENABLE(ep93xx,
  281. AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
  282. [build_ep93xx=$enableval], [build_ep93xx=no])
  283. AC_ARG_ENABLE(at91rm9200,
  284. AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
  285. [build_at91rm9200=$enableval], [build_at91rm9200=no])
  286. ;;
  287. *)
  288. build_ep93xx=no
  289. build_at91rm9200=no
  290. ;;
  291. esac
  292. AC_ARG_ENABLE(gw16012,
  293. AS_HELP_STRING([--enable-gw16012], [Enable building support for the Gateworks GW16012 JTAG Programmer]),
  294. [build_gw16012=$enableval], [build_gw16012=no])
  295. AC_ARG_ENABLE(presto_libftdi,
  296. AS_HELP_STRING([--enable-presto_libftdi], [Enable building support for ASIX Presto Programmer using the libftdi driver]),
  297. [build_presto_libftdi=$enableval], [build_presto_libftdi=no])
  298. AC_ARG_ENABLE(presto_ftd2xx,
  299. AS_HELP_STRING([--enable-presto_ftd2xx], [Enable building support for ASIX Presto Programmer using the FTD2XX driver]),
  300. [build_presto_ftd2xx=$enableval], [build_presto_ftd2xx=no])
  301. AC_ARG_ENABLE(usbprog,
  302. AS_HELP_STRING([--enable-usbprog], [Enable building support for the usbprog JTAG Programmer]),
  303. [build_usbprog=$enableval], [build_usbprog=no])
  304. AC_ARG_ENABLE(oocd_trace,
  305. AS_HELP_STRING([--enable-oocd_trace], [Enable building support for the OpenOCD+trace ETM capture device]),
  306. [build_oocd_trace=$enableval], [build_oocd_trace=no])
  307. AC_ARG_ENABLE(jlink,
  308. AS_HELP_STRING([--enable-jlink], [Enable building support for the Segger J-Link JTAG Programmer]),
  309. [build_jlink=$enableval], [build_jlink=no])
  310. AC_ARG_ENABLE(vsllink,
  311. AS_HELP_STRING([--enable-vsllink], [Enable building support for the Versaloon-Link JTAG Programmer]),
  312. [build_vsllink=$enableval], [build_vsllink=no])
  313. AC_ARG_ENABLE(rlink,
  314. AS_HELP_STRING([--enable-rlink], [Enable building support for the Raisonance RLink JTAG Programmer]),
  315. [build_rlink=$enableval], [build_rlink=no])
  316. AC_ARG_ENABLE(arm-jtag-ew,
  317. AS_HELP_STRING([--enable-arm-jtag-ew], [Enable building support for the Olimex ARM-JTAG-EW Programmer]),
  318. [build_armjtagew=$enableval], [build_armjtagew=no])
  319. AC_ARG_ENABLE(minidriver_dummy,
  320. AS_HELP_STRING([--enable-minidriver-dummy], [Enable the dummy minidriver.]),
  321. [build_minidriver_dummy=$enableval], [build_minidriver_dummy=no])
  322. build_minidriver=no
  323. AC_MSG_CHECKING([whether to enable ZY1000 minidriver])
  324. if test $build_ecosboard = yes; then
  325. # check for that project's header file in the current header search path
  326. AC_CHECK_HEADERS(jtag_minidriver.h, [build_minidriver=yes],
  327. AC_MSG_WARN([The --enable-ecosboard option needs the out-of-tree 'jtag_minidriver.h'])
  328. AC_MSG_ERROR([The out-of-tree jtag_minidriver.h cannot be found.])
  329. )
  330. build_minidriver=yes
  331. AC_DEFINE(BUILD_MINIDRIVER_DUMMY, 1, [Use the dummy minidriver.])
  332. fi
  333. AC_MSG_RESULT($build_ecosboard)
  334. AC_MSG_CHECKING([whether to enable dummy minidriver])
  335. if test $build_minidriver_dummy = yes; then
  336. if test $build_minidriver = yes; then
  337. AC_MSG_ERROR([Multiple minidriver options have been enabled.])
  338. fi
  339. build_minidriver=yes
  340. AC_DEFINE(BUILD_MINIDRIVER_DUMMY, 1, [Use the dummy minidriver.])
  341. AC_DEFINE(HAVE_JTAG_MINIDRIVER_H, 1,
  342. [Define to 1 if you have the <jtag_minidriver.h> header file.])
  343. fi
  344. AC_MSG_RESULT($build_minidriver_dummy)
  345. AC_MSG_CHECKING([whether standard drivers can be built])
  346. if test "$build_minidriver" = yes; then
  347. AC_MSG_RESULT([no])
  348. AC_MSG_WARN([Using the minidriver disables all other drivers.])
  349. sleep 2
  350. else
  351. AC_MSG_RESULT([yes])
  352. fi
  353. case "${host_cpu}" in
  354. i?86|x86*)
  355. ;;
  356. *)
  357. if test x$parport_use_ppdev = xno; then
  358. AC_MSG_WARN([--disable-parport-ppdev is not supported by the host CPU])
  359. fi
  360. parport_use_ppdev=yes
  361. ;;
  362. esac
  363. case $host in
  364. *-cygwin*)
  365. is_win32=yes
  366. AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[return __MINGW32__;]),[is_mingw=yes],[is_mingw=no])
  367. if test $is_mingw = yes; then
  368. AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
  369. if test x$parport_use_giveio = xno; then
  370. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  371. fi
  372. parport_use_giveio=yes
  373. is_cygwin=no
  374. else
  375. is_cygwin=yes
  376. AC_DEFINE(IS_CYGWIN, 1, [1 if building for Cygwin.])
  377. fi
  378. AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
  379. AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
  380. ;;
  381. *-mingw*)
  382. is_mingw=yes
  383. is_win32=yes
  384. if test x$parport_use_giveio = xno; then
  385. AC_MSG_WARN([--disable-parport-giveio is not supported by MinGW32 hosts])
  386. fi
  387. parport_use_giveio=yes
  388. AC_DEFINE(IS_MINGW, 1, [1 if building for MinGW.])
  389. AC_DEFINE(IS_WIN32, 1, [1 if building for Win32.])
  390. AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
  391. ;;
  392. *darwin*)
  393. is_darwin=yes
  394. if test x$parport_use_giveio = xyes; then
  395. AC_MSG_WARN([--enable-parport-giveio cannot be used by Darwin hosts])
  396. fi
  397. parport_use_giveio=no
  398. AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
  399. AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
  400. AC_DEFINE(IS_DARWIN, 1, [1 if building for Darwin.])
  401. ;;
  402. *)
  403. if test x$parport_use_giveio = xyes; then
  404. AC_MSG_WARN([--enable-parport-giveio cannot be used by ]$host[ hosts])
  405. fi
  406. parport_use_giveio=no
  407. AC_DEFINE(IS_CYGWIN, 0, [0 if not building for Cygwin.])
  408. AC_DEFINE(IS_WIN32, 0, [0 if not building for Win32.])
  409. AC_DEFINE(IS_DARWIN, 0, [0 if not building for Darwin.])
  410. ;;
  411. esac
  412. if test $build_parport = yes; then
  413. build_bitbang=yes
  414. AC_DEFINE(BUILD_PARPORT, 1, [1 if you want parport.])
  415. else
  416. AC_DEFINE(BUILD_PARPORT, 0, [0 if you don't want parport.])
  417. fi
  418. if test $build_dummy = yes; then
  419. build_bitbang=yes
  420. AC_DEFINE(BUILD_DUMMY, 1, [1 if you want dummy driver.])
  421. else
  422. AC_DEFINE(BUILD_DUMMY, 0, [0 if you don't want dummy driver.])
  423. fi
  424. if test $build_ep93xx = yes; then
  425. build_bitbang=yes
  426. AC_DEFINE(BUILD_EP93XX, 1, [1 if you want ep93xx.])
  427. else
  428. AC_DEFINE(BUILD_EP93XX, 0, [0 if you don't want ep93xx.])
  429. fi
  430. if test $build_ecosboard = yes; then
  431. AC_DEFINE(BUILD_ECOSBOARD, 1, [1 if you want eCosBoard.])
  432. else
  433. AC_DEFINE(BUILD_ECOSBOARD, 0, [0 if you don't want eCosBoard.])
  434. fi
  435. if test $build_ioutil = yes; then
  436. AC_DEFINE(BUILD_IOUTIL, 1, [1 if you want ioutils.])
  437. else
  438. AC_DEFINE(BUILD_IOUTIL, 0, [0 if you don't want ioutils.])
  439. fi
  440. if test $build_httpd = yes; then
  441. AC_DEFINE(BUILD_HTTPD, 1, [1 if you want httpd.])
  442. else
  443. AC_DEFINE(BUILD_HTTPD, 0, [0 if you don't want httpd.])
  444. fi
  445. if test $build_at91rm9200 = yes; then
  446. build_bitbang=yes
  447. AC_DEFINE(BUILD_AT91RM9200, 1, [1 if you want at91rm9200.])
  448. else
  449. AC_DEFINE(BUILD_AT91RM9200, 0, [0 if you don't want at91rm9200.])
  450. fi
  451. if test x$parport_use_ppdev = xyes; then
  452. AC_DEFINE(PARPORT_USE_PPDEV, 1, [1 if you want parport to use ppdev.])
  453. else
  454. AC_DEFINE(PARPORT_USE_PPDEV, 0, [0 if you don't want parport to use ppdev.])
  455. fi
  456. if test x$parport_use_giveio = xyes; then
  457. AC_DEFINE(PARPORT_USE_GIVEIO, 1, [1 if you want parport to use giveio.])
  458. else
  459. AC_DEFINE(PARPORT_USE_GIVEIO, 0, [0 if you don't want parport to use giveio.])
  460. fi
  461. if test $build_bitbang = yes; then
  462. AC_DEFINE(BUILD_BITBANG, 1, [1 if you want a bitbang interface.])
  463. else
  464. AC_DEFINE(BUILD_BITBANG, 0, [0 if you don't want a bitbang interface.])
  465. fi
  466. if test $build_ft2232_libftdi = yes; then
  467. AC_DEFINE(BUILD_FT2232_LIBFTDI, 1, [1 if you want libftdi ft2232.])
  468. else
  469. AC_DEFINE(BUILD_FT2232_LIBFTDI, 0, [0 if you don't want libftdi ft2232.])
  470. fi
  471. if test $build_ft2232_ftd2xx = yes; then
  472. AC_DEFINE(BUILD_FT2232_FTD2XX, 1, [1 if you want ftd2xx ft2232.])
  473. else
  474. AC_DEFINE(BUILD_FT2232_FTD2XX, 0, [0 if you don't want ftd2xx ft2232.])
  475. fi
  476. if test $build_amtjtagaccel = yes; then
  477. AC_DEFINE(BUILD_AMTJTAGACCEL, 1, [1 if you want the Amontec JTAG-Accelerator driver.])
  478. else
  479. AC_DEFINE(BUILD_AMTJTAGACCEL, 0, [0 if you don't want the Amontec JTAG-Accelerator driver.])
  480. fi
  481. if test $build_gw16012 = yes; then
  482. AC_DEFINE(BUILD_GW16012, 1, [1 if you want the Gateworks GW16012 driver.])
  483. else
  484. AC_DEFINE(BUILD_GW16012, 0, [0 if you don't want the Gateworks GW16012 driver.])
  485. fi
  486. if test $build_presto_libftdi = yes; then
  487. build_bitq=yes
  488. AC_DEFINE(BUILD_PRESTO_LIBFTDI, 1, [1 if you want the ASIX PRESTO driver using libftdi.])
  489. else
  490. AC_DEFINE(BUILD_PRESTO_LIBFTDI, 0, [0 if you don't want the ASIX PRESTO driver using libftdi.])
  491. fi
  492. if test $build_presto_ftd2xx = yes; then
  493. build_bitq=yes
  494. AC_DEFINE(BUILD_PRESTO_FTD2XX, 1, [1 if you want the ASIX PRESTO driver using FTD2XX.])
  495. else
  496. AC_DEFINE(BUILD_PRESTO_FTD2XX, 0, [0 if you don't want the ASIX PRESTO driver using FTD2XX.])
  497. fi
  498. if test $build_bitq = yes; then
  499. AC_DEFINE(BUILD_BITQ, 1, [1 if you want a bitq interface.])
  500. else
  501. AC_DEFINE(BUILD_BITQ, 0, [0 if you don't want a bitq interface.])
  502. fi
  503. if test $build_usbprog = yes; then
  504. AC_DEFINE(BUILD_USBPROG, 1, [1 if you want the usbprog JTAG driver.])
  505. else
  506. AC_DEFINE(BUILD_USBPROG, 0, [0 if you don't want the usbprog JTAG driver.])
  507. fi
  508. if test $build_oocd_trace = yes; then
  509. AC_DEFINE(BUILD_OOCD_TRACE, 1, [1 if you want the OpenOCD+trace ETM capture driver.])
  510. else
  511. AC_DEFINE(BUILD_OOCD_TRACE, 0, [0 if you don't want the OpenOCD+trace ETM capture driver.])
  512. fi
  513. if test $build_jlink = yes; then
  514. AC_DEFINE(BUILD_JLINK, 1, [1 if you want the J-Link JTAG driver.])
  515. else
  516. AC_DEFINE(BUILD_JLINK, 0, [0 if you don't want the J-Link JTAG driver.])
  517. fi
  518. if test $build_vsllink = yes; then
  519. AC_DEFINE(BUILD_VSLLINK, 1, [1 if you want the Versaloon-Link JTAG driver.])
  520. else
  521. AC_DEFINE(BUILD_VSLLINK, 0, [0 if you don't want the Versaloon-Link JTAG driver.])
  522. fi
  523. if test $build_rlink = yes; then
  524. AC_DEFINE(BUILD_RLINK, 1, [1 if you want the RLink JTAG driver.])
  525. else
  526. AC_DEFINE(BUILD_RLINK, 0, [0 if you don't want the RLink JTAG driver.])
  527. fi
  528. if test $build_armjtagew = yes; then
  529. AC_DEFINE(BUILD_ARMJTAGEW, 1, [1 if you want the ARM-JTAG-EW JTAG driver.])
  530. else
  531. AC_DEFINE(BUILD_ARMJTAGEW, 0, [0 if you don't want the ARM-JTAG-EW JTAG driver.])
  532. fi
  533. #-- Deal with MingW/Cygwin FTD2XX issues
  534. if test $is_win32 = yes; then
  535. if test "${with_ftd2xx_linux_tardir+set}" = set
  536. then
  537. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  538. fi
  539. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  540. AC_MSG_CHECKING([for ftd2xx.lib exists (win32)])
  541. # if we are given a zipdir...
  542. if test "${with_ftd2xx_win32_zipdir+set}" = set
  543. then
  544. # Set the CFLAGS for "ftd2xx.h"
  545. f=$with_ftd2xx_win32_zipdir/ftd2xx.h
  546. if test ! -f $f ; then
  547. AC_MSG_ERROR([File: $f cannot be found])
  548. fi
  549. CFLAGS="$CFLAGS -I$with_ftd2xx_win32_zipdir"
  550. # And calculate the LDFLAGS for the machine
  551. case "$host_cpu" in
  552. i?86|x86_*)
  553. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/i386"
  554. LIBS="$LIBS -lftd2xx"
  555. f=$with_ftd2xx_win32_zipdir/i386/ftd2xx.lib
  556. ;;
  557. amd64)
  558. LDFLAGS="$LDFLAGS -L$with_ftd2xx_win32_zipdir/amd64"
  559. LIBS="$LIBS -lftd2xx"
  560. f=$with_ftd2xx_win32_zipdir/amd64/ftd2xx.lib
  561. ;;
  562. *)
  563. AC_MSG_ERROR([Unknown Win32 host cpu: $host_cpu])
  564. ;;
  565. esac
  566. if test ! -f $f ; then
  567. AC_MSG_ERROR([Library: $f not found])
  568. fi
  569. else
  570. LIBS="$LIBS -lftd2xx"
  571. AC_MSG_WARN([ASSUMPTION: The (win32) FTDICHIP.COM files: ftd2xx.h and ftd2xx.lib are in a proper place])
  572. fi
  573. fi
  574. fi
  575. if test $is_darwin = yes ; then
  576. if test "${with_ftd2xx_win32_zipdir+set}" = set
  577. then
  578. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  579. fi
  580. if test "${with_ftd2xx_linux_tardir+set}" = set
  581. then
  582. AC_MSG_ERROR([The option: with_ftd2xx_linux_tardir is for LINUX only.])
  583. fi
  584. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  585. AC_MSG_CHECKING([for libftd2xx.a (darwin)])
  586. if test ! -f /usr/local/include/ftd2xx.h ; then
  587. AC_MSG_ERROR([ftd2xx library from FTDICHIP.com seems to be missing, cannot find: /usr/local/include/ftd2xx.h])
  588. fi
  589. CFLAGS="$CFLAGS -I/usr/local/include"
  590. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  591. LIBS="$LIBS -lftd2xx"
  592. AC_MSG_RESULT([-L/usr/local/lib -lftd2xx])
  593. fi
  594. fi
  595. if test $is_win32 = no && test $is_darwin = no ; then
  596. if test "${with_ftd2xx_win32_zipdir+set}" = set
  597. then
  598. AC_MSG_ERROR([The option: --with-ftd2xx-win32-zipdir is for win32 only])
  599. fi
  600. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes ; then
  601. # Must be linux
  602. if test $host_os != linux-gnu && test $host_os != linux ; then
  603. AC_MSG_ERROR([The (linux) ftd2xx library from FTDICHIP.com is linux only. Try --enable-ft2232-libftdi instead])
  604. fi
  605. # Are we given a TAR directory?
  606. if test "${with_ftd2xx_linux_tardir+set}" = set
  607. then
  608. AC_MSG_CHECKING([uninstalled ftd2xx distribution])
  609. # The .H file is simple..
  610. FTD2XX_H=$with_ftd2xx_linux_tardir/ftd2xx.h
  611. if test ! -f "${FTD2XX_H}"; then
  612. AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: ${FTD2XX_H}])
  613. fi
  614. CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir"
  615. FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir"
  616. FTD2XX_LIB="-lftd2xx"
  617. if test $with_ftd2xx_lib != shared; then
  618. # Test #1 - Future proof - if/when ftdichip fixes their distro.
  619. # Try it with the simple ".a" suffix.
  620. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a"
  621. if test -f "${FTD2XX_LIB}"; then
  622. FTD2XX_LDFLAGS="${FTD2XX_LDFLAGS}/static_lib"
  623. else
  624. # Test Number2.
  625. # Grr.. perhaps it exists as a version number?
  626. FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*"
  627. count=`ls ${FTD2XX_LIB} | wc -l`
  628. if test $count -gt 1 ; then
  629. AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet])
  630. fi
  631. if test $count -ne 1 ; then
  632. AC_MSG_ERROR([Not found: $f, option: --with-ftd2xx-linux-tardir appears to be wrong])
  633. fi
  634. # Because the "-l" rules do not understand version numbers...
  635. # we will just stuff the absolute path onto the LIBS variable
  636. FTD2XX_LIB="`ls ${FTD2XX_LIB}` -lpthread"
  637. FTD2XX_LDFLAGS=""
  638. fi
  639. fi
  640. LDFLAGS="${LDFLAGS} ${FTD2XX_LDFLAGS}"
  641. LIBS="${LIBS} ${FTD2XX_LIB}"
  642. AC_MSG_RESULT([${FTD2XX_LDFLAGS} ${FTD2XX_LIB}])
  643. else
  644. AC_CHECK_HEADER([ftd2xx.h],[],[
  645. AC_MSG_ERROR([You seem to be missing the FTD2xx driver header file.])
  646. ])
  647. AC_SEARCH_LIBS([FT_GetLibraryVersion],[ftd2xx],,[
  648. AC_MSG_ERROR([You appear to be missing the FTD2xx driver library.])
  649. ],[])
  650. fi
  651. fi
  652. fi
  653. if test $build_ft2232_ftd2xx = yes -o $build_presto_ftd2xx = yes; then
  654. # Before we go any further - make sure we can *BUILD* and *RUN*
  655. # a simple app with the "ftd2xx.lib" file - in what ever form we where given
  656. # We should be able to compile, link and run this test program now
  657. AC_MSG_CHECKING([whether ftd2xx library works])
  658. #
  659. # Save the LDFLAGS for later..
  660. LDFLAGS_SAVE=$LDFLAGS
  661. CFLAGS_SAVE=$CFLAGS
  662. _LDFLAGS=`eval echo $LDFLAGS`
  663. _CFLAGS=`eval echo $CFLAGS`
  664. LDFLAGS=$_LDFLAGS
  665. CFLAGS=$_CFLAGS
  666. AC_RUN_IFELSE(
  667. [
  668. #include "confdefs.h"
  669. #if IS_WIN32
  670. #include "windows.h"
  671. #endif
  672. #include <stdio.h>
  673. #include <ftd2xx.h>
  674. int
  675. main( int argc, char **argv )
  676. {
  677. DWORD x;
  678. FT_GetLibraryVersion( &x );
  679. return 0;
  680. }
  681. ], [ AC_MSG_RESULT([Success!])] , [ AC_MSG_ERROR([Cannot build & run test program using ftd2xx.lib]) ] )
  682. AC_MSG_CHECKING([whether to build ftd2xx device support])
  683. AC_MSG_RESULT([$want_ftd2xx_highspeed])
  684. if test $want_ftd2xx_highspeed != no; then
  685. AC_MSG_CHECKING([for ftd2xx highspeed device support])
  686. AC_COMPILE_IFELSE([
  687. #include "confdefs.h"
  688. #if IS_WIN32
  689. #include "windows.h"
  690. #endif
  691. #include <stdio.h>
  692. #include <ftd2xx.h>
  693. DWORD x = FT_DEVICE_4232H;
  694. ], [
  695. AC_DEFINE(BUILD_FTD2XX_HIGHSPEED, [1], [Support FT2232H/FT4232HS with FTD2XX.])
  696. build_ftd2xx_highspeed=yes
  697. ], [
  698. build_ftd2xx_highspeed=no
  699. ] )
  700. AC_MSG_RESULT([$build_ftd2xx_highspeed])
  701. if test $want_ftd2xx_highspeed = yes -a $build_ftd2xx_highspeed = no; then
  702. AC_MSG_ERROR([You need a newer FTD2XX driver (version 0.4.16 or later).])
  703. fi
  704. fi
  705. LDFLAGS=$LDFLAGS_SAVE
  706. CFLAGS=$CFLAGS_SAVE
  707. fi
  708. if test $build_ft2232_libftdi = yes ; then
  709. # We assume: the package is preinstalled in the proper place
  710. # these present as 2 libraries..
  711. LIBS="$LIBS -lftdi -lusb"
  712. #
  713. # Try to build a small program.
  714. AC_MSG_CHECKING([Build & Link with libftdi...])
  715. LDFLAGS_SAVE=$LDFLAGS
  716. CFLAGS_SAVE=$CFLAGS
  717. _LDFLAGS=`eval echo $LDFLAGS`
  718. _CFLAGS=`eval echo $CFLAGS`
  719. LDFLAGS=$_LDFLAGS
  720. CFLAGS=$_CFLAGS
  721. AC_RUN_IFELSE(
  722. [
  723. #include <stdio.h>
  724. #include <ftdi.h>
  725. int
  726. main( int argc, char **argv )
  727. {
  728. struct ftdi_context *p;
  729. p = ftdi_new();
  730. if( p != NULL ){
  731. return 0;
  732. } else {
  733. fprintf( stderr, "calling ftdi_new() failed\n");
  734. return 1;
  735. }
  736. }
  737. ]
  738. ,
  739. [ AC_MSG_RESULT([Success]) ]
  740. ,
  741. [ AC_MSG_ERROR([Cannot build & run test program using libftdi]) ] )
  742. # Restore the 'unexpanded ldflags'
  743. LDFLAGS=$LDFLAGS_SAVE
  744. CFLAGS=$CFLAGS_SAVE
  745. fi
  746. # check for usb.h when a driver will require it
  747. if test $build_jlink = yes -o $build_vsllink = yes -o $build_usbprog = yes -o \
  748. $build_rlink = yes -o $build_armjtagew = yes
  749. then
  750. AC_CHECK_HEADERS([usb.h],[],
  751. [AC_MSG_ERROR([usb.h is required to build some OpenOCD driver(s)])])
  752. fi
  753. AM_CONFIG_HEADER(config.h)
  754. AH_BOTTOM([
  755. #include "system.h"
  756. #include "replacements.h"
  757. ])
  758. AM_INIT_AUTOMAKE([-Wall -Wno-portability])
  759. AM_MAINTAINER_MODE
  760. AM_CONDITIONAL(RELEASE, test $build_release = yes)
  761. AM_CONDITIONAL(PARPORT, test $build_parport = yes)
  762. AM_CONDITIONAL(DUMMY, test $build_dummy = yes)
  763. AM_CONDITIONAL(GIVEIO, test x$parport_use_giveio = xyes)
  764. AM_CONDITIONAL(EP93XX, test $build_ep93xx = yes)
  765. AM_CONDITIONAL(ECOSBOARD, test $build_ecosboard = yes)
  766. AM_CONDITIONAL(IOUTIL, test $build_ioutil = yes)
  767. AM_CONDITIONAL(HTTPD, test $build_httpd = yes)
  768. AM_CONDITIONAL(AT91RM9200, test $build_at91rm9200 = yes)
  769. AM_CONDITIONAL(BITBANG, test $build_bitbang = yes)
  770. AM_CONDITIONAL(FT2232_LIBFTDI, test $build_ft2232_libftdi = yes)
  771. AM_CONDITIONAL(FT2232_FTD2XX, test $build_ft2232_ftd2xx = yes)
  772. AM_CONDITIONAL(AMTJTAGACCEL, test $build_amtjtagaccel = yes)
  773. AM_CONDITIONAL(GW16012, test $build_gw16012 = yes)
  774. AM_CONDITIONAL(PRESTO_LIBFTDI, test $build_presto_libftdi = yes)
  775. AM_CONDITIONAL(PRESTO_FTD2XX, test $build_presto_ftd2xx = yes)
  776. AM_CONDITIONAL(USBPROG, test $build_usbprog = yes)
  777. AM_CONDITIONAL(OOCD_TRACE, test $build_oocd_trace = yes)
  778. AM_CONDITIONAL(JLINK, test $build_jlink = yes)
  779. AM_CONDITIONAL(VSLLINK, test $build_vsllink = yes)
  780. AM_CONDITIONAL(RLINK, test $build_rlink = yes)
  781. AM_CONDITIONAL(ARMJTAGEW, test $build_armjtagew = yes)
  782. AM_CONDITIONAL(IS_CYGWIN, test $is_cygwin = yes)
  783. AM_CONDITIONAL(IS_MINGW, test $is_mingw = yes)
  784. AM_CONDITIONAL(IS_WIN32, test $is_win32 = yes)
  785. AM_CONDITIONAL(IS_DARWIN, test $is_darwin = yes)
  786. AM_CONDITIONAL(BITQ, test $build_bitq = yes)
  787. AM_CONDITIONAL(MINIDRIVER, test $build_minidriver = yes)
  788. AM_CONDITIONAL(MINIDRIVER_DUMMY, test $build_minidriver_dummy = yes)
  789. AC_LANG_C
  790. AC_PROG_CC
  791. AC_PROG_CC_C99
  792. AM_PROG_CC_C_O
  793. AC_PROG_RANLIB
  794. AC_PROG_LIBTOOL
  795. AC_PROG_INSTALL
  796. dnl configure checks required for Jim files (these are obsolete w/ C99)
  797. AC_C_CONST
  798. AC_TYPE_LONG_LONG_INT
  799. # Look for environ alternatives. Possibility #1: is environ in unistd.h or stdlib.h?
  800. AC_MSG_CHECKING([for environ in unistd.h and stdlib.h])
  801. AC_COMPILE_IFELSE([
  802. #define _GNU_SOURCE
  803. #include <unistd.h>
  804. #include <stdlib.h>
  805. int main(int argc, char **argv) { char **ep = environ; }
  806. ], [
  807. AC_MSG_RESULT([yes])
  808. has_environ=yes
  809. ], [
  810. AC_MSG_RESULT([no])
  811. # Possibility #2: can environ be found in an available library?
  812. AC_MSG_CHECKING([for extern environ])
  813. AC_LINK_IFELSE([
  814. extern char **environ;
  815. int main(int argc, char **argv) { char **ep = environ; }
  816. ], [
  817. AC_DEFINE(NEED_ENVIRON_EXTERN, [1], [Must declare 'environ' to use it.])
  818. has_environ=yes
  819. ], [
  820. has_environ=no
  821. ])
  822. AC_MSG_RESULT([${has_environ}])
  823. ])
  824. if test "${has_environ}" != "yes" ; then
  825. AC_MSG_FAILURE([Could not find 'environ' in unistd.h or available libraries.])
  826. fi
  827. AC_DEFINE([_GNU_SOURCE],[1],[Use GNU C library extensions (e.g. stdndup).])
  828. # set default gcc warnings
  829. GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security"
  830. if test "${gcc_wextra}" = yes; then
  831. GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter"
  832. GCC_WARNINGS="${GCC_WARNINGS} -Wbad-function-cast"
  833. GCC_WARNINGS="${GCC_WARNINGS} -Wcast-align"
  834. GCC_WARNINGS="${GCC_WARNINGS} -Wredundant-decls"
  835. fi
  836. if test "${gcc_werror}" = yes; then
  837. GCC_WARNINGS="${GCC_WARNINGS} -Werror"
  838. fi
  839. # overide default gcc cflags
  840. if test $gcc_warnings = yes; then
  841. CFLAGS="$CFLAGS $GCC_WARNINGS"
  842. fi
  843. # Setup for compiling build tools
  844. AC_MSG_CHECKING([for a C compiler for build tools])
  845. if test $cross_compiling = yes; then
  846. AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc)
  847. CFLAGS_FOR_BUILD="-g -O2 $GCC_WARNINGS"
  848. else
  849. CC_FOR_BUILD=$CC
  850. CFLAGS_FOR_BUILD=$CFLAGS
  851. fi
  852. AC_MSG_RESULT([$CC_FOR_BUILD])
  853. AC_SUBST(CC_FOR_BUILD)
  854. AC_SUBST(CFLAGS_FOR_BUILD)
  855. AC_MSG_CHECKING([for suffix of executable build tools])
  856. if test $cross_compiling = yes; then
  857. cat >conftest.c <<\_______EOF
  858. int main ()
  859. {
  860. exit (0);
  861. }
  862. _______EOF
  863. for i in .exe ""; do
  864. compile="$CC_FOR_BUILD conftest.c -o conftest$i"
  865. if AC_TRY_EVAL(compile); then
  866. if (./conftest) 2>&AC_FD_CC; then
  867. EXEEXT_FOR_BUILD=$i
  868. break
  869. fi
  870. fi
  871. done
  872. rm -f conftest*
  873. if test "${EXEEXT_FOR_BUILD+set}" != set; then
  874. AC_MSG_ERROR([Cannot determine suffix of executable build tools])
  875. fi
  876. else
  877. EXEEXT_FOR_BUILD=$EXEEXT
  878. fi
  879. AC_MSG_RESULT([$EXEEXT_FOR_BUILD])
  880. AC_SUBST(EXEEXT_FOR_BUILD)
  881. AC_OUTPUT(Makefile src/Makefile src/helper/Makefile src/jtag/Makefile src/xsvf/Makefile src/svf/Makefile src/target/Makefile src/server/Makefile src/flash/Makefile src/pld/Makefile doc/Makefile)