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.
 
 
 
 
 
 

720 lines
21 KiB

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