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.
 
 
 
 
 
 

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