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.
 
 
 
 
 
 

883 lines
27 KiB

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