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.
 
 
 
 
 
 

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